wm: ircd

Download patch

ref: ba28c5fac80ac2c4110dac03fda42aae501ae2d5
parent: eff35fb697d4b13385578194a9c4c557c1274493
author: mkf <mkf@cloud9p.org>
date: Tue Sep 26 09:29:54 EDT 2023

add welcome(), and dummy motd

--- a/ircd.c
+++ b/ircd.c
@@ -2,7 +2,7 @@
 #include <libc.h>
 
 char *password = nil; /* nil to disable server password */
-
+char *motd = nil; /* nil for no motd */
 enum {
 	Maxclients = 48,
 	Maxchannels = 16,
@@ -94,6 +94,7 @@
 char date[32];
 int debug;
 
+
 int
 dprint(char *fmt, ...)
 {
@@ -463,13 +464,23 @@
 		replylist(&ch->members, r, skipme);
 	}
 }
+void
+welcome(Client *c)
+{
+	Reply r;
+	r.code = RPL_WELCOME;
+	reply(c, &r);
+	if(motd == nil){
+		r.code = ERR_NOMOTD;
+		reply(c, &r);
+	}
+}
 
 int
 setprefix(Client *c)
 {
 	/* fatal */
-	if(password != nil && !c->passok)
-	{
+	if(password != nil && !c->passok){
 		delclient(c);
 		return 1;
 	}
@@ -549,8 +560,7 @@
 	if(c->nick == nil)
 		return 1;
 
-	r.code = RPL_WELCOME;
-	reply(c, &r);
+	welcome(c);
 	return 1;
 }
 
@@ -603,10 +613,8 @@
 	}
 	qunlock(&clock);
 
-	if(first && c->user != nil){
-		r.code = RPL_WELCOME;
-		reply(c, &r);
-	}
+	if(first && c->user != nil)
+		welcome(c);
 	return 1;
 }