wm: ticl

Download patch

ref: c8499f76236656b20c24d0e2bc0690d4ae049b8f
parent: fb90d152ef67420872ed6f7a479b0fa6f201a725
author: libredev <libredev@ircforever.org>
date: Thu Feb 16 11:24:49 EST 2023

fixed NICK command

--- a/config.mk
+++ b/config.mk
@@ -9,6 +9,7 @@
 CPPFLAGS = -D_DEFAULT_SOURCE -DVERSION=\"$(VERSION)\"
 CFLAGS   = -g -std=c89 -Wall -Wextra -pedantic -Wfatal-errors -Wconversion\
 	   -Wstrict-prototypes -Wold-style-definition $(CPPFLAGS)
+CFLAGS	+= -rdynamic
 LDFLAGS  = $(LIBS)
 
 CC = cc
--- a/main.c
+++ b/main.c
@@ -228,7 +228,6 @@
 
 	free(networks);
 	free(fdtodata);
-	printf("table len: %d\n", usertofds->len);
 	htdestroy(usertofds);
 	return 0;
 }
@@ -307,7 +306,7 @@
 			int i;
 			for (i = 0; i < netlen; i++) {
 				if (strcmp(name, networks[i].name) == 0) {
-					snprintf(msg, sizeof(msg), "QUIT :unlinking %s\r\n", networks[i].name);
+					snprintf(msg, sizeof(msg), "QUIT :netdel: %s\r\n", networks[i].name);
 					net_del(i, msg, FALSE);
 					return;
 				}
@@ -622,14 +621,18 @@
 		/* allocate a new nick with net symbol and replace the old one */
 		newnick = emalloc((strlen(buf) + strlen(networks[netid].symb) + 2 + 1) * sizeof(char));
 		sprintf(newnick, "%s[%s]", buf, networks[netid].symb);
-		htmodkey(usertofds, nick, newnick);
 		snprintf(msg, sizeof(msg), "NICK %s\r\n", newnick);
 		for (i = 0; i < netlen; i++) {
 			if (fds[i] > 0) {
 				fdtodata[fds[i]]->user = newnick;
+				fdtodata[fds[i]]->suffix = 0;
 				writeall(fds[i], msg);
+			} else if (fds[i] == -3) {
+				reconn_list_del(nick, i);
+				reconn_list_add(newnick, i);
 			}
 		}
+		htmodkey(usertofds, nick, newnick);
 		return;
 	} else if (strcmp(cmd, "KICK") == 0) {
 		/* :<user_who_kicked>!~username@host KICK <channel> <user_who_is_being_kicked> :<kick_msg> */