wm: ircd

Download patch

ref: 7cba880065de2ed105300827caf939721812d5d0
parent: 8564cc83ea21e7c445abd6cdf99b790001c310f2
author: mkf <mkf@cloud9p.org>
date: Mon Sep 25 12:18:46 EDT 2023

add 403 (Nosuchchannel)

--- a/ircd.c
+++ b/ircd.c
@@ -31,6 +31,7 @@
 	Rpltopicwho,
 	Notregistered,
 	Alreadyregistered,
+	Nosuchchannel,
 	Unknowncmd,
 };
 
@@ -358,6 +359,10 @@
 		/* r->argv[0] is nick/channel */
 		n = snprint(buf, n, ":%s 401 %s %s :No such nick/channel\r\n", servername, c->nick, r->argv[0]);
 		break;
+	case Nosuchchannel:
+		/* r->argv is: channel */
+		n = snprint(buf, n, ":%s 403 %s :No such channel\r\n", servername, r->argv[0]);
+		break;
 	case Erroneousnick:
 		/* r->argv[0] is nick */
 		n = snprint(buf, n, ":%s 432 %s %s :Erroneous nickname\r\n", servername, c->nick, r->argv[0]);
@@ -683,12 +688,16 @@
 	if(ch == nil){
 		if(channels.size == Maxchannels){
 			fprint(2, "%d: Maxchannels reached\n", c->fd);
-			/* reply? */
+			r.code = Nosuchchannel;
+			r.argv[0] = chan;
+			reply(c, &r);
 			goto end;
 		}
 		if(!validchan(chan)){
 			dprint("%d: invalid chan %s\n", c->fd, chan);
-			/* reply? */
+			r.code = Nosuchchannel;
+			r.argv[0] = chan;
+			reply(c, &r);
 			goto end;
 		}
 		ch = addchan(chan);
@@ -993,7 +1002,7 @@
 		tmp2++;
 		return privmsg(c, tmp, tmp2);
 	}
-	/* JOIN #c or JOIN #c1,#c2, hence the check for "," */
+	/* JOIN #c or JOIN #c1,#c2 hence the check for "," */
 	if(strcmp(cmd, "JOIN") == 0){
 		tmp = strtok(0, " \r"); /* channels */
 		if(tmp == nil)