Author: Kev <klmitch@undernet.org>
authorKevin L. Mitchell <klmitch@mit.edu>
Fri, 14 Apr 2000 20:19:41 +0000 (20:19 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Fri, 14 Apr 2000 20:19:41 +0000 (20:19 +0000)
Log message:

a couple of misc. bug fixes for gline code, start work on sendcmdto_*
series, include ircd_snprintf in linking (for sendcmdto_*), update gline
and jupe code to utilize the new functions.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@174 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/msg.h
include/send.h
ircd/Makefile.in
ircd/gline.c
ircd/ircd_snprintf.c
ircd/jupe.c
ircd/m_gline.c
ircd/m_jupe.c
ircd/s_user.c
ircd/send.c

index ffd711d770ec5844afc4bfd80419c51364639b9b..c684340a4e4154374698095e13bdd8122777cce9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,38 @@
 2000-04-14  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/s_user.c: move gline_lookup function call into
+       register_user, where it'll have a username to lookup!
+
+       * ircd/m_gline.c: modify to utilize new sendcmdto_* series of
+       functions; also stuff send_error_to_client into return clauses
+
+       * ircd/m_jupe.c: modify to utilize new sendcmdto_* series of
+       functions; also use send_error_to_client where that makes sense
+
+       * ircd/jupe.c: modify to utilize new sendcmdto_* series of
+       functions; also use send_error_to_client where that makes sense
+
+       * ircd/gline.c: modify to utilize new sendcmdto_* series of
+       functions; also fix gline_lookup() to deal properly with remote
+       clients--boy, do struct Client and struct User need to be cleaned
+       up!
+
+       * ircd/ircd_snprintf.c (doprintf): a dest of &me is a server,
+       too...
+
+       * ircd/send.c: wrote sendcmdto_one(), vsendcmdto_one(), and
+       sendcmdto_serv_butone(), all utilizing the %v conversion of
+       ircd_snprintf()
+
+       * include/send.h: define IRC_BUFSIZE, max size of a message;
+       declare sendcmdto_one(), vsendcmdto_one(), and
+       sendcmdto_serv_butone()
+
+       * include/msg.h: define all the CMD_* constants needed to utilize
+       the new sendcmdto_* series of functions
+
+       * ircd/Makefile.in (SRC): list ircd_snprintf.c; run make depend
+
        * ircd/gline.c: remove old, dead code.
 
        * ircd/m_gline.c (mo_gline): disallow setting of global G-lines
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.85 2000-04-14 17:37:00 kev Exp $
+# $Id: ChangeLog,v 1.86 2000-04-14 20:19:41 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 70a39f5d12fd5864b881e5fd21e3a3c21bde09eb..09c86dba5c6b3f807a9039cd8ba2d5d0bdd94c16 100644 (file)
@@ -48,211 +48,279 @@ struct Client;
 
 #define MSG_PRIVATE             "PRIVMSG"       /* PRIV */
 #define TOK_PRIVATE             "P"
+#define CMD_PRIVATE            MSG_PRIVATE, TOK_PRIVATE
 
 #define MSG_WHO                 "WHO"           /* WHO  -> WHOC */
 #define TOK_WHO                 "H"
+#define CMD_WHO                        MSG_WHO, TOK_WHO
 
 #define MSG_WHOIS               "WHOIS"         /* WHOI */
 #define TOK_WHOIS               "W"
+#define CMD_WHOIS              MSG_WHOIS, TOK_WHOIS
 
 #define MSG_WHOWAS              "WHOWAS"        /* WHOW */
 #define TOK_WHOWAS              "X"
+#define CMD_WHOWAS             MSG_WHOWAS, TOK_WHOWAS
 
 #define MSG_USER                "USER"          /* USER */
 #define TOK_USER                "USER"
+#define CMD_USER               MSG_USER, TOK_USER
 
 #define MSG_NICK                "NICK"          /* NICK */
 #define TOK_NICK                "N"
+#define CMD_NICK               MSG_NICK, TOK_NICK
 
 #define MSG_SERVER              "SERVER"        /* SERV */
 #define TOK_SERVER              "S"
+#define CMD_SERVER             MSG_SERVER, TOK_SERVER
 
 #define MSG_LIST                "LIST"          /* LIST */
 #define TOK_LIST                "LIST"
+#define CMD_LIST               MSG_LIST, TOK_LIST
 
 #define MSG_TOPIC               "TOPIC"         /* TOPI */
 #define TOK_TOPIC               "T"
+#define CMD_TOPIC              MSG_TOPIC, TOK_TOPIC
 
 #define MSG_INVITE              "INVITE"        /* INVI */
 #define TOK_INVITE              "I"
+#define CMD_INVITE             MSG_INVITE, TOK_INVITE
 
 #define MSG_VERSION             "VERSION"       /* VERS */
 #define TOK_VERSION             "V"
+#define CMD_VERSION            MSG_VERSION, TOK_VERSION
 
 #define MSG_QUIT                "QUIT"          /* QUIT */
 #define TOK_QUIT                "Q"
+#define CMD_QUIT               MSG_QUIT, TOK_QUIT
 
 #define MSG_SQUIT               "SQUIT"         /* SQUI */
 #define TOK_SQUIT               "SQ"
+#define CMD_SQUIT              MSG_SQUIT, TOK_SQUIT
 
 #define MSG_KILL                "KILL"          /* KILL */
 #define TOK_KILL                "D"
+#define CMD_KILL               MSG_KILL, TOK_KILL
 
 #define MSG_INFO                "INFO"          /* INFO */
 #define TOK_INFO                "F"
+#define CMD_INFO               MSG_INFO, TOK_INFO
 
 #define MSG_LINKS               "LINKS"         /* LINK */
 #define TOK_LINKS               "LI"
+#define CMD_LINKS              MSG_LINKS, TOK_LINKS
 
 #define MSG_STATS               "STATS"         /* STAT */
 #define TOK_STATS               "R"
+#define CMD_STATS              MSG_STATS, TOK_STATS
 
 #define MSG_HELP                "HELP"          /* HELP */
 #define TOK_HELP                "HELP"
+#define CMD_HELP               MSG_HELP, TOK_HELP
 
 #define MSG_ERROR               "ERROR"         /* ERRO */
 #define TOK_ERROR               "Y"
+#define CMD_ERROR              MSG_ERROR, TOK_ERROR
 
 #define MSG_AWAY                "AWAY"          /* AWAY */
 #define TOK_AWAY                "A"
+#define CMD_AWAY               MSG_AWAY, TOK_AWAY
 
 #define MSG_CONNECT             "CONNECT"       /* CONN */
 #define TOK_CONNECT             "CO"
+#define CMD_CONNECT            MSG_CONNECT, TOK_CONNECT
 
 #define MSG_MAP                 "MAP"           /* MAP  */
 #define TOK_MAP                 "MAP"
+#define CMD_MAP                        MSG_MAP, TOK_MAP
 
 #define MSG_PING                "PING"          /* PING */
 #define TOK_PING                "G"
+#define CMD_PING               MSG_PING, TOK_PING
 
 #define MSG_PONG                "PONG"          /* PONG */
 #define TOK_PONG                "Z"
+#define CMD_PONG               MSG_PONG, TOK_PONG
 
 #define MSG_OPER                "OPER"          /* OPER */
 #define TOK_OPER                "OPER"
+#define CMD_OPER               MSG_OPER, TOK_OPER
 
 #define MSG_PASS                "PASS"          /* PASS */
 #define TOK_PASS                "PA"
+#define CMD_PASS               MSG_PASS, TOK_PASS
 
 #define MSG_WALLOPS             "WALLOPS"       /* WALL */
 #define TOK_WALLOPS             "WA"
+#define CMD_WALLOPS            MSG_WALLOPS, TOK_WALLOPS
 
 #define MSG_DESYNCH             "DESYNCH"       /* DESY */
 #define TOK_DESYNCH             "DS"
+#define CMD_DESYNCH            MSG_DESYNCH, TOK_DESYNCH
 
 #define MSG_TIME                "TIME"          /* TIME */
 #define TOK_TIME                "TI"
+#define CMD_TIME               MSG_TIME, TOK_TIME
 
 #define MSG_SETTIME             "SETTIME"       /* SETT */
 #define TOK_SETTIME             "SE"
+#define CMD_SETTIME            MSG_SETTIME, TOK_SETTIME
 
 #define MSG_RPING               "RPING"         /* RPIN */
 #define TOK_RPING               "RI"
+#define CMD_RPING              MSG_RPING, TOK_RPING
 
 #define MSG_RPONG               "RPONG"         /* RPON */
 #define TOK_RPONG               "RO"
+#define CMD_RPONG              MSG_RPONG, TOK_RPONG
 
 #define MSG_NAMES               "NAMES"         /* NAME */
 #define TOK_NAMES               "E"
+#define CMD_NAMES              MSG_NAMES, TOK_NAMES
 
 #define MSG_ADMIN               "ADMIN"         /* ADMI */
 #define TOK_ADMIN               "AD"
+#define CMD_ADMIN              MSG_ADMIN, TOK_ADMIN
 
 #define MSG_TRACE               "TRACE"         /* TRAC */
 #define TOK_TRACE               "TR"
+#define CMD_TRACE              MSG_TRACE, TOK_TRACE
 
 #define MSG_NOTICE              "NOTICE"        /* NOTI */
 #define TOK_NOTICE              "O"
+#define CMD_NOTICE             MSG_NOTICE, TOK_NOTICE
 
 #define MSG_WALLCHOPS           "WALLCHOPS"     /* WC */
 #define TOK_WALLCHOPS           "WC"
+#define CMD_WALLCHOPS          MSG_WALLCHOPS, TOK_WALLCHOPS
 
 #define MSG_CPRIVMSG            "CPRIVMSG"      /* CPRI */
 #define TOK_CPRIVMSG            "CP"
+#define CMD_CPRIVMSG           MSG_CPRIVMSG, TOK_CPRIVMSG
 
 #define MSG_CNOTICE             "CNOTICE"       /* CNOT */
 #define TOK_CNOTICE             "CN"
+#define CMD_CNOTICE            MSG_CNOTICE, TOK_CNOTICE
 
 #define MSG_JOIN                "JOIN"          /* JOIN */
 #define TOK_JOIN                "J"
+#define CMD_JOIN               MSG_JOIN, TOK_JOIN
 
 #define MSG_PART                "PART"          /* PART */
 #define TOK_PART                "L"
+#define CMD_PART               MSG_PART, TOK_PART
 
 #define MSG_LUSERS              "LUSERS"        /* LUSE */
 #define TOK_LUSERS              "LU"
+#define CMD_LUSERS             MSG_LUSERS, TOK_LUSERS
 
 #define MSG_MOTD                "MOTD"          /* MOTD */
 #define TOK_MOTD                "MO"
+#define CMD_MOTD               MSG_MOTD, TOK_MOTD
 
 #define MSG_MODE                "MODE"          /* MODE */
 #define TOK_MODE                "M"
+#define CMD_MODE               MSG_MODE, TOK_MODE
 
 #define MSG_KICK                "KICK"          /* KICK */
 #define TOK_KICK                "K"
+#define CMD_KICK               MSG_KICK, TOK_KICK
 
 #define MSG_USERHOST            "USERHOST"      /* USER -> USRH */
 #define TOK_USERHOST            "USERHOST"
+#define CMD_USERHOST           MSG_USERHOST, TOK_USERHOST
 
 #define MSG_USERIP              "USERIP"        /* USER -> USIP */
 #define TOK_USERIP              "USERIP"
+#define CMD_USERIP             MSG_USERIP, TOK_USERIP
 
 #define MSG_ISON                "ISON"          /* ISON */
 #define TOK_ISON                "ISON"
+#define CMD_ISON               MSG_ISON, TOK_ISON
 
 #define MSG_SQUERY              "SQUERY"        /* SQUE */
 #define TOK_SQUERY              "SQUERY"
+#define CMD_SQUERY             MSG_SQUERY, TOK_SQUERY
 
 #define MSG_SERVLIST            "SERVLIST"      /* SERV -> SLIS */
 #define TOK_SERVLIST            "SERVSET"
+#define CMD_SERVLIST           MSG_SERVLIST, TOK_SERVLIST
 
 #define MSG_SERVSET             "SERVSET"       /* SERV -> SSET */
 #define TOK_SERVSET             "SERVSET"
+#define CMD_SERVSET            MSG_SERVSET, TOK_SERVSET
 
 #define MSG_REHASH              "REHASH"        /* REHA */
 #define TOK_REHASH              "REHASH"
+#define CMD_REHASH             MSG_REHASH, TOK_REHASH
 
 #define MSG_RESTART             "RESTART"       /* REST */
 #define TOK_RESTART             "RESTART"
+#define CMD_RESTART            MSG_RESTART, TOK_RESTART
 
 #define MSG_CLOSE               "CLOSE"         /* CLOS */
 #define TOK_CLOSE               "CLOSE"
+#define CMD_CLOSE              MSG_CLOSE, TOK_CLOSE
 
 #define MSG_DIE                 "DIE"           /* DIE  */
 #define TOK_DIE                 "DIE"
+#define CMD_DIE                        MSG_DIE, TOK_DIE
 
 #define MSG_HASH                "HASH"          /* HASH */
 #define TOK_HASH                "HASH"
+#define CMD_HASH               MSG_HASH, TOK_HASH
 
 #define MSG_DNS                 "DNS"           /* DNS  -> DNSS */
 #define TOK_DNS                 "DNS"
+#define CMD_DNS                        MSG_DNS, TOK_DNS
 
 #define MSG_SILENCE             "SILENCE"       /* SILE */
 #define TOK_SILENCE             "U"
+#define CMD_SILENCE            MSG_SILENCE, TOK_SILENCE
 
 #define MSG_GLINE               "GLINE"         /* GLIN */
 #define TOK_GLINE               "GL"
+#define CMD_GLINE              MSG_GLINE, TOK_GLINE
 
 #define MSG_BURST               "BURST"         /* BURS */
 #define TOK_BURST               "B"
+#define CMD_BURST              MSG_BURST, TOK_BURST
 
 #define MSG_UPING               "UPING"         /* UPIN */
 #define TOK_UPING               "UP"
+#define CMD_UPING              MSG_UPING, TOK_UPING
 
 #define MSG_CREATE              "CREATE"        /* CREA */
 #define TOK_CREATE              "C"
+#define CMD_CREATE             MSG_CREATE, TOK_CREATE
 
 #define MSG_DESTRUCT            "DESTRUCT"      /* DEST */
 #define TOK_DESTRUCT            "DE"
+#define CMD_DESTRUCT           MSG_DESTRUCT, TOK_DESTRUCT
 
 #define MSG_END_OF_BURST        "END_OF_BURST"  /* END_ */
 #define TOK_END_OF_BURST        "EB"
+#define CMD_END_OF_BURST       MSG_END_OF_BURST, TOK_END_OF_BURST
 
 #define MSG_END_OF_BURST_ACK    "EOB_ACK"       /* EOB_ */
 #define TOK_END_OF_BURST_ACK    "EA"
+#define CMD_END_OF_BURST_ACK   MSG_END_OF_BURST_ACK, TOK_END_OF_BURST_ACK
 
 #define MSG_PROTO               "PROTO"         /* PROTO */
 #define TOK_PROTO               "PROTO"         /* PROTO */
+#define CMD_PROTO              MSG_PROTO, TOK_PROTO
 
 #define MSG_JUPE                "JUPE"          /* JUPE */
 #define TOK_JUPE                "JU"
+#define CMD_JUPE               MSG_JUPE, TOK_JUPE
 
 #define MSG_OPMODE              "OPMODE"        /* OPMO */
 #define TOK_OPMODE              "OM"
+#define CMD_OPMODE             MSG_OPMODE, TOK_OPMODE
 
 #define MSG_CLEARMODE           "CLEARMODE"     /* CLMO */
 #define TOK_CLEARMODE           "CM"
-
+#define CMD_CLEARMODE          MSG_CLEARMODE, TOK_CLEARMODE
 
 /*
  * Constants
index 422e62b8938f9bcb9c65b829e31f16039af700a9..b28d2f25c5c9d1d1b580006da80894054baa5242 100644 (file)
@@ -64,4 +64,16 @@ extern void sendbufto_serv_butone(struct Client *one);
 
 extern char sendbuf[2048];
 
+#define IRC_BUFSIZE    512
+
+extern void sendcmdto_one(struct Client *one, const char *cmd,
+                         const char *tok, struct Client *from,
+                         const char *fmt, ...);
+extern void vsendcmdto_one(struct Client *one, const char *cmd,
+                          const char *tok, struct Client *from,
+                          const char *fmt, va_list vl);
+extern void sendcmdto_serv_butone(struct Client *one, const char *cmd,
+                                 const char *tok, struct Client *from,
+                                 const char *fmt, ...);
+
 #endif /* INCLUDED_send_h */
index 24be062d377de94e8ef7d4c6af7829f6276aad81..189cd0a8c2cce0620d962982ed2ad604d2d145b9 100644 (file)
@@ -76,6 +76,7 @@ SRC = \
        ircd_relay.c \
        ircd_reply.c \
        ircd_signal.c \
+       ircd_snprintf.c \
        ircd_string.c \
        ircd_xopen.c \
        jupe.c \
@@ -365,6 +366,10 @@ ircd_reply.o: ircd_reply.c ../include/ircd_reply.h ../include/client.h \
 ircd_signal.o: ircd_signal.c ../include/ircd_signal.h \
  ../include/ircd.h ../config/config.h ../config/setup.h \
  ../include/struct.h ../include/ircd_defs.h
+ircd_snprintf.o: ircd_snprintf.c ../include/client.h ../include/dbuf.h \
+ ../include/ircd_defs.h ../include/ircd_handler.h \
+ ../include/ircd_snprintf.h ../config/config.h ../config/setup.h \
+ ../include/struct.h
 ircd_string.o: ircd_string.c ../include/ircd_string.h \
  ../config/config.h ../config/setup.h ../include/ircd_chattr.h \
  ../include/ircd_defs.h chattr.tab.c
@@ -373,10 +378,11 @@ jupe.o: jupe.c ../include/jupe.h ../config/config.h ../config/setup.h \
  ../include/client.h ../include/dbuf.h ../include/ircd_defs.h \
  ../include/ircd_handler.h ../include/hash.h ../include/ircd.h \
  ../include/struct.h ../include/ircd_alloc.h ../include/fda.h \
- ../include/ircd_string.h ../include/ircd_chattr.h ../include/match.h \
- ../include/msg.h ../include/numeric.h ../include/numnicks.h \
- ../include/s_bsd.h ../include/s_misc.h ../include/send.h \
- ../include/support.h ../include/sys.h
+ ../include/ircd_reply.h ../include/ircd_string.h \
+ ../include/ircd_chattr.h ../include/match.h ../include/msg.h \
+ ../include/numeric.h ../include/numnicks.h ../include/s_bsd.h \
+ ../include/s_misc.h ../include/send.h ../include/support.h \
+ ../include/sys.h
 list.o: list.c ../include/list.h ../include/class.h \
  ../include/client.h ../include/dbuf.h ../include/ircd_defs.h \
  ../include/ircd_handler.h ../include/ircd.h ../config/config.h \
@@ -967,10 +973,11 @@ send.o: send.c ../include/send.h ../include/channel.h \
  ../config/config.h ../config/setup.h ../include/ircd_defs.h \
  ../include/class.h ../include/client.h ../include/dbuf.h \
  ../include/ircd_handler.h ../include/ircd.h ../include/struct.h \
- ../include/ircd_string.h ../include/ircd_chattr.h ../include/list.h \
- ../include/match.h ../include/msg.h ../include/numnicks.h \
- ../include/s_bsd.h ../include/s_debug.h ../include/s_misc.h \
- ../include/s_user.h ../include/sprintf_irc.h ../include/sys.h
+ ../include/ircd_snprintf.h ../include/ircd_string.h \
+ ../include/ircd_chattr.h ../include/list.h ../include/match.h \
+ ../include/msg.h ../include/numnicks.h ../include/s_bsd.h \
+ ../include/s_debug.h ../include/s_misc.h ../include/s_user.h \
+ ../include/sprintf_irc.h ../include/sys.h
 sprintf_irc.o: sprintf_irc.c ../include/sprintf_irc.h ../include/sys.h \
  ../config/config.h ../config/setup.h
 support.o: support.c ../include/support.h ../config/config.h \
index 61f490471ecbaa46afe5bc1aa443d9313be525c3..f83ff6b012f83fe70382ebc99b84d707ca9a3c1f 100644 (file)
@@ -144,36 +144,22 @@ do_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
 static void
 propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
 {
-  if (GlineIsLocal(gline)) /* don't propagate local glines */
+  if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod))
     return;
 
-  if (IsUser(sptr)) { /* select appropriate source */
-    if (!gline->gl_lastmod)
-      return;
-    sendto_serv_butone(cptr, "%s%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " "
-                      TIME_T_FMT " :%s", NumNick(sptr),
-                      GlineIsActive(gline) ? '+' : '-', gline->gl_user,
-                      GlineIsBadChan(gline) ? "" : "@",
-                      GlineIsBadChan(gline) ? "" : gline->gl_host,
-                      gline->gl_expire - TStime(), gline->gl_lastmod,
-                      gline->gl_reason);
-  } else {
-    if (gline->gl_lastmod)
-      sendto_serv_butone(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " "
-                        TIME_T_FMT " :%s", NumServ(sptr),
-                        GlineIsActive(gline) ? '+' : '-', gline->gl_user,
-                        GlineIsBadChan(gline) ? "" : "@",
-                        GlineIsBadChan(gline) ? "" : gline->gl_host,
-                        gline->gl_expire - TStime(), gline->gl_lastmod,
-                        gline->gl_reason);
-    else
-      sendto_serv_butone(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT
-                        " :%s", NumServ(sptr),
-                        GlineIsActive(gline) ? '+' : '-', gline->gl_user,
-                        GlineIsBadChan(gline) ? "" : "@",
-                        GlineIsBadChan(gline) ? "" : gline->gl_host,
-                        gline->gl_expire - TStime(), gline->gl_reason);
-  }
+  if (gline->gl_lastmod)
+    sendcmdto_serv_butone(cptr, CMD_GLINE, sptr, "* %c%s%s%s %Tu %Tu :%s",
+                         GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                         GlineIsBadChan(gline) ? "" : "@",
+                         GlineIsBadChan(gline) ? "" : gline->gl_host,
+                         gline->gl_expire - TStime(), gline->gl_lastmod,
+                         gline->gl_reason);
+  else
+    sendcmdto_serv_butone(cptr, CMD_GLINE, sptr, "* %c%s%s%s %Tu :%s",
+                         GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                         GlineIsBadChan(gline) ? "" : "@",
+                         GlineIsBadChan(gline) ? "" : gline->gl_host,
+                         gline->gl_expire - TStime(), gline->gl_reason);
 }
 
 int 
@@ -402,8 +388,8 @@ gline_lookup(struct Client *cptr)
     if (gline->gl_expire <= TStime())
       gline_free(gline);
     else if ((GlineIsIpMask(gline) ?
-             match(gline->gl_host, cptr->sock_ip) :
-             match(gline->gl_host, cptr->sockhost)) == 0 &&
+             match(gline->gl_host, ircd_ntoa((const char *)&cptr->ip)) :
+             match(gline->gl_host, cptr->user->host)) == 0 &&
             match(gline->gl_user, cptr->user->username) == 0)
       return gline;
   }
@@ -439,10 +425,10 @@ gline_burst(struct Client *cptr)
     if (gline->gl_expire <= TStime()) /* expire any that need expiring */
       gline_free(gline);
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
-      sendto_one(cptr, "%s " TOK_GLINE " * %c%s@%s " TIME_T_FMT " " TIME_T_FMT
-                " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-                gline->gl_user, gline->gl_host, gline->gl_expire - TStime(),
-                gline->gl_lastmod, gline->gl_reason);
+      sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s@%s %Tu %Tu :%s",
+                   GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                   gline->gl_host, gline->gl_expire - TStime(),
+                   gline->gl_lastmod, gline->gl_reason);
   }
 
   for (gline = BadChanGlineList; gline; gline = sgline) { /* all glines */
@@ -451,10 +437,10 @@ gline_burst(struct Client *cptr)
     if (gline->gl_expire <= TStime()) /* expire any that need expiring */
       gline_free(gline);
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
-      sendto_one(cptr, "%s " TOK_GLINE " * %c%s " TIME_T_FMT " " TIME_T_FMT
-                " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-                gline->gl_user, gline->gl_expire - TStime(),
-                gline->gl_lastmod, gline->gl_reason);
+      sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s %Tu %Tu :%s",
+                   GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                   gline->gl_expire - TStime(), gline->gl_lastmod,
+                   gline->gl_reason);
   }
 }
 
@@ -464,11 +450,12 @@ gline_resend(struct Client *cptr, struct Gline *gline)
   if (GlineIsLocal(gline) || !gline->gl_lastmod)
     return 0;
 
-  sendto_one(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " " TIME_T_FMT
-            " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-            gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
-            GlineIsBadChan(gline) ? "" : gline->gl_host,
-            gline->gl_expire - TStime(), gline->gl_lastmod, gline->gl_reason);
+  sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s%s%s %Tu %Tu :%s",
+               GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+               GlineIsBadChan(gline) ? "" : "@",
+               GlineIsBadChan(gline) ? "" : gline->gl_host,
+               gline->gl_expire - TStime(), gline->gl_lastmod,
+               gline->gl_reason);
 
   return 0;
 }
index 2cbf74178defba9eb3178cc26996b0448e8d5aa8..fa3e7cae5e492233c1dbe84268dfb59710509d24 100644 (file)
@@ -1996,8 +1996,9 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt,
       char *str1 = 0, *str2 = 0;
       int slen1 = 0, slen2 = 0, plen = 0;
 
-      if (dest && IsServer(dest)) {
-       if (IsServer(cptr))
+      /* &me is used if it's not a definite server */
+      if (dest && (IsServer(dest) || IsMe(dest))) {
+       if (IsServer(cptr) || IsMe(cptr))
          str1 = cptr->yxx;
        else {
          str1 = cptr->user->server->yxx;
index bde16cbf9665a3decccb4e8b19721032f5dc39dd..d9132ac58ab89c2bd5871465f81137a4ec6084d5 100644 (file)
@@ -25,6 +25,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
 #include "msg.h"
@@ -88,18 +89,10 @@ propagate_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe)
   if (JupeIsLocal(jupe)) /* don't propagate local jupes */
     return;
 
-  if (IsUser(sptr)) /* select correct prefix */
-    sendto_serv_butone(cptr, "%s%s " TOK_JUPE " * %c%s " TIME_T_FMT " "
-                      TIME_T_FMT " :%s", NumNick(sptr),
-                      JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
-                      jupe->ju_expire - TStime(), jupe->ju_lastmod,
-                      jupe->ju_reason);
-  else
-    sendto_serv_butone(cptr, "%s " TOK_JUPE " * %c%s " TIME_T_FMT " "
-                      TIME_T_FMT " :%s", NumServ(sptr),
-                      JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
-                      jupe->ju_expire - TStime(), jupe->ju_lastmod,
-                      jupe->ju_reason);
+  sendcmdto_serv_butone(cptr, CMD_JUPE, sptr, "* %c%s %Tu %Tu :%s",
+                       JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
+                       jupe->ju_expire - TStime(), jupe->ju_lastmod,
+                       jupe->ju_reason);
 }
 
 int
@@ -118,7 +111,7 @@ jupe_add(struct Client *cptr, struct Client *sptr, char *server, char *reason,
    */
   if (expire <= 0 || expire > JUPE_MAX_EXPIRE) {
     if (!IsServer(cptr) && MyConnect(cptr))
-      sendto_one(cptr, err_str(ERR_BADEXPIRE), me.name, cptr->name, expire);
+      send_error_to_client(cptr, ERR_BADEXPIRE, expire);
     return 0;
   }
 
@@ -283,10 +276,10 @@ jupe_burst(struct Client *cptr)
     if (jupe->ju_expire <= TStime()) /* expire any that need expiring */
       jupe_free(jupe);
     else if (!JupeIsLocal(jupe)) /* forward global jupes */
-      sendto_one(cptr, "%s " TOK_JUPE " * %c%s "TIME_T_FMT" "TIME_T_FMT" :%s",
-                NumServ(&me), JupeIsActive(jupe) ? '+' : '-',
-                jupe->ju_server, jupe->ju_expire - TStime(),
-                jupe->ju_lastmod, jupe->ju_reason);
+      sendcmdto_one(cptr, CMD_JUPE, &me, "* %c%s %Tu %Tu :%s",
+                   JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
+                   jupe->ju_expire - TStime(), jupe->ju_lastmod,
+                   jupe->ju_reason);
   }
 }
 
@@ -296,9 +289,9 @@ jupe_resend(struct Client *cptr, struct Jupe *jupe)
   if (JupeIsLocal(jupe)) /* don't propagate local jupes */
     return 0;
 
-  sendto_one(cptr, "%s " TOK_JUPE " * %c%s " TIME_T_FMT " " TIME_T_FMT " :%s",
-            NumServ(&me), JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
-            jupe->ju_expire - TStime(), jupe->ju_lastmod, jupe->ju_reason);
+  sendcmdto_one(cptr, CMD_JUPE, &me, "* %c%s %Tu %Tu :%s",
+               JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
+               jupe->ju_expire - TStime(), jupe->ju_lastmod, jupe->ju_reason);
 
   return 0;
 }
@@ -310,10 +303,8 @@ jupe_list(struct Client *sptr, char *server)
   struct Jupe *sjupe;
 
   if (server) {
-    if (!(jupe = jupe_find(server))) { /* no such jupe */
-      sendto_one(sptr, err_str(ERR_NOSUCHJUPE), me.name, sptr->name, server);
-      return 0;
-    }
+    if (!(jupe = jupe_find(server))) /* no such jupe */
+      return send_error_to_client(sptr, ERR_NOSUCHJUPE, server);
 
     /* send jupe information along */
     sendto_one(sptr, rpl_str(RPL_JUPELIST), me.name, sptr->name,
index 1fa1621808d1682392fc541b701f2e7c24ca5bb7..40eaf2f77c8fdcc8a20e0b1666dd5f1cea54bdb4 100644 (file)
@@ -150,16 +150,12 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       return 0; /* no such server */
 
     if (!IsMe(acptr)) { /* manually propagate */
-      if (IsServer(sptr)) {
-       if (!lastmod)
-         sendto_one(acptr, "%s " TOK_GLINE " %s %s %s :%s", NumServ(sptr),
-                    target, mask, parv[3], reason);
-       else
-         sendto_one(acptr, "%s " TOK_GLINE " %s %s %s %s :%s", NumServ(sptr),
-                    target, mask, parv[3], parv[4], reason);
-      } else
-       sendto_one(acptr, "%s%s " TOK_GLINE " %s %s %s %s :%s", NumNick(sptr),
-                  target, mask, parv[3], parv[4], reason);
+      if (!lastmod)
+       sendcmdto_one(acptr, CMD_GLINE, sptr, "%s %s %s :%s", target, mask,
+                     parv[3], reason);
+      else
+       sendcmdto_one(acptr, CMD_GLINE, sptr, "%s %s %s %s :%s", target, mask,
+                     parv[3], parv[4], reason);
 
       return 0;
     }
@@ -254,29 +250,22 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
   if (target) {
     if (!(target[0] == '*' && target[1] == '\0')) {
-      if (!(acptr = find_match_server(target))) {
-       send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
-       return 0;
-      }
+      if (!(acptr = find_match_server(target)))
+       return send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
 
       if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
-       if (!IsOper(sptr)) {
-         send_error_to_client(sptr, ERR_NOPRIVILEGES);
-         return 0;
-       }
+       if (!IsOper(sptr))
+         return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
-       sendto_one(acptr, "%s%s " TOK_GLINE " %s %c%s %s " TIME_T_FMT " :%s",
-                  NumNick(sptr), NumServ(acptr),
-                  flags & GLINE_ACTIVE ? '?' : '-', mask, parv[3], TStime(),
-                  reason);
+       sendcmdto_one(acptr, CMD_GLINE, sptr, "%s %c%s %s %Tu :%s", target,
+                     flags & GLINE_ACTIVE ? '?' : '-', mask, parv[3],
+                     TStime(), reason);
        return 0;
       }
 
       flags |= GLINE_LOCAL;
-    } else if (!IsOper(sptr)) {
-      send_error_to_client(sptr, ERR_NOPRIVILEGES);
-      return 0;
-    }
+    } else if (!IsOper(sptr))
+      return send_error_to_client(sptr, ERR_NOPRIVILEGES);
   }
 
 #ifndef CONFIG_OPERCMDS
index 6541d046cc9ce867442bfb532fed53360a213227..fb606d9dc6317f35204a1852c871485d48573b43 100644 (file)
@@ -137,13 +137,8 @@ int ms_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       return 0; /* no such server */
 
     if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
-      if (IsServer(sptr))
-       sendto_one(acptr, "%s " TOK_JUPE " %s %s %s %s :%s", NumServ(sptr),
-                  target, server, parv[3], parv[4], reason);
-      else
-       sendto_one(acptr, "%s%s " TOK_JUPE " %s %s %s %s :%s", NumNick(sptr),
-                  target, server, parv[3], parv[4], reason);
-
+      sendcmdto_one(acptr, CMD_JUPE, sptr, "%s %s %s %s :%s", target, server,
+                   parv[3], parv[4], reason);
       return 0;
     }
 
@@ -219,28 +214,21 @@ int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     return need_more_params(sptr, "JUPE");
 
   if (!(target[0] == '*' && target[1] == '\0')) {
-    if (!(acptr = find_match_server(target))) {
-      sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], target);
-      return 0;
-    }
+    if (!(acptr = find_match_server(target)))
+      return send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
 
     if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
-      if (!IsOper(sptr)) {
-       sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
-       return 0;
-      }
+      if (!IsOper(sptr))
+       return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
-      sendto_one(acptr, "%s%s " TOK_JUPE " %s %c%s %s " TIME_T_FMT " :%s",
-                NumNick(sptr), NumServ(acptr), active ? '+' : '-', server,
-                parv[3], TStime(), reason);
+      sendcmdto_one(acptr, CMD_JUPE, sptr, "%C %c%s %s %Tu :%s", acptr,
+                   active ? '+' : '-', server, parv[3], TStime(), reason);
       return 0;
     }
 
     local = 1;
-  } else if (!IsOper(sptr)) {
-    sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
-    return 0;
-  }
+  } else if (!IsOper(sptr))
+    return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
   expire_off = atoi(parv[3]);
 
index 39bb074375004b2f98bf7f1a1c421b24968ea570..3a55fd06ad6b9b78a69527348310ed31886c4519 100644 (file)
@@ -381,6 +381,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
   struct User*     user = sptr->user;
   char             ip_base64[8];
   char             featurebuf[512];
+  struct Gline*    gline;
 
   user->last = CurrentTime;
   parv[0] = sptr->name;
@@ -545,6 +546,8 @@ int register_user(struct Client *cptr, struct Client *sptr,
   else {
     ircd_strncpy(user->username, username, USERLEN);
     Count_newremoteclient(UserStats, user->server);
+    if ((gline = gline_lookup(sptr)) && GlineIsActive(gline))
+      gline_resend(cptr, gline);
   }
   SetUser(sptr);
 
@@ -690,7 +693,6 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
   if (IsServer(sptr)) {
     int   i;
     const char* p;
-    struct Gline *gline;
 
     /*
      * A server introducing a new client, change source
@@ -729,8 +731,6 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
     ircd_strncpy(new_client->username, parv[4], USERLEN);
     ircd_strncpy(new_client->user->host, parv[5], HOSTLEN);
     ircd_strncpy(new_client->info, parv[parc - 1], REALLEN);
-    if ((gline = gline_lookup(new_client)) && GlineIsActive(gline))
-      gline_resend(cptr, gline);
     return register_user(cptr, new_client, new_client->name, parv[4]);
   }
   else if (sptr->name[0]) {
index aaf952f3cb0774e94c2d818e50e3ad1113f4dbc0..5bdd1048c58e010a078fbf4a9a104478489e76a4 100644 (file)
@@ -24,6 +24,7 @@
 #include "class.h"
 #include "client.h"
 #include "ircd.h"
+#include "ircd_snprintf.h"
 #include "ircd_string.h"
 #include "list.h"
 #include "match.h"
@@ -190,6 +191,40 @@ void vsendto_one(struct Client *to, const char* pattern, va_list vl)
   sendbufto_one(to);
 }
 
+/*
+ * Send a (prefixed) command to a single client; select which of <cmd>
+ * <tok> to use depending on if to is a server or not.  <from> is the
+ * originator of the command.
+ */
+void sendcmdto_one(struct Client *to, const char *cmd, const char *tok,
+                  struct Client *from, const char *pattern, ...)
+{
+  va_list vl;
+
+  va_start(vl, pattern);
+  vsendcmdto_one(to, cmd, tok, from, pattern, vl);
+  va_end(vl);
+}
+
+void vsendcmdto_one(struct Client *to, const char *cmd, const char *tok,
+                   struct Client *from, const char *pattern, va_list vl)
+{
+  struct VarData vd;
+  char sndbuf[IRC_BUFSIZE];
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  vd.vd_args = vl;
+
+  if (MyUser(to)) /* :nick!user@host form; use cmd */
+    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v",
+                 from->name, from->user->username, from->user->host,
+                 cmd, &vd);
+  else /* numeric form; use tok */
+    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
+
+  send_buffer(to, sndbuf);
+}
+
 #ifdef GODMODE
 static void send_to_god(struct Client* to, const char* buf)
 {
@@ -561,6 +596,33 @@ void sendto_serv_butone(struct Client *one, const char* pattern, ...)
 
 }
 
+void sendcmdto_serv_butone(struct Client *one, const char *cmd,
+                          const char *tok, struct Client *from,
+                          const char *pattern, ...)
+{
+  struct VarData vd;
+  va_list vl;
+  char sndbuf[IRC_BUFSIZE];
+  struct DLink *lp;
+
+  cmd = 0; /* try to suppress compile warning */
+
+  va_start(vl, pattern);
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  vd.vd_args = vl;
+
+  /* use token */
+  ircd_snprintf(&me, sndbuf, sizeof(sndbuf) - 2, "%C %s %v", from, tok, &vd);
+  va_end(vl);
+
+  /* send it to our downlinks */
+  for (lp = me.serv->down; lp; lp = lp->next) {
+    if (one && lp->value.cptr == one->from)
+      continue;
+    send_buffer(lp->value.cptr, sndbuf);
+  }
+}
+
 /*
  * sendbufto_serv_butone()
  *