about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-15 04:54:53 -0500
committerJune McEnroe <june@causal.agency>2020-02-15 04:54:53 -0500
commit42d106260b5e881aad7bc4cf6c73ffb1b30b5abb (patch)
tree3a0ce91447067c10f7b47c3aa3e197545b875639
parentAdd /ns and /cs (diff)
downloadcatgirl-42d106260b5e881aad7bc4cf6c73ffb1b30b5abb.tar.gz
catgirl-42d106260b5e881aad7bc4cf6c73ffb1b30b5abb.zip
Separate network info from self
Diffstat (limited to '')
-rw-r--r--chat.c7
-rw-r--r--chat.h9
-rw-r--r--handle.c16
-rw-r--r--ui.c2
4 files changed, 19 insertions, 15 deletions
diff --git a/chat.c b/chat.c
index fd1d33e..318a379 100644
--- a/chat.c
+++ b/chat.c
@@ -65,6 +65,7 @@ enum Color idColors[IDCap] = {
 
 size_t idNext = Network + 1;
 
+struct Network network;
 struct Self self = { .color = Default };
 
 static const char *save;
@@ -187,10 +188,10 @@ int main(int argc, char *argv[]) {
 	if (!user) user = nick;
 	if (!real) real = nick;
 
+	set(&network.name, host);
+	set(&network.chanTypes, "#&");
+	set(&network.prefixes, "@+");
 	set(&self.nick, "*");
-	set(&self.network, host);
-	set(&self.chanTypes, "#&");
-	set(&self.prefixes, "@+");
 	commandComplete();
 
 	FILE *certFile = NULL;
diff --git a/chat.h b/chat.h
index c7ab5f7..9976786 100644
--- a/chat.h
+++ b/chat.h
@@ -82,15 +82,18 @@ enum Cap {
 #undef X
 };
 
+extern struct Network {
+	char *name;
+	char *chanTypes;
+	char *prefixes;
+} network;
+
 extern struct Self {
 	bool debug;
 	bool restricted;
 	char *plain;
 	const char *join;
 	enum Cap caps;
-	char *network;
-	char *chanTypes;
-	char *prefixes;
 	char *nick;
 	char *user;
 	enum Color color;
diff --git a/handle.c b/handle.c
index a73ae3e..f29d890 100644
--- a/handle.c
+++ b/handle.c
@@ -212,17 +212,17 @@ static void handleReplyISupport(struct Message *msg) {
 		char *key = strsep(&msg->params[i], "=");
 		if (!msg->params[i]) continue;
 		if (!strcmp(key, "NETWORK")) {
-			set(&self.network, msg->params[i]);
+			set(&network.name, msg->params[i]);
 			uiFormat(
 				Network, Cold, tagTime(msg),
 				"You arrive in %s", msg->params[i]
 			);
 		} else if (!strcmp(key, "CHANTYPES")) {
-			set(&self.chanTypes, msg->params[i]);
+			set(&network.chanTypes, msg->params[i]);
 		} else if (!strcmp(key, "PREFIX")) {
 			strsep(&msg->params[i], ")");
 			if (!msg->params[i]) continue;
-			set(&self.prefixes, msg->params[i]);
+			set(&network.prefixes, msg->params[i]);
 		}
 	}
 }
@@ -348,7 +348,7 @@ static void handleReplyNames(struct Message *msg) {
 	size_t len = 0;
 	while (msg->params[3]) {
 		char *name = strsep(&msg->params[3], " ");
-		name += strspn(name, self.prefixes);
+		name += strspn(name, network.prefixes);
 		char *nick = strsep(&name, "!");
 		char *user = strsep(&name, "@");
 		enum Color color = (user ? hash(user) : Default);
@@ -510,7 +510,7 @@ static void handleReplyWhoisChannels(struct Message *msg) {
 	size_t len = 0;
 	while (msg->params[2]) {
 		char *channel = strsep(&msg->params[2], " ");
-		channel += strspn(channel, self.prefixes);
+		channel += strspn(channel, network.prefixes);
 		int n = snprintf(
 			&buf[len], sizeof(buf) - len,
 			"%s\3%02d%s\3", (len ? ", " : ""), hash(channel), channel
@@ -642,11 +642,11 @@ static const char *colorMentions(size_t id, struct Message *msg) {
 
 static void handlePrivmsg(struct Message *msg) {
 	require(msg, true, 2);
-	bool query = !strchr(self.chanTypes, msg->params[0][0]);
-	bool network = strchr(msg->nick, '.');
+	bool query = !strchr(network.chanTypes, msg->params[0][0]);
+	bool server = strchr(msg->nick, '.');
 	bool mine = !strcmp(msg->nick, self.nick);
 	size_t id;
-	if (query && network) {
+	if (query && server) {
 		id = Network;
 	} else if (query && !mine) {
 		id = idFor(msg->nick);
diff --git a/ui.c b/ui.c
index 3b1fdc1..9cfc2eb 100644
--- a/ui.c
+++ b/ui.c
@@ -426,7 +426,7 @@ static void statusUpdate(void) {
 	wclrtoeol(status);
 
 	const struct Window *window = windows.ptrs[windows.show];
-	snprintf(title, sizeof(title), "%s %s", self.network, idNames[window->id]);
+	snprintf(title, sizeof(title), "%s %s", network.name, idNames[window->id]);
 	if (window->mark && window->unreadWarm) {
 		snprintf(
 			&title[strlen(title)], sizeof(title) - strlen(title),