+2000-04-26 Kevin L. Mitchell <klmitch@mit.edu>
+
+ * ircd/s_serv.c (exit_new_server): rewrite exit_new_server to be a
+ little less brain-dead
+
+ * ircd/s_misc.c: use sendcmdto_one, sendrawto_one, and send_reply
+
+ * ircd/s_debug.c: use send_reply with RPL_EXPLICIT for
+ RPL_STATSDEBUG
+
+ * ircd/res.c (cres_mem): use send_reply with RPL_EXPLICIT for
+ RPL_STATSDEBUG
+
+ * ircd/list.c (send_listinfo): use send_reply with RPL_EXPLICIT
+ for RPL_STATSDEBUG
+
+ * ircd/m_pong.c: use RPL_EXPLICIT for ERR_BADPING
+
+ * ircd/ircd.c: use RPL_EXPLICIT for ERR_BADPING
+
+ * ircd/s_user.c (register_user): use RPL_EXPLICIT for
+ ERR_INVALIDUSERNAME
+
+ * ircd/ircd_reply.c (send_reply): support RPL_EXPLICIT
+
+ * include/ircd_reply.h (RPL_EXPLICIT): somewhat of a hack to mark
+ a numeric as needing to use an explicit pattern, which will be the
+ first argument in the variable argument list
+
+ * ircd/s_user.c: use sendrawto_one instead of sendto_one to send
+ non-prefixed nospoof PING
+
+ * ircd/s_bsd.c: use sendrawto_one instead of sendto_one to send
+ non-prefixed SERVER login
+
+ * ircd/ircd.c (check_pings): fix last sendto_one calls (except for
+ a numeric usage further up)
+
+ * include/send.h: declare sendrawto_one
+
+ * ircd/send.c (sendrawto_one): new function to use ONLY for
+ non-prefixed commands, like PING to client, or PASS/SERVER on
+ server registration
+
2000-04-25 Kevin L. Mitchell <klmitch@mit.edu>
* ircd/ircd_snprintf.c (doprintf): implement %H for possible
#
# ChangeLog for ircu2.10.11
#
-# $Id: ChangeLog,v 1.102 2000-04-25 20:33:50 kev Exp $
+# $Id: ChangeLog,v 1.103 2000-04-26 20:14:56 kev Exp $
#
# Insert new changes at beginning of the change list.
#
extern int send_reply(struct Client *to, int reply, ...);
extern int send_admin_info(struct Client* sptr, const struct ConfItem* data);
+#define RPL_EXPLICIT 0x40000000 /* first arg is a pattern to use */
+
#endif /* INCLUDED_ircd_reply_h */
#define IRC_BUFSIZE 512
+/* Send a raw message to one client; USE ONLY IF YOU MUST SEND SOMETHING
+ * WITHOUT A PREFIX!
+ */
+extern void sendrawto_one(struct Client *to, const char *pattern, ...);
+
/* Send a command to one client */
extern void sendcmdto_one(struct Client *from, const char *cmd,
const char *tok, struct Client *to,
#include "hash.h"
#include "ircd_alloc.h" /* set_nomem_handler */
#include "ircd_log.h"
+#include "ircd_reply.h"
#include "ircd_signal.h"
#include "ircd_string.h"
#include "jupe.h"
* nospoof PONG.
*/
if (*cptr->name && cptr->user && *cptr->user->username) {
- /* XXX sendto_one used to send numeric XXX */
- sendto_one(cptr,
- ":%s %d %s :Your client may not be compatible with this server.",
- me.name, ERR_BADPING, cptr->name);
- sendto_one(cptr,
- ":%s %d %s :Compatible clients are available at "
- "ftp://ftp.undernet.org/pub/irc/clients",
- me.name, ERR_BADPING, cptr->name);
+ send_reply(cptr, RPL_EXPLICIT | ERR_BADPING,
+ ":Your client may not be compatible with this server.");
+ send_reply(cptr, RPL_EXPLICIT | ERR_BADPING,
+ ":Compatible clients are available at "
+ "ftp://ftp.undernet.org/pub/irc/clients");
}
exit_client_msg(cptr,cptr,&me, "Ping Timeout");
continue;
*/
cptr->lasttime = CurrentTime - max_ping;
- /* XXX sendto_one sending PING; must be very careful XXX */
if (IsUser(cptr))
- sendto_one(cptr, MSG_PING " :%s", me.name);
+ sendrawto_one(cptr, MSG_PING " :%s", me.name);
else
- sendto_one(cptr, "%s " TOK_PING " :%s", NumServ(&me), me.name);
+ sendcmdto_one(&me, CMD_PING, cptr, ":%s", me.name);
} /* of if not ping sent... */
expire=cptr->lasttime+max_ping*2;
assert(0 != to);
assert(0 != reply);
- num = get_error_numeric(reply); /* get information about reply... */
+ num = get_error_numeric(reply & ~RPL_EXPLICIT); /* get reply... */
- vd.vd_format = num->format; /* select format... */
-
- /* build buffer */
va_start(vd.vd_args, reply);
- if (MyUser(to))
- ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %C %v", me.name,
- num->str, to, &vd);
+
+ if (reply & RPL_EXPLICIT) /* get right pattern */
+ vd.vd_format = (const char *) va_arg(vd.vd_args, char *);
else
- ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %C %v", &me, num->str,
- to, &vd);
+ vd.vd_format = num->format;
+
+ assert(0 != vd.vd_format);
+
+ /* build buffer */
+ ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %C %v", &me, num->str,
+ to, &vd);
+
va_end(vd.vd_args);
/* send it to the user */
* $Id$
*/
#include "client.h"
+#include "channel.h"
#include "ircd_snprintf.h"
#include "struct.h"
#include "client.h"
#include "ircd.h"
#include "ircd_alloc.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "listener.h"
#include "match.h"
}
#ifdef DEBUGMODE
-/* XXX uses sendto_one to send a RPL_STATSDEBUG -- no string for rpl */
void send_listinfo(struct Client *cptr, char *name)
{
int inuse = 0, mem = 0, tmp = 0;
- sendto_one(cptr, ":%s %d %s :Local: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name, inuse += cloc.inuse,
- tmp = cloc.inuse * CLIENT_LOCAL_SIZE);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Local: inuse: %d(%d)",
+ inuse += cloc.inuse, tmp = cloc.inuse * CLIENT_LOCAL_SIZE);
mem += tmp;
- sendto_one(cptr, ":%s %d %s :Remote: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name,
- crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Remote: inuse: %d(%d)",
+ crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE);
mem += tmp;
inuse += crem.inuse;
- sendto_one(cptr, ":%s %d %s :Users: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name, users.inuse,
- tmp = users.inuse * sizeof(struct User));
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Users: inuse: %d(%d)",
+ users.inuse, tmp = users.inuse * sizeof(struct User));
mem += tmp;
- inuse += users.inuse,
- sendto_one(cptr, ":%s %d %s :Servs: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name, servs.inuse,
- tmp = servs.inuse * sizeof(struct Server));
+ inuse += users.inuse;
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Servs: inuse: %d(%d)",
+ servs.inuse, tmp = servs.inuse * sizeof(struct Server));
mem += tmp;
- inuse += servs.inuse,
- sendto_one(cptr, ":%s %d %s :Links: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name, links.inuse,
- tmp = links.inuse * sizeof(struct SLink));
+ inuse += servs.inuse;
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Links: inuse: %d(%d)",
+ links.inuse, tmp = links.inuse * sizeof(struct SLink));
mem += tmp;
- inuse += links.inuse,
- sendto_one(cptr, ":%s %d %s :Classes: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name, classs.inuse,
- tmp = classs.inuse * sizeof(struct ConfClass));
+ inuse += links.inuse;
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Classes: inuse: %d(%d)",
+ classs.inuse, tmp = classs.inuse * sizeof(struct ConfClass));
mem += tmp;
- inuse += classs.inuse,
- sendto_one(cptr, ":%s %d %s :Confs: inuse: %d(%d)",
- me.name, RPL_STATSDEBUG, name, GlobalConfCount,
- tmp = GlobalConfCount * sizeof(struct ConfItem));
+ inuse += classs.inuse;
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Confs: inuse: %d(%d)",
+ GlobalConfCount, tmp = GlobalConfCount * sizeof(struct ConfItem));
mem += tmp;
- inuse += GlobalConfCount,
- sendto_one(cptr, ":%s %d %s :Totals: inuse %d %d",
- me.name, RPL_STATSDEBUG, name, inuse, mem);
+ inuse += GlobalConfCount;
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Totals: inuse %d %d",
+ inuse, mem);
}
#endif
#include "client.h"
#include "hash.h"
#include "ircd.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "msg.h"
#include "numeric.h"
if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name)) {
struct Client* acptr;
if ((acptr = FindClient(destination))) {
- if (MyUser(acptr))
- sendto_one(acptr, ":%s PONG %s %s", sptr->name, origin, destination);
- else
- sendto_one(acptr, "%s " TOK_PONG " %s %s", NumServ(sptr), origin, destination);
+ sendcmdto_one(sptr, CMD_PONG, acptr, "%s %s", origin, destination);
}
}
return 0;
return register_user(cptr, sptr, sptr->name, sptr->user->username);
}
else
- sendto_one(sptr, ":%s %d %s :To connect, type /QUOTE PONG %u",
- me.name, ERR_BADPING, (sptr->name) ? sptr->name : "*",
- sptr->cookie);
+ send_reply(sptr, RPL_EXPLICIT | ERR_BADPING,
+ ":To connect, type /QUOTE PONG %u", sptr->cookie);
}
return 0;
}
#include "ircd_alloc.h"
#include "ircd_log.h"
#include "ircd_osdep.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "msg.h"
#include "numeric.h"
request_mem += MAXGETHOSTLEN + 1;
++request_count;
}
- /* XXX sendto_one used to send STATSDEBUG */
+
if (cachedCount != cache_count) {
- sendto_one(sptr,
- ":%s %d %s :Resolver: cache count mismatch: %d != %d",
- me.name, RPL_STATSDEBUG, sptr->name, cachedCount, cache_count);
+ send_reply(sptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Resolver: cache count mismatch: %d != %d", cachedCount,
+ cache_count);
assert(cachedCount == cache_count);
}
- sendto_one(sptr, ":%s %d %s :Resolver: cache %d(%d) requests %d(%d)",
- me.name, RPL_STATSDEBUG, sptr->name, cache_count, cache_mem,
- request_count, request_mem);
+ send_reply(sptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Resolver: cache %d(%d) requests %d(%d)", cache_count,
+ cache_mem, request_count, request_mem);
return cache_mem + request_mem;
}
sendto_opmask_butone(0, SNO_OLDSNO, "Lost Server Line for %s", cptr->name);
return 0;
}
- /* XXX sendto_one sending without a prefix; be careful! */
+
if (!EmptyString(aconf->passwd))
- sendto_one(cptr, "PASS :%s", aconf->passwd);
+ sendrawto_one(cptr, MSG_PASS " :%s", aconf->passwd);
#if 0
/* dead code, already done in connect_server */
*/
cptr->lasttime = CurrentTime;
cptr->flags |= FLAGS_PINGSENT;
- /* XXX sendto_one sending without a prefix; be careful! */
- sendto_one(cptr, "SERVER %s 1 " TIME_T_FMT " " TIME_T_FMT " J%s %s%s :%s",
- me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL,
- NumServCap(&me), me.info);
+
+ sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s",
+ me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL,
+ NumServCap(&me), me.info);
return (IsDead(cptr)) ? 0 : 1;
}
#include "hash.h"
#include "ircd_alloc.h"
#include "ircd_osdep.h"
+#include "ircd_reply.h"
#include "ircd.h"
#include "list.h"
#include "numeric.h"
static void debug_enumerator(struct Client* cptr, const char* msg)
{
assert(0 != cptr);
- sendto_one(cptr, ":%s %d %s :%s", me.name, RPL_STATSDEBUG, cptr->name, msg);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":%s", msg);
}
/*
{
os_get_rusage(cptr, CurrentTime - me.since, debug_enumerator);
- sendto_one(cptr, ":%s %d %s :DBUF alloc %d used %d",
- me.name, RPL_STATSDEBUG, nick, DBufAllocCount, DBufUsedCount);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":DBUF alloc %d used %d",
+ DBufAllocCount, DBufUsedCount);
}
#endif /* DEBUGMODE */
for (cltmp = classes; cltmp; cltmp = cltmp->next)
cl++;
- sendto_one(cptr, ":%s %d %s :Client Local %d(" SIZE_T_FMT
- ") Remote %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, lc, lcm, rc, rcm);
- sendto_one(cptr, ":%s %d %s :Users %d(" SIZE_T_FMT
- ") Invites %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, us, us * sizeof(struct User), usi,
- usi * sizeof(struct SLink));
- sendto_one(cptr,
- ":%s %d %s :User channels %d(" SIZE_T_FMT ") Aways %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, memberships,
- memberships * sizeof(struct Membership), aw, awm);
- sendto_one(cptr, ":%s %d %s :Attached confs %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, lcc, lcc * sizeof(struct SLink));
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Client Local %d(%zu) Remote %d(%zu)", lc, lcm, rc, rcm);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Users %d(%zu) Invites %d(%zu)", us, us * sizeof(struct User),
+ usi, usi * sizeof(struct SLink));
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":User channels %d(%zu) Aways %d(%zu)", memberships,
+ memberships * sizeof(struct Membership), aw, awm);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Attached confs %d(%zu)",
+ lcc, lcc * sizeof(struct SLink));
totcl = lcm + rcm + us * sizeof(struct User) + memberships * sizeof(struct Membership) + awm;
totcl += lcc * sizeof(struct SLink) + usi * sizeof(struct SLink);
- sendto_one(cptr, ":%s %d %s :Conflines %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, co, com);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Conflines %d(%zu)", co,
+ com);
- sendto_one(cptr, ":%s %d %s :Classes %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, cl, cl * sizeof(struct ConfClass));
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Classes %d(%zu)", cl,
+ cl * sizeof(struct ConfClass));
- sendto_one(cptr, ":%s %d %s :Channels %d(" SIZE_T_FMT
- ") Bans %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, ch, chm, chb, chbm);
- sendto_one(cptr, ":%s %d %s :Channel membrs %d(" SIZE_T_FMT ") invite %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, memberships, memberships * sizeof(struct Membership),
- chi, chi * sizeof(struct SLink));
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Channels %d(%zu) Bans %d(%zu)", ch, chm, chb, chbm);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Channel membrs %d(%zu) invite %d(%zu)", memberships,
+ memberships * sizeof(struct Membership), chi,
+ chi * sizeof(struct SLink));
totch = chm + chbm + chi * sizeof(struct SLink);
- sendto_one(cptr, ":%s %d %s :Whowas users %d(" SIZE_T_FMT
- ") away %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, wwu, wwu * sizeof(struct User), wwa, wwam);
- sendto_one(cptr, ":%s %d %s :Whowas array %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, NICKNAMEHISTORYLENGTH, wwm);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Whowas users %d(%zu) away %d(%zu)", wwu,
+ wwu * sizeof(struct User), wwa, wwam);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Whowas array %d(%zu)",
+ NICKNAMEHISTORYLENGTH, wwm);
totww = wwu * sizeof(struct User) + wwam + wwm;
- sendto_one(cptr, ":%s %d %s :Hash: client %d(" SIZE_T_FMT
- "), chan is the same",
- me.name, RPL_STATSDEBUG, nick, HASHSIZE, sizeof(void *) * HASHSIZE);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Hash: client %d(%zu), chan is the same", HASHSIZE,
+ sizeof(void *) * HASHSIZE);
/*
* NOTE: this count will be accurate only for the exact instant that this
* are sent.
*/
dbuf_count_memory(&dbufs_allocated, &dbufs_used);
- sendto_one(cptr,
- ":%s %d %s :DBufs allocated %d(" SIZE_T_FMT ") used %d(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, DBufAllocCount, dbufs_allocated,
- DBufUsedCount, dbufs_used);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":DBufs allocated %d(%zu) used %d(%zu)", DBufAllocCount,
+ dbufs_allocated, DBufUsedCount, dbufs_used);
rm = cres_mem(cptr);
tot += sizeof(void *) * HASHSIZE * 3;
#if !defined(NDEBUG)
- sendto_one(cptr, ":%s %d %s :Allocations: " SIZE_T_FMT "(" SIZE_T_FMT ")",
- me.name, RPL_STATSDEBUG, nick, fda_get_block_count(),
- fda_get_byte_count());
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Allocations: %zu(%zu)",
+ fda_get_block_count(), fda_get_byte_count());
#endif
- sendto_one(cptr, ":%s %d %s :Total: ww " SIZE_T_FMT " ch " SIZE_T_FMT
- " cl " SIZE_T_FMT " co " SIZE_T_FMT " db " SIZE_T_FMT,
- me.name, RPL_STATSDEBUG, nick, totww, totch, totcl, com, dbufs_allocated);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":Total: ww %zu ch %zu cl %zu co %zu db %zu", totww, totch,
+ totcl, com, dbufs_allocated);
}
/* 248 */
{ RPL_STATSULINE, "%c %s %s %s %d %d", "248" },
/* 249 */
- { 0 },
+ { RPL_STATSDEBUG, 0, "249" },
/* 250 */
{ RPL_STATSCONN, ":Highest connection count: %d (%d clients)", "250" },
/* 251 */
/* 467 */
{ ERR_KEYSET, "%s :Channel key already set", "467" },
/* 468 */
- { ERR_INVALIDUSERNAME, "", "468" },
+ { ERR_INVALIDUSERNAME, 0, "468" },
/* 469 */
{ 0 },
/* 470 */
/* 512 */
{ ERR_NOSUCHGLINE, "%s :No such gline", "512" },
/* 513 */
- { ERR_BADPING, "", "513" },
+ { ERR_BADPING, 0, "513" },
/* 514 */
{ ERR_NOSUCHJUPE, "%s :No such jupe", "514" },
/* 515 */
#include "ircd.h"
#include "ircd_alloc.h"
#include "ircd_log.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "list.h"
#include "match.h"
* that the client can show the "**signoff" message).
* (Note: The notice is to the local clients *only*)
*/
- sendto_common_channels(bcptr, ":%s QUIT :%s", bcptr->name, comment);
+ sendcmdto_common_channels(bcptr, CMD_QUIT, ":%s", comment);
remove_user_from_all_channels(bcptr);
}
else if (IsMe(bcptr))
{
- sendto_ops("ERROR: tried to exit me! : %s", comment);
+ sendto_opmask_butone(0, SNO_OLDSNO, "ERROR: tried to exit me! : %s",
+ comment);
return; /* ...must *never* exit self! */
}
else if (IsUnknown(bcptr) || IsConnecting(bcptr) || IsHandshake(bcptr))
#ifdef ALLOW_SNO_CONNEXIT
#ifdef SNO_CONNEXIT_IP
if (IsUser(victim)) {
- sprintf_irc(sendbuf,
- ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s] [%s]",
- me.name, victim->name, victim->user->username, victim->user->host,
- comment, ircd_ntoa((const char*) &victim->ip));
- sendbufto_op_mask(SNO_CONNEXIT);
+ sendto_opmask_butone(0, SNO_CONNEXIT,
+ "Client exiting: %s (%s@%s) [%s] [%s]",
+ victim->name, victim->user->username,
+ victim->user->host, comment,
+ ircd_ntoa((const char *)&victim->ip));
}
#else /* SNO_CONNEXIT_IP */
if (IsUser(victim)) {
- sprintf_irc(sendbuf,
- ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s]",
- me.name, victim->name, victim->user->username, victim->user->host,
- comment);
- sendbufto_op_mask(SNO_CONNEXIT);
+ sendto_opmask_butone(0, SNO_CONNEXIT, "Client exiting: %s (%s@%s) [%s]",
+ victim->name, victim->user->username,
+ victim->user->host, comment);
}
#endif /* SNO_CONNEXIT_IP */
#endif /* ALLOW_SNO_CONNEXIT */
&& IsClient(victim)) /* Not a Ping struct or Log file */
{
if (IsServer(victim) || IsHandshake(victim))
- sendto_one(victim, ":%s " TOK_SQUIT " %s 0 :%s", killer->name, me.name, comment);
+ sendcmdto_one(killer, CMD_SQUIT, victim, "%C 0 :%s", &me, comment);
else if (!IsConnecting(victim)) {
if (!IsDead(victim))
- sendto_one(victim, "ERROR :Closing Link: %s by %s (%s)",
- victim->name, killer->name, comment);
+ sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)",
+ victim->name, killer->name, comment);
}
if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) &&
(killer == &me || (IsServer(killer) &&
if (victim->serv->user && *victim->serv->by &&
(acptr = findNUser(victim->serv->by))) {
if (acptr->user == victim->serv->user) {
- if (MyUser(acptr) || Protocol(acptr->from) < 10)
- sendto_one(acptr,
- ":%s NOTICE %s :Link with %s cancelled: %s",
- me.name, acptr->name, victim->name, comment);
- else
- sendto_one(acptr,
- "%s NOTICE %s%s :Link with %s cancelled: %s",
- NumServ(&me), NumNick(acptr), victim->name, comment);
+ sendcmdto_one(&me, CMD_NOTICE, acptr,
+ "%C :Link with %s cancelled: %s", acptr,
+ victim->name, comment);
}
else {
/*
}
}
if (killer == &me)
- sendto_lops_butone(acptr, "Link with %s cancelled: %s",
- victim->name, comment);
+ sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s cancelled: %s",
+ victim->name, comment);
}
}
/*
strcat(comment1, " ");
strcat(comment1, victim->name);
if (IsUser(killer))
- sendto_lops_butone(killer, "%s SQUIT by %s [%s]:",
- (killer->user->server == victim ||
- killer->user->server == victim->serv->up) ? "Local" : "Remote",
- get_client_name(killer, HIDE_IP), killer->user->server->name);
+ sendto_opmask_butone(killer, SNO_OLDSNO, "%s SQUIT by %s [%s]:",
+ (killer->user->server == victim ||
+ killer->user->server == victim->serv->up) ?
+ "Local" : "Remote",
+ get_client_name(killer, HIDE_IP),
+ killer->user->server->name);
else if (killer != &me && victim->serv->up != killer)
- sendto_ops("Received SQUIT %s from %s :", victim->name,
- IsServer(killer) ? killer->name : get_client_name(killer, HIDE_IP));
- sendto_op_mask(SNO_NETWORK, "Net break: %s (%s)", comment1, comment);
+ sendto_opmask_butone(0, SNO_OLDSNO, "Received SQUIT %s from %s :",
+ victim->name, IsServer(killer) ? killer->name :
+ get_client_name(killer, HIDE_IP));
+ sendto_opmask_butone(0, SNO_NETWORK, "Net break: %s (%s)", comment1,
+ comment);
}
/*
for (dlp = me.serv->down; dlp; dlp = dlp->next) {
if (dlp->value.cptr != killer->from && dlp->value.cptr != victim) {
if (IsServer(victim))
- sendto_one(dlp->value.cptr, ":%s " TOK_SQUIT " %s " TIME_T_FMT " :%s",
- killer->name, victim->name, victim->serv->timestamp, comment);
+ sendcmdto_one(killer, CMD_SQUIT, dlp->value.cptr, "%C %Tu :%s",
+ victim, victim->serv->timestamp, comment);
else if (IsUser(victim) && 0 == (victim->flags & FLAGS_KILLED))
- sendto_one(dlp->value.cptr, "%s%s " TOK_QUIT " :%s", NumNick(victim), comment);
+ sendcmdto_one(victim, CMD_QUIT, dlp->value.cptr, ":%s", comment);
}
}
/* Then remove the client structures */
sp->is_ni++;
}
- sendto_one(cptr, ":%s %d %s :accepts %u refused %u",
- me.name, RPL_STATSDEBUG, name, sp->is_ac, sp->is_ref);
- sendto_one(cptr, ":%s %d %s :unknown commands %u prefixes %u",
- me.name, RPL_STATSDEBUG, name, sp->is_unco, sp->is_unpf);
- sendto_one(cptr, ":%s %d %s :nick collisions %u unknown closes %u",
- me.name, RPL_STATSDEBUG, name, sp->is_kill, sp->is_ni);
- sendto_one(cptr, ":%s %d %s :wrong direction %u empty %u",
- me.name, RPL_STATSDEBUG, name, sp->is_wrdi, sp->is_empt);
- sendto_one(cptr, ":%s %d %s :numerics seen %u mode fakes %u",
- me.name, RPL_STATSDEBUG, name, sp->is_num, sp->is_fake);
- sendto_one(cptr, ":%s %d %s :auth successes %u fails %u",
- me.name, RPL_STATSDEBUG, name, sp->is_asuc, sp->is_abad);
- sendto_one(cptr, ":%s %d %s :local connections %u",
- me.name, RPL_STATSDEBUG, name, sp->is_loc);
- sendto_one(cptr, ":%s %d %s :Client Server", me.name, RPL_STATSDEBUG, name);
- sendto_one(cptr, ":%s %d %s :connected %u %u",
- me.name, RPL_STATSDEBUG, name, sp->is_cl, sp->is_sv);
- sendto_one(cptr, ":%s %d %s :bytes sent %u.%uK %u.%uK",
- me.name, RPL_STATSDEBUG, name,
- sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs);
- sendto_one(cptr, ":%s %d %s :bytes recv %u.%uK %u.%uK",
- me.name, RPL_STATSDEBUG, name,
- sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr);
- sendto_one(cptr, ":%s %d %s :time connected " TIME_T_FMT " " TIME_T_FMT,
- me.name, RPL_STATSDEBUG, name, sp->is_cti, sp->is_sti);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":accepts %u refused %u",
+ sp->is_ac, sp->is_ref);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":unknown commands %u prefixes %u", sp->is_unco, sp->is_unpf);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":nick collisions %u unknown closes %u", sp->is_kill, sp->is_ni);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":wrong direction %u empty %u", sp->is_wrdi, sp->is_empt);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":numerics seen %u mode fakes %u", sp->is_num, sp->is_fake);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+ ":auth successes %u fails %u", sp->is_asuc, sp->is_abad);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":local connections %u",
+ sp->is_loc);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Client server");
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":connected %u %u",
+ sp->is_cl, sp->is_sv);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":bytes sent %u.%uK %u.%uK",
+ sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":bytes recv %u.%uK %u.%uK",
+ sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr);
+ send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":time connected %Tu %Tu",
+ sp->is_cti, sp->is_sti);
}
#include "ircd_alloc.h"
#include "ircd_reply.h"
#include "ircd_string.h"
+#include "ircd_snprintf.h"
#include "ircd_xopen.h"
#include "jupe.h"
#include "list.h"
unsigned int max_connection_count = 0;
unsigned int max_client_count = 0;
-
+#if 0
int exit_new_server(struct Client* cptr, struct Client* sptr,
const char* host, time_t timestamp, const char* fmt, ...)
{
MyFree(buf);
return 0;
}
+#endif /* 0 */
+
+int exit_new_server(struct Client *cptr, struct Client *sptr, const char *host,
+ time_t timestamp, const char *pattern, ...)
+{
+ struct VarData vd;
+ int retval = 0;
+
+ vd.vd_format = pattern;
+ va_start(vd.vd_args, pattern);
+
+ if (!IsServer(sptr))
+ retval = vexit_client_msg(cptr, cptr, &me, pattern, vd.vd_args);
+ else
+ sendcmdto_one(&me, CMD_SQUIT, cptr, "%s %Tu :%v", host, timestamp, &vd);
+
+ va_end(vd.vd_args);
+
+ return retval;
+}
int a_kills_b_too(struct Client *a, struct Client *b)
{
if (IsUnknown(cptr)) {
if (aconf->passwd[0])
- sendto_one(cptr, "PASS :%s", aconf->passwd);
+ sendrawto_one(cptr, MSG_PASS " :%s", aconf->passwd);
/*
* Pass my info to the new server
*/
- sendto_one(cptr, "SERVER %s 1 " TIME_T_FMT " " TIME_T_FMT " J%s %s%s :%s",
- me.name, me.serv->timestamp, cptr->serv->timestamp,
- MAJOR_PROTOCOL, NumServCap(&me),
- (me.info[0]) ? (me.info) : "IRCers United");
+ sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s", me.name,
+ me.serv->timestamp, cptr->serv->timestamp, MAJOR_PROTOCOL,
+ NumServCap(&me), *me.info ? me.info : "IRCers United");
/*
* Don't charge this IP# for connecting
* XXX - if this comes from a server port, it will not have been added
strcmp(sptr->username, username) != 0))
{
ServerStats->is_ref++;
- /* XXX sendto_one used with ERR_INVALIDUSERNAME--explanations */
- sendto_one(cptr, ":%s %d %s :Your username is invalid.",
- me.name, ERR_INVALIDUSERNAME, cptr->name);
- sendto_one(cptr,
- ":%s %d %s :Connect with your real username, in lowercase.",
- me.name, ERR_INVALIDUSERNAME, cptr->name);
- sendto_one(cptr, ":%s %d %s :If your mail address were foo@bar.com, "
- "your username would be foo.",
- me.name, ERR_INVALIDUSERNAME, cptr->name);
+
+ send_reply(cptr, RPL_EXPLICIT | ERR_INVALIDUSERNAME,
+ ":Your username is invalid.");
+ send_reply(cptr, RPL_EXPLICIT | ERR_INVALIDUSERNAME,
+ ":Connect with your real username, in lowercase.");
+ send_reply(cptr, RPL_EXPLICIT | ERR_INVALIDUSERNAME,
+ ":If your mail address were foo@bar.com, your username "
+ "would be foo.");
return exit_client(cptr, sptr, &me, "USER: Bad username");
}
Count_unknownbecomesclient(sptr, UserStats);
do {
sptr->cookie = (ircrandom() & 0x7fffffff);
} while (!sptr->cookie);
- /* XXX sendto_one used to send PING--must be very careful! */
- sendto_one(cptr, "PING :%u", sptr->cookie);
+ sendrawto_one(cptr, MSG_PING " :%u", sptr->cookie);
}
else if (*sptr->user->host && sptr->cookie == COOKIE_VERIFIED) {
/*
va_end(vl);
}
+/*
+ * Send a raw command to a single client; use *ONLY* if you absolutely
+ * must send a command without a prefix.
+ */
+void sendrawto_one(struct Client *to, const char *pattern, ...)
+{
+ char sndbuf[IRC_BUFSIZE];
+ va_list vl;
+
+ va_start(vl, pattern);
+ ircd_vsnprintf(to, sndbuf, sizeof(sndbuf) - 2, pattern, vl);
+ va_end(vl);
+
+ send_buffer(to, sndbuf);
+}
+
/*
* 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