From b1b9d9350e1aa2e3bd04bd1218b8596a41560773 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Tue, 25 Apr 2000 20:22:26 +0000 Subject: [PATCH] Author: Kev Log message: More changes to use new sendcmdto_* routines; also simplified them using new format options git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@202 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 31 +++++++- include/support.h | 1 - ircd/ircd_snprintf.c | 5 +- ircd/res.c | 42 +++++------ ircd/s_auth.c | 6 +- ircd/s_bsd.c | 47 +++++++------ ircd/s_serv.c | 69 ++++++------------ ircd/s_user.c | 164 +++++++++++++++++++------------------------ ircd/send.c | 46 ++---------- ircd/support.c | 45 ------------ ircd/uping.c | 127 +++++++++------------------------ ircd/userload.c | 31 +++----- ircd/whocmds.c | 4 +- 13 files changed, 226 insertions(+), 392 deletions(-) diff --git a/ChangeLog b/ChangeLog index af55368..c6ad9fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,34 @@ +2000-04-25 Kevin L. Mitchell + + * ircd/whocmds.c: use send_reply + + * ircd/userload.c: use sendcmdto_one + + * ircd/uping.c: use sendcmdto_one + + * ircd/send.c: use new flags to %C format string; ':' prefixes + client name with a colon for local connects, '#' uses + nick!user@host form for local connects + + * ircd/s_user.c: use send_reply, sendto_opmask_butone, + sendcmdto_one, sendcmdto_serv_butone, sendcmdto_flag_butone + + * ircd/s_serv.c: use sendcmdto_one, sendto_opmask_butone + + * ircd/s_bsd.c: use sendto_opmask_butone, send_reply, + sendcmdto_one + + * ircd/s_auth.c: use sendto_opmask_butone + + * ircd/res.c: use sendcmdto_one + + * ircd/ircd_snprintf.c (doprintf): minor bug fixes and some + debugging assertions + 2000-04-24 Kevin L. Mitchell + * ircd/support.c: dumpcore is no longer used, so get rid of it + * ircd/parse.c: use send_reply, sendcmdto_one * ircd/map.c: use send_reply @@ -692,7 +721,7 @@ # # ChangeLog for ircu2.10.11 # -# $Id: ChangeLog,v 1.100 2000-04-24 18:50:37 kev Exp $ +# $Id: ChangeLog,v 1.101 2000-04-25 20:22:25 kev Exp $ # # Insert new changes at beginning of the change list. # diff --git a/include/support.h b/include/support.h index b3e546f..3d07a30 100644 --- a/include/support.h +++ b/include/support.h @@ -20,7 +20,6 @@ * Prototypes */ -extern void dumpcore(const char *pattern, ...); extern int check_if_ipmask(const char *mask); extern void write_log(const char *filename, const char *pattern, ...); diff --git a/ircd/ircd_snprintf.c b/ircd/ircd_snprintf.c index c3ac949..69d7db1 100644 --- a/ircd/ircd_snprintf.c +++ b/ircd/ircd_snprintf.c @@ -22,6 +22,7 @@ #include "ircd_snprintf.h" #include "struct.h" +#include #include #include #include @@ -2012,7 +2013,9 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt, fld_s.flags &= ~(FLAG_ALT | FLAG_COLON); } else { str1 = *cptr->name ? cptr->name : "*"; - if (!IsServer(dest) && fld_s.flags & FLAG_ALT) { + if (!IsServer(cptr) && !IsMe(cptr) && fld_s.flags & FLAG_ALT) { + assert(0 != cptr->user); + assert(0 != *cptr->name); str2 = cptr->user->username; str3 = cptr->user->host; } else diff --git a/ircd/res.c b/ircd/res.c index ceeacb9..8f60bc4 100644 --- a/ircd/res.c +++ b/ircd/res.c @@ -17,6 +17,7 @@ #include "ircd_log.h" #include "ircd_osdep.h" #include "ircd_string.h" +#include "msg.h" #include "numeric.h" #include "s_bsd.h" #include "s_debug.h" @@ -1667,35 +1668,35 @@ int m_dns(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) if (parv[1] && *parv[1] == 'l') { for(cp = cacheTop; cp; cp = cp->list_next) { hp = &cp->he.h; - sendto_one(sptr, "NOTICE %s :Ex %d ttl %d host %s(%s)", - parv[0], cp->expireat - CurrentTime, cp->ttl, - hp->h_name, ircd_ntoa(hp->h_addr)); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Ex %d ttl %d host %s(%s)", + sptr, cp->expireat - CurrentTime, cp->ttl, + hp->h_name, ircd_ntoa(hp->h_addr)); for (i = 0; hp->h_aliases[i]; i++) - sendto_one(sptr,"NOTICE %s : %s = %s (CN)", - parv[0], hp->h_name, hp->h_aliases[i]); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C : %s = %s (CN)", sptr, + hp->h_name, hp->h_aliases[i]); for (i = 1; hp->h_addr_list[i]; i++) - sendto_one(sptr,"NOTICE %s : %s = %s (IP)", - parv[0], hp->h_name, ircd_ntoa(hp->h_addr_list[i])); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C : %s = %s (IP)", sptr, + hp->h_name, ircd_ntoa(hp->h_addr_list[i])); } return 0; } if (parv[1] && *parv[1] == 'd') { - sendto_one(sptr, "NOTICE %s :ResolverFileDescriptor = %d", - parv[0], ResolverFileDescriptor); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :ResolverFileDescriptor = %d", + sptr, ResolverFileDescriptor); return 0; } - sendto_one(sptr,"NOTICE %s :Ca %d Cd %d Ce %d Cl %d Ch %d:%d Cu %d", - sptr->name, - cainfo.ca_adds, cainfo.ca_dels, cainfo.ca_expires, - cainfo.ca_lookups, cainfo.ca_na_hits, cainfo.ca_nu_hits, - cainfo.ca_updates); + sendcmdto_one(&me, CMD_NOTICE, sptr,"%C :Ca %d Cd %d Ce %d Cl %d Ch %d:%d " + "Cu %d", sptr, + cainfo.ca_adds, cainfo.ca_dels, cainfo.ca_expires, + cainfo.ca_lookups, cainfo.ca_na_hits, cainfo.ca_nu_hits, + cainfo.ca_updates); - sendto_one(sptr,"NOTICE %s :Re %d Rl %d/%d Rp %d Rq %d", - sptr->name, reinfo.re_errors, reinfo.re_nu_look, - reinfo.re_na_look, reinfo.re_replies, reinfo.re_requests); - sendto_one(sptr,"NOTICE %s :Ru %d Rsh %d Rs %d(%d) Rt %d", sptr->name, - reinfo.re_unkrep, reinfo.re_shortttl, reinfo.re_sent, - reinfo.re_resends, reinfo.re_timeouts); + sendcmdto_one(&me, CMD_NOTICE, sptr,"%C :Re %d Rl %d/%d Rp %d Rq %d", + sptr, reinfo.re_errors, reinfo.re_nu_look, + reinfo.re_na_look, reinfo.re_replies, reinfo.re_requests); + sendcmdto_one(&me, CMD_NOTICE, sptr,"%C :Ru %d Rsh %d Rs %d(%d) Rt %d", sptr, + reinfo.re_unkrep, reinfo.re_shortttl, reinfo.re_sent, + reinfo.re_resends, reinfo.re_timeouts); #endif return 0; } @@ -1722,6 +1723,7 @@ size_t cres_mem(struct Client* sptr) 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", diff --git a/ircd/s_auth.c b/ircd/s_auth.c index b84d100..c687917 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -218,9 +218,9 @@ static void auth_dns_callback(void* vptr, struct DNSReply* reply) if (!hp->h_addr_list[i]) { if (IsUserPort(auth->client)) sendheader(auth->client, REPORT_IP_MISMATCH); - sendto_op_mask(SNO_IPMISMATCH, "IP# Mismatch: %s != %s[%s]", - auth->client->sock_ip, hp->h_name, - ircd_ntoa(hp->h_addr_list[0])); + sendto_opmask_butone(0, SNO_IPMISMATCH, "IP# Mismatch: %s != %s[%s]", + auth->client->sock_ip, hp->h_name, + ircd_ntoa(hp->h_addr_list[0])); #if defined(KILL_IPMISMATCH) auth_kill_client(auth); return; diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 4213843..4d9be9e 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -27,10 +27,12 @@ #include "hash.h" #include "ircd_log.h" #include "ircd_osdep.h" +#include "ircd_reply.h" #include "ircd_string.h" #include "ircd.h" #include "list.h" #include "listener.h" +#include "msg.h" #include "numeric.h" #include "numnicks.h" #include "packet.h" @@ -159,7 +161,7 @@ void report_error(const char* text, const char* who, int err) /* * pace error messages so opers don't get flooded by transients */ - sendto_ops(text, who, errmsg); + sendto_opmask_butone(0, SNO_OLDSNO, text, who, errmsg); last_notice = CurrentTime; } ircd_log(L_ERROR, text, who, errmsg); @@ -182,7 +184,8 @@ static void connect_dns_callback(void* vptr, struct DNSReply* reply) connect_server(aconf, 0, reply); } else - sendto_ops("Connect to %s failed: host lookup", aconf->name); + sendto_opmask_butone(0, SNO_OLDSNO, "Connect to %s failed: host lookup", + aconf->name); } /* @@ -395,13 +398,15 @@ static int completed_connection(struct Client* cptr) const char* msg = strerror(cptr->error); if (!msg) msg = "Unknown error"; - sendto_ops("Connection failed to %s: %s", cptr->name, msg); + sendto_opmask_butone(0, SNO_OLDSNO, "Connection failed to %s: %s", + cptr->name, msg); return 0; } if (!(aconf = find_conf_byname(cptr->confs, cptr->name, CONF_SERVER))) { - sendto_ops("Lost Server Line for %s", cptr->name); + 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); @@ -429,6 +434,7 @@ static int completed_connection(struct Client* cptr) */ 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); @@ -533,8 +539,7 @@ int net_close_unregistered_connections(struct Client* source) for (i = HighestFd; i > 0; --i) { if ((cptr = LocalClientArray[i]) && !IsRegistered(cptr)) { - sendto_one(source, rpl_str(RPL_CLOSING), me.name, source->name, - get_client_name(source, HIDE_IP)); + send_reply(source, RPL_CLOSING, get_client_name(source, HIDE_IP)); exit_client(source, cptr, &me, "Oper Closing"); ++count; } @@ -1300,7 +1305,8 @@ int connect_server(struct ConfItem* aconf, struct Client* by, assert(0 != aconf); if (aconf->dns_pending) { - sendto_ops("Server %s connect DNS pending"); + sendto_opmask_butone(0, SNO_OLDSNO, "Server %s connect DNS pending", + aconf->name); return 0; } Debug((DEBUG_NOTICE, "Connect to %s[@%s]", aconf->name, @@ -1308,22 +1314,18 @@ int connect_server(struct ConfItem* aconf, struct Client* by, if ((cptr = FindClient(aconf->name))) { if (IsServer(cptr) || IsMe(cptr)) { - sendto_ops("Server %s already present from %s", - aconf->name, cptr->from->name); + sendto_opmask_butone(0, SNO_OLDSNO, "Server %s already present from %s", + aconf->name, cptr->from->name); if (by && IsUser(by) && !MyUser(by)) { - sendto_one(by, "%s NOTICE %s%s :Server %s already present from %s", - NumServ(&me), NumNick(by), aconf->name, cptr->from->name); + sendcmdto_one(&me, CMD_NOTICE, by, "%C :Server %s already present " + "from %s", by, aconf->name, cptr->from->name); } return 0; } else if (IsHandshake(cptr) || IsConnecting(cptr)) { if (by && IsUser(by)) { - if (MyUser(by)) - sendto_one(by, ":%s NOTICE %s :Connection to %s already in progress", - me.name, by->name, cptr->name); - else - sendto_one(by, "%s NOTICE %s%s :Connection to %s already in progress", - NumServ(&me), NumNick(by), cptr->name); + sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connection to %s already in " + "progress", by, cptr->name); } return 0; } @@ -1370,10 +1372,11 @@ int connect_server(struct ConfItem* aconf, struct Client* by, attach_confs_byhost(cptr, aconf->host, CONF_SERVER); if (!find_conf_byhost(cptr->confs, aconf->host, CONF_SERVER)) { - sendto_ops("Host %s is not enabled for connecting: no C-line", aconf->name); + sendto_opmask_butone(0, SNO_OLDSNO, "Host %s is not enabled for " + "connecting: no C-line", aconf->name); if (by && IsUser(by) && !MyUser(by)) { - sendto_one(by, "%s NOTICE %s%s :Connect to host %s failed: no C-line", - NumServ(&me), NumNick(by), aconf->name); + sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connect to host %s failed: no " + "C-line", by, aconf->name); } det_confs_butmask(cptr, 0); free_client(cptr); @@ -1384,8 +1387,8 @@ int connect_server(struct ConfItem* aconf, struct Client* by, */ if (!connect_inet(aconf, cptr)) { if (by && IsUser(by) && !MyUser(by)) { - sendto_one(by, "%s NOTICE %s%s :Couldn't connect to %s", - NumServ(&me), NumNick(by), cptr->name); + sendcmdto_one(&me, CMD_NOTICE, by, "%C :Couldn't connect to %s", by, + cptr->name); } det_confs_butmask(cptr, 0); free_client(cptr); diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 4cb3459..93baf6a 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -142,12 +142,8 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) if (cptr->serv->user && *cptr->serv->by && (acptr = findNUser(cptr->serv->by))) { if (acptr->user == cptr->serv->user) { - if (MyUser(acptr)) - sendto_one(acptr, ":%s NOTICE %s :Link with %s established.", - me.name, acptr->name, inpath); - else - sendto_one(acptr, "%s NOTICE %s%s :Link with %s established.", - NumServ(&me), NumNick(acptr), inpath); + sendcmdto_one(&me, CMD_NOTICE, acptr, "%C :Link with %s established.", + acptr, inpath); } else { /* @@ -158,10 +154,11 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) } } - sendto_lops_butone(acptr, "Link with %s established.", inpath); + sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s established.", inpath); cptr->serv->up = &me; cptr->serv->updown = add_dlink(&me.serv->down, cptr); - sendto_op_mask(SNO_NETWORK, "Net junction: %s %s", me.name, cptr->name); + sendto_opmask_butone(0, SNO_NETWORK, "Net junction: %s %s", me.name, + cptr->name); SetJunction(cptr); /* * Old sendto_serv_but_one() call removed because we now @@ -175,20 +172,9 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) continue; if (!match(me.name, cptr->name)) continue; - if (split) - { - sendto_one(acptr, "%s " TOK_SERVER " %s 2 0 " TIME_T_FMT " %s%u %s%s 0 :%s", - NumServ(&me), cptr->name, cptr->serv->timestamp, - (Protocol(cptr) > 9) ? "J" : "J0", Protocol(cptr), - NumServCap(cptr), cptr->info); - } - else - { - sendto_one(acptr, "%s " TOK_SERVER " %s 2 0 " TIME_T_FMT " %s%u %s%s 0 :%s", - NumServ(&me), cptr->name, cptr->serv->timestamp, - (Protocol(cptr) > 9) ? "J" : "J0", Protocol(cptr), - NumServCap(cptr), cptr->info); - } + sendcmdto_one(&me, CMD_SERVER, acptr, "%s 2 0 %Tu J%02u %s%s 0 :%s", + cptr->name, cptr->serv->timestamp, Protocol(cptr), + NumServCap(cptr), cptr->info); } /* @@ -223,24 +209,10 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) split = (MyConnect(acptr) && 0 != ircd_strcmp(acptr->name, acptr->sockhost) && 0 != ircd_strncmp(acptr->info, "JUPE", 4)); - if (split) - { - sendto_one(cptr, - "%s " TOK_SERVER " %s %d 0 " TIME_T_FMT " %s%u %s%s 0 :%s", - NumServ(acptr->serv->up), acptr->name, - acptr->hopcount + 1, acptr->serv->timestamp, - protocol_str, Protocol(acptr), - NumServCap(acptr), acptr->info); - } - else - { - sendto_one(cptr, - "%s " TOK_SERVER " %s %d 0 " TIME_T_FMT " %s%u %s%s 0 :%s", - NumServ(acptr->serv->up), acptr->name, - acptr->hopcount + 1, acptr->serv->timestamp, - protocol_str, Protocol(acptr), - NumServCap(acptr), acptr->info); - } + sendcmdto_one(&me, CMD_SERVER, cptr, "%s %d 0 %Tu %s%u %s%s 0 :%s", + acptr->name, acptr->hopcount + 1, acptr->serv->timestamp, + protocol_str, Protocol(acptr), NumServCap(acptr), + acptr->info); } } @@ -253,14 +225,13 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) { char xxx_buf[8]; char *s = umode_str(acptr); - sendto_one(cptr, *s ? - "%s N %s %d " TIME_T_FMT " %s %s +%s %s %s%s :%s" : - "%s N %s %d " TIME_T_FMT " %s %s %s%s %s%s :%s", - NumServ(acptr->user->server), - acptr->name, acptr->hopcount + 1, acptr->lastnick, - acptr->user->username, acptr->user->host, - s, inttobase64(xxx_buf, ntohl(acptr->ip.s_addr), 6), - NumNick(acptr), acptr->info); + sendcmdto_one(acptr->user->server, CMD_NICK, cptr, *s ? + "%s %d %Tu %s %s +%s %s %s%s :%s" : + "%s %d %Tu %s %s %s%s %s%s :%s", + acptr->name, acptr->hopcount + 1, acptr->lastnick, + acptr->user->username, acptr->user->host, s, + inttobase64(xxx_buf, ntohl(acptr->ip.s_addr), 6), + NumNick(acptr), acptr->info); } } /* @@ -274,7 +245,7 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) } jupe_burst(cptr); gline_burst(cptr); - sendto_one(cptr, "%s EB", NumServ(&me)); + sendcmdto_one(&me, CMD_END_OF_BURST, cptr, ""); return 0; } diff --git a/ircd/s_user.c b/ircd/s_user.c index 3a55fd0..f4456a4 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -245,8 +245,7 @@ int hunt_server(int MustBeOper, struct Client *cptr, struct Client *sptr, char * } else if (!(acptr = find_match_server(parv[server]))) { - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), - me.name, parv[0], parv[server]); + send_reply(sptr, ERR_NOSUCHSERVER, parv[server]); return (HUNTED_NOSUCH); } } @@ -258,7 +257,7 @@ int hunt_server(int MustBeOper, struct Client *cptr, struct Client *sptr, char * if (MustBeOper && !IsPrivileged(sptr)) { - sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, sptr->name); + send_reply(sptr, ERR_NOPRIVILEGES); return HUNTED_NOSUCH; } @@ -266,6 +265,7 @@ int hunt_server(int MustBeOper, struct Client *cptr, struct Client *sptr, char * parv[server] = y; assert(!IsServer(sptr)); + /* XXX sendto_one used with explicit command; must be very careful */ sendto_one(acptr, command, NumNick(sptr), parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); @@ -398,32 +398,35 @@ int register_user(struct Client *cptr, struct Client *sptr, case ACR_OK: break; case ACR_NO_AUTHORIZATION: - sendto_op_mask(SNO_UNAUTH, "Unauthorized connection from %s.", - get_client_name(sptr, HIDE_IP)); + sendto_opmask_butone(0, SNO_UNAUTH, "Unauthorized connection from %s.", + get_client_name(sptr, HIDE_IP)); ++ServerStats->is_ref; return exit_client(cptr, sptr, &me, - "No Authorization - use another server"); + "No Authorization - use another server"); case ACR_TOO_MANY_IN_CLASS: if (CurrentTime - last_too_many1 >= (time_t) 60) { last_too_many1 = CurrentTime; - sendto_op_mask(SNO_TOOMANY, "Too many connections in class for %s.", - get_client_name(sptr, HIDE_IP)); + sendto_opmask_butone(0, SNO_TOOMANY, "Too many connections in " + "class for %s.", + get_client_name(sptr, HIDE_IP)); } ++ServerStats->is_ref; IPcheck_connect_fail(sptr->ip); return exit_client(cptr, sptr, &me, - "Sorry, your connection class is full - try again later or try another server"); + "Sorry, your connection class is full - try " + "again later or try another server"); case ACR_TOO_MANY_FROM_IP: if (CurrentTime - last_too_many2 >= (time_t) 60) { last_too_many2 = CurrentTime; - sendto_op_mask(SNO_TOOMANY, "Too many connections from same IP for %s.", - get_client_name(sptr, HIDE_IP)); + sendto_opmask_butone(0, SNO_TOOMANY, "Too many connections from " + "same IP for %s.", + get_client_name(sptr, HIDE_IP)); } ++ServerStats->is_ref; return exit_client(cptr, sptr, &me, - "Too many connections from your host"); + "Too many connections from your host"); case ACR_ALREADY_AUTHORIZED: /* Can this ever happen? */ case ACR_BAD_SOCKET: @@ -451,7 +454,7 @@ int register_user(struct Client *cptr, struct Client *sptr, { ServerStats->is_ref++; IPcheck_connect_fail(sptr->ip); - sendto_one(sptr, err_str(ERR_PASSWDMISMATCH), me.name, parv[0]); + send_reply(sptr, ERR_PASSWDMISMATCH); return exit_client(cptr, sptr, &me, "Bad Password"); } memset(sptr->passwd, 0, sizeof(sptr->passwd)); @@ -531,6 +534,7 @@ int register_user(struct Client *cptr, struct Client *sptr, 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, @@ -560,16 +564,15 @@ int register_user(struct Client *cptr, struct Client *sptr, sptr->handler = CLIENT_HANDLER; release_dns_reply(sptr); - sendto_one(sptr, rpl_str(RPL_WELCOME), me.name, nick, nick); + send_reply(sptr, RPL_WELCOME, nick); /* * This is a duplicate of the NOTICE but see below... */ - sendto_one(sptr, rpl_str(RPL_YOURHOST), me.name, nick, - me.name, version); - sendto_one(sptr, rpl_str(RPL_CREATED), me.name, nick, creation); - sendto_one(sptr, rpl_str(RPL_MYINFO), me.name, parv[0], me.name, version); + send_reply(sptr, RPL_YOURHOST, me.name, version); + send_reply(sptr, RPL_CREATED, creation); + send_reply(sptr, RPL_MYINFO, me.name, version); sprintf_irc(featurebuf,FEATURES,FEATURESVALUES); - sendto_one(sptr, rpl_str(RPL_ISUPPORT), me.name, nick, featurebuf); + send_reply(sptr, RPL_ISUPPORT, featurebuf); m_lusers(sptr, sptr, 1, parv); update_load(); #ifdef NODEFAULTMOTD @@ -582,16 +585,12 @@ int register_user(struct Client *cptr, struct Client *sptr, set_snomask(sptr, sptr->snomask & SNO_NOISY, SNO_ADD); #ifdef ALLOW_SNO_CONNEXIT #ifdef SNO_CONNEXIT_IP - sprintf_irc(sendbuf, - ":%s NOTICE * :*** Notice -- Client connecting: %s (%s@%s) [%s] {%d}", - me.name, nick, user->username, user->host, cptr->sock_ip, - get_client_class(sptr)); - sendbufto_op_mask(SNO_CONNEXIT); + sendto_opmask_butone(0, SNO_CONNEXIT, "Client connecting: %s (%s@%s) " + "[%s] {%d}", nick, user->username, user->host, + cptr->sock_ip, get_client_class(sptr)); #else /* SNO_CONNEXIT_IP */ - sprintf_irc(sendbuf, - ":%s NOTICE * :*** Notice -- Client connecting: %s (%s@%s)", - me.name, nick, user->username, user->host); - sendbufto_op_mask(SNO_CONNEXIT); + sendto_opmask_butone(0, SNO_CONEXIT, "Client connecting: %s (%s@%s)", + nick, user->username, user->host); #endif /* SNO_CONNEXIT_IP */ #endif /* ALLOW_SNO_CONNEXIT */ IPcheck_connect_succeeded(sptr); @@ -604,9 +603,9 @@ int register_user(struct Client *cptr, struct Client *sptr, acptr = user->server; if (acptr->from != sptr->from) { - sendto_one(cptr, "%s " TOK_KILL " %s%s :%s (%s != %s[%s])", - NumServ(&me), NumNick(sptr), me.name, user->server->name, - acptr->from->name, acptr->from->sockhost); + sendcmdto_one(&me, CMD_KILL, cptr, "%C :%s (%s != %s[%s])", + sptr, me.name, user->server->name, acptr->from->name, + acptr->from->sockhost); sptr->flags |= FLAGS_KILLED; return exit_client(cptr, sptr, &me, "NICK server wrong direction"); } @@ -631,21 +630,20 @@ int register_user(struct Client *cptr, struct Client *sptr, } tmpstr = umode_str(sptr); - sendto_serv_butone(cptr, *tmpstr ? - "%s " TOK_NICK " %s %d %d %s %s +%s %s %s%s :%s" : - "%s " TOK_NICK " %s %d %d %s %s %s%s %s%s :%s", - NumServ(user->server), nick, sptr->hopcount + 1, sptr->lastnick, - user->username, user->host, tmpstr, - inttobase64(ip_base64, ntohl(sptr->ip.s_addr), 6), - NumNick(sptr), sptr->info); + sendcmdto_serv_butone(user->server, CMD_NICK, cptr, *tmpstr ? + "%s %d %d %s %s +%s %s %s%s :%s" : + "%s %d %d %s %s %s%s %s%s :%s", + nick, sptr->hopcount + 1, sptr->lastnick, + user->username, user->host, tmpstr, + inttobase64(ip_base64, ntohl(sptr->ip.s_addr), 6), + NumNick(sptr), sptr->info); /* Send umode to client */ if (MyUser(sptr)) { send_umode(cptr, sptr, 0, ALL_UMODES); if (sptr->snomask != SNO_DEFAULT && (sptr->flags & FLAGS_SERVNOTICE)) - sendto_one(sptr, rpl_str(RPL_SNOMASK), me.name, sptr->name, - sptr->snomask, sptr->snomask); + send_reply(sptr, RPL_SNOMASK, sptr->snomask, sptr->snomask); } return 0; @@ -744,9 +742,7 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, if (MyUser(sptr)) { const char* channel_name; if ((channel_name = find_no_nickchange_channel(sptr))) { - sendto_one(cptr, err_str(ERR_BANNICKCHANGE), me.name, parv[0], - channel_name); - return 0; + return send_reply(cptr, ERR_BANNICKCHANGE, channel_name); } /* * Refuse nick change if the last nick change was less @@ -758,10 +754,10 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, */ if (CurrentTime < cptr->nextnick) { cptr->nextnick += 2; - sendto_one(cptr, err_str(ERR_NICKTOOFAST), - me.name, parv[0], parv[1], cptr->nextnick - CurrentTime); + send_reply(cptr, ERR_NICKTOOFAST, parv[1], + cptr->nextnick - CurrentTime); /* Send error message */ - sendto_prefix_one(cptr, cptr, ":%s NICK %s", parv[0], parv[0]); + sendcmdto_one(cptr, CMD_NICK, cptr, "%s", cptr->name); /* bounce NICK to user */ return 0; /* ignore nick change! */ } @@ -785,13 +781,13 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, * on that channel. Propagate notice to other servers. */ if (IsUser(sptr)) { - sendto_common_channels(sptr, ":%s NICK :%s", parv[0], nick); + sendcmdto_common_channels(sptr, CMD_NICK, ":%s", nick); add_history(sptr, 1); - sendto_serv_butone(cptr, - "%s%s " TOK_NICK " %s " TIME_T_FMT, NumNick(sptr), nick, sptr->lastnick); + sendcmdto_serv_butone(sptr, CMD_NICK, cptr, "%s %Tu", nick, + sptr->lastnick); } else - sendto_one(sptr, ":%s NICK :%s", parv[0], nick); + sendcmdto_one(sptr, CMD_NICK, sptr, ":%s", nick); if (sptr->name[0]) hRemClient(sptr); @@ -817,6 +813,7 @@ int set_nick_name(struct Client* cptr, struct Client* sptr, 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); } else if (*sptr->user->host && sptr->cookie == COOKIE_VERIFIED) { @@ -910,13 +907,14 @@ int check_target_limit(struct Client *sptr, void *target, const char *name, * No server flooding */ sptr->nexttarget += 2; - sendto_one(sptr, err_str(ERR_TARGETTOOFAST), - me.name, sptr->name, name, sptr->nexttarget - CurrentTime); + send_reply(sptr, ERR_TARGETTOOFAST, name, + sptr->nexttarget - CurrentTime); } return 1; } else { #ifdef GODMODE + /* XXX Let's get rid of GODMODE */ sendto_one(sptr, ":%s NOTICE %s :New target: %s; ft " TIME_T_FMT, me.name, sptr->name, name, (CurrentTime - sptr->nexttarget) / TARGET_DELAY); #endif @@ -960,12 +958,10 @@ int whisper(struct Client* source, const char* nick, const char* channel, assert(MyUser(source)); if (!(dest = FindUser(nick))) { - sendto_one(source, err_str(ERR_NOSUCHNICK), me.name, source->name, nick); - return 0; + return send_reply(source, ERR_NOSUCHNICK, nick); } if (!(chptr = FindChannel(channel))) { - sendto_one(source, err_str(ERR_NOSUCHCHANNEL), me.name, source->name, channel); - return 0; + return send_reply(source, ERR_NOSUCHCHANNEL, channel); } /* * compare both users channel lists, instead of the channels user list @@ -977,12 +973,10 @@ int whisper(struct Client* source, const char* nick, const char* channel, break; } if (0 == membership) { - sendto_one(source, err_str(ERR_NOTONCHANNEL), me.name, source->name, chptr->chname); - return 0; + return send_reply(source, ERR_NOTONCHANNEL, chptr->chname); } if (!IsVoicedOrOpped(membership)) { - sendto_one(source, err_str(ERR_VOICENEEDED), me.name, source->name, chptr->chname); - return 0; + return send_reply(source, ERR_VOICENEEDED, chptr->chname); } /* * lookup channel in destination @@ -993,24 +987,17 @@ int whisper(struct Client* source, const char* nick, const char* channel, break; } if (0 == membership || IsZombie(membership)) { - sendto_one(source, err_str(ERR_USERNOTINCHANNEL), me.name, - source->name, dest->name, chptr->chname); - return 0; + return send_reply(source, ERR_USERNOTINCHANNEL, dest->name, chptr->chname); } if (is_silenced(source, dest)) return 0; if (dest->user->away) - sendto_one(source, rpl_str(RPL_AWAY), me.name, source->name, - dest->name, dest->user->away); - if (MyUser(dest)) - sendto_prefix_one(dest, source, ":%s %s %s :%s", - source->name, is_notice ? MSG_NOTICE : MSG_PRIVATE, - dest->name, text); + send_reply(source, RPL_AWAY, dest->name, dest->user->away); + if (is_notice) + sendcmdto_one(source, CMD_NOTICE, dest, "%C :%s", dest, text); else - sendto_one(dest, "%s%s %s %s%s :%s", - NumNick(source), is_notice ? TOK_NOTICE : TOK_PRIVATE, - NumNick(dest), text); + sendcmdto_one(source, CMD_PRIVATE, dest, "%C :%s", dest, text); return 0; } @@ -1028,7 +1015,7 @@ void send_umode_out(struct Client *cptr, struct Client *sptr, int old) for (i = HighestFd; i >= 0; i--) { if ((acptr = LocalClientArray[i]) && IsServer(acptr) && (acptr != cptr) && (acptr != sptr) && *umodeBuf) - sendto_one(acptr, "%s%s " TOK_MODE " %s :%s", NumNick(sptr), sptr->name, umodeBuf); + sendcmdto_one(sptr, CMD_MODE, acptr, "%s :%s", sptr->name, umodeBuf); } if (cptr && MyUser(cptr)) send_umode(cptr, sptr, old, ALL_UMODES); @@ -1097,17 +1084,18 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv if (!(acptr = FindUser(parv[1]))) { if (MyConnect(sptr)) - sendto_one(sptr, err_str(ERR_NOSUCHCHANNEL), me.name, parv[0], parv[1]); + send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); return 0; } if (IsServer(sptr) || sptr != acptr) { if (IsServer(cptr)) - sendto_ops_butone(NULL, &me, ":%s WALLOPS :MODE for User %s From %s!%s", - me.name, parv[1], cptr->name, sptr->name); + sendcmdto_flag_butone(&me, CMD_WALLOPS, 0, FLAGS_WALLOP, + ":MODE for User %s from %s!%s", parv[1], + cptr->name, sptr->name); else - sendto_one(sptr, err_str(ERR_USERSDONTMATCH), me.name, parv[0]); + send_reply(sptr, ERR_USERSDONTMATCH); return 0; } @@ -1120,12 +1108,11 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv *m++ = userModeList[i].c; } *m = '\0'; - sendto_one(sptr, rpl_str(RPL_UMODEIS), me.name, parv[0], buf); + send_reply(sptr, RPL_UMODEIS, buf); if ((sptr->flags & FLAGS_SERVNOTICE) && MyConnect(sptr) && sptr->snomask != (unsigned int)(IsOper(sptr) ? SNO_OPERDEFAULT : SNO_DEFAULT)) - sendto_one(sptr, rpl_str(RPL_SNOMASK), me.name, parv[0], sptr->snomask, - sptr->snomask); + send_reply(sptr, RPL_SNOMASK, sptr->snomask, sptr->snomask); return 0; } @@ -1269,8 +1256,7 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv if (tmpmask != sptr->snomask) set_snomask(sptr, tmpmask, SNO_SET); if (sptr->snomask && snomask_given) - sendto_one(sptr, rpl_str(RPL_SNOMASK), me.name, sptr->name, - sptr->snomask, sptr->snomask); + send_reply(sptr, RPL_SNOMASK, sptr->snomask, sptr->snomask); } return 0; @@ -1344,7 +1330,7 @@ void send_umode(struct Client *cptr, struct Client *sptr, int old, int sendmask) } *m = '\0'; if (*umodeBuf && cptr) - sendto_one(cptr, ":%s MODE %s :%s", sptr->name, sptr->name, umodeBuf); + sendcmdto_one(sptr, CMD_MODE, cptr, "%s :%s", sptr->name, umodeBuf); } /* @@ -1436,7 +1422,7 @@ void set_snomask(struct Client *cptr, unsigned int newmask, int what) else if (what == SNO_DEL) newmask = oldmask & ~newmask; else if (what != SNO_SET) /* absolute set, no math needed */ - sendto_ops("setsnomask called with %d ?!", what); + sendto_opmask_butone(0, SNO_OLDSNO, "setsnomask called with %d ?!", what); newmask &= (IsAnOper(cptr) ? SNO_ALL : SNO_USER); @@ -1487,12 +1473,8 @@ int is_silenced(struct Client *sptr, struct Client *acptr) { if (!MyConnect(sptr)) { - if (Protocol(sptr->from) < 10) - sendto_one(sptr->from, ":%s SILENCE %s %s", acptr->name, - sptr->name, lp->value.cp); - else - sendto_one(sptr->from, ":%s SILENCE %s%s %s", acptr->name, - NumNick(sptr), lp->value.cp); + sendcmdto_one(acptr, CMD_SILENCE, sptr->from, "%C %s", sptr, + lp->value.cp); } return 1; } @@ -1550,7 +1532,7 @@ int add_silence(struct Client* sptr, const char* mask) len += strlen(lp->value.cp); if ((len > MAXSILELENGTH) || (++cnt >= MAXSILES)) { - sendto_one(sptr, err_str(ERR_SILELISTFULL), me.name, sptr->name, mask); + send_reply(sptr, ERR_SILELISTFULL, mask); return -1; } else if (!mmatch(lp->value.cp, mask)) diff --git a/ircd/send.c b/ircd/send.c index ffd5b60..e118b07 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -1013,16 +1013,8 @@ void vsendcmdto_one(struct Client *from, const char *cmd, const char *tok, vd.vd_format = pattern; /* set up the struct VarData for %v */ vd.vd_args = vl; - if (MyUser(to)) { /* :nick!user@host form; use cmd */ - if (IsServer(from) || IsMe(from)) - ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v", - from->name, cmd, &vd); - else - 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); + ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %v", from, + IsServer(to) || IsMe(to) ? tok : cmd, &vd); send_buffer(to, sndbuf); } @@ -1089,8 +1081,7 @@ void sendcmdto_common_channels(struct Client *from, const char *cmd, va_start(vd.vd_args, pattern); /* build the buffer */ - ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", from->name, - from->user->username, from->user->host, cmd, &vd); + ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %v", from, cmd, &vd); va_end(vd.vd_args); sentalong_marker++; @@ -1128,12 +1119,7 @@ void sendcmdto_channel_butserv(struct Client *from, const char *cmd, va_start(vd.vd_args, pattern); /* build the buffer */ - if (IsServer(from) || IsMe(from)) - ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s %s %v", from->name, - cmd, &vd); - else - ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s!%s@%s %s %v", from->name, - from->user->username, from->user->host, cmd, &vd); + ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %v", from, cmd, &vd); va_end(vd.vd_args); /* send the buffer to each local channel member */ @@ -1174,13 +1160,7 @@ void sendcmdto_channel_butone(struct Client *from, const char *cmd, /* Build buffer to send to users */ va_start(vd.vd_args, pattern); - if (IsServer(from) || IsMe(from)) - ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s %s %v", from->name, - cmd, &vd); - else - ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s!%s@%s %s %v", - from->name, from->user->username, from->user->host, cmd, - &vd); + ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, "%:#C %s %v", from, cmd, &vd); va_end(vd.vd_args); /* Build buffer to send to servers */ @@ -1234,13 +1214,7 @@ void sendcmdto_flag_butone(struct Client *from, const char *cmd, /* Build buffer to send to users */ va_start(vd.vd_args, pattern); - if (IsServer(from) || IsMe(from)) - ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s %s %v", from->name, - cmd, &vd); - else - ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s!%s@%s %s %v", - from->name, from->user->username, from->user->host, cmd, - &vd); + ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, "%:#C %s %v", from, cmd, &vd); va_end(vd.vd_args); /* Build buffer to send to servers */ @@ -1294,13 +1268,7 @@ void sendcmdto_match_butone(struct Client *from, const char *cmd, /* Build buffer to send to users */ va_start(vd.vd_args, pattern); - if (IsServer(from) || IsMe(from)) /* probably a bad idea :) */ - ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s %s %v", from->name, - cmd, &vd); - else - ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, ":%s!%s@%s %s %v", - from->name, from->user->username, from->user->host, cmd, - &vd); + ircd_snprintf(0, userbuf, sizeof(userbuf) - 2, "%:#C %s %v", from, cmd, &vd); va_end(vd.vd_args); /* Build buffer to send to servers */ diff --git a/ircd/support.c b/ircd/support.c index 6f98211..81a38c2 100644 --- a/ircd/support.c +++ b/ircd/support.c @@ -35,51 +35,6 @@ #include #include -#ifdef DEBUGMODE - -void dumpcore(const char *pattern, ...) -{ - va_list vl; - static time_t lastd = 0; - static int dumps = 0; - char corename[12]; - time_t now; - int p; - - va_start(vl, pattern); - - now = time(NULL); - - if (!lastd) - lastd = now; - else if (now - lastd < 60 && dumps > 2) - server_die("too many core dumps"); - if (now - lastd > 60) - { - lastd = now; - dumps = 1; - } - else - dumps++; - p = getpid(); - if (fork() > 0) - { - kill(p, 3); - kill(p, 9); - } - sprintf_irc(corename, "core.%d", p); - rename("core", corename); - Debug((DEBUG_FATAL, "Dumped core : core.%d", p)); - sendto_ops("Dumped core : core.%d", p); - vdebug(DEBUG_FATAL, pattern, vl); - vsendto_ops(pattern, vl); - va_end(vl); - - server_die("debug core dump"); - -} -#endif - int check_if_ipmask(const char *mask) { int has_digit = 0; diff --git a/ircd/uping.c b/ircd/uping.c index c84401b..ab90801 100644 --- a/ircd/uping.c +++ b/ircd/uping.c @@ -170,18 +170,10 @@ static void uping_start(struct UPing* pptr) { assert(0 != pptr); - if (MyUser(pptr->client)) { - sendto_one(pptr->client, - ":%s NOTICE %s :Sending %d ping%s to %s", - me.name, pptr->client->name, pptr->count, - (pptr->count == 1) ? "" : "s", pptr->name); - } - else { - sendto_one(pptr->client, - "%s NOTICE %s%s :Sending %d ping%s to %s", - NumServ(&me), NumNick(pptr->client), pptr->count, - (pptr->count == 1) ? "" : "s", pptr->name); - } + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :Sending %d ping%s to %s", + pptr->client, pptr->count, (pptr->count == 1) ? "" : "s", + pptr->name); + pptr->timeout = CurrentTime + UPINGTIMEOUT; pptr->active = 1; } @@ -214,14 +206,9 @@ void uping_send(struct UPing* pptr) const char* msg = strerror(errno); if (!msg) msg = "Unknown error"; - if (pptr->client) { - if (MyUser(pptr->client)) - sendto_one(pptr->client, ":%s NOTICE %s :UPING: send failed: %s", - me.name, pptr->client->name, msg); - else - sendto_one(pptr->client, "%s NOTICE %s%s :UPING: sendto() failed: %s", - NumServ(&me), NumNick(pptr->client), msg); - } + if (pptr->client) + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :UPING: send failed: " + "%s", pptr->client, msg); Debug((DEBUG_DEBUG, "UPING: send_ping: sendto failed on %d: %s", pptr->fd, msg)); uping_end(pptr); return; @@ -253,12 +240,8 @@ void uping_read(struct UPing* pptr) const char* msg = strerror(errno); if (!msg) msg = "Unknown error"; - if (MyUser(pptr->client)) - sendto_one(pptr->client, ":%s NOTICE %s :UPING: receive error: %s", - me.name, pptr->client->name, msg); - else - sendto_one(pptr->client, "%s NOTICE %s%s :UPING: receive error: %s", - NumServ(&me), NumNick(pptr->client), msg); + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :UPING: receive error: " + "%s", pptr->client, msg); uping_end(pptr); return; } @@ -300,34 +283,23 @@ int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int coun assert(0 != aconf); if (INADDR_NONE == aconf->ipnum.s_addr) { - if (MyUser(sptr)) - sendto_one(sptr, ":%s NOTICE %s :UPING: Host lookup failed for %s", - me.name, sptr->name, aconf->name); - else - sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Host lookup failed for %s", - NumServ(&me), NumNick(sptr), aconf->name); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :UPING: Host lookup failed for " + "%s", sptr, aconf->name); + return 0; } if (IsUPing(sptr)) uping_cancel(sptr, sptr); /* Cancel previous ping request */ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - if (MyUser(sptr)) - sendto_one(sptr, ":%s NOTICE %s :UPING: Unable to create udp ping socket", - me.name, sptr->name); - else - sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Unable to create udp ping socket", - NumServ(&me), NumNick(sptr)); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :UPING: Unable to create udp " + "ping socket", sptr); return 0; } if (!os_set_nonblocking(fd)) { - if (MyUser(sptr)) - sendto_one(sptr, ":%s NOTICE %s :UPING: Can't set fd non-blocking", - me.name, sptr->name); - else - sendto_one(sptr, "%s " TOK_NOTICE " %s%s :UPING: Can't set fd non-blocking", - NumServ(&me), NumNick(sptr)); + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :UPING: Can't set fd non-" + "blocking", sptr); close(fd); return 0; } @@ -358,58 +330,23 @@ void uping_end(struct UPing* pptr) Debug((DEBUG_DEBUG, "uping_end: %p", pptr)); if (pptr->client) { - if (MyUser(pptr->client)) { - if (pptr->lastsent) { - if (0 < pptr->received) { - sendto_one(pptr->client, ":%s NOTICE %s :UPING %s%s", - me.name, pptr->client->name, pptr->name, pptr->buf); - /* - * XXX - warning long unsigned int format, unsigned int arg (7, 8, 9) - */ - sendto_one(pptr->client, - ":%s NOTICE %s :UPING Stats: sent %d recvd %d ; " - "min/avg/max = %1lu/%1lu/%1lu ms", - me.name, pptr->client->name, pptr->sent, - pptr->received, pptr->ms_min, - (2 * pptr->ms_ave) / (2 * pptr->received), - pptr->ms_max); - } - else - sendto_one(pptr->client, - ":%s NOTICE %s :UPING: no response from %s within %d seconds", - me.name, pptr->client->name, pptr->name, - UPINGTIMEOUT); - } - else - sendto_one(pptr->client, - ":%s NOTICE %s :UPING: Could not start ping to %s", - me.name, pptr->client->name, pptr->name); - } - else { - if (pptr->lastsent) { - if (0 < pptr->received) { - sendto_one(pptr->client, "%s NOTICE %s%s :UPING %s%s", - NumServ(&me), NumNick(pptr->client), pptr->name, pptr->buf); - /* XXX - warning: long unsigned int format, unsigned int arg(9, 10, 11) */ - sendto_one(pptr->client, - "%s " TOK_NOTICE " %s%s :UPING Stats: sent %d recvd %d ; " - "min/avg/max = %1lu/%1lu/%1lu ms", - NumServ(&me), NumNick(pptr->client), pptr->sent, - pptr->received, pptr->ms_min, - (2 * pptr->ms_ave) / (2 * pptr->received), - pptr->ms_max); - } - else - sendto_one(pptr->client, - "%s " TOK_NOTICE " %s%s :UPING: no response from %s within %d seconds", - NumServ(&me), NumNick(pptr->client), pptr->name, UPINGTIMEOUT); - } - else - sendto_one(pptr->client, - "%s " TOK_NOTICE " %s%s :UPING: Could not start ping to %s", - NumServ(&me), NumNick(pptr->client), pptr->name); - } + if (pptr->lastsent) { + if (0 < pptr->received) { + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :UPING %s%s", + pptr->client, pptr->name, pptr->buf); + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :UPING Stats: " + "sent %d recvd %d ; min/avg/max = %1lu/%1lu/%1lu ms", + pptr->client, pptr->sent, pptr->received, pptr->ms_min, + (2 * pptr->ms_ave) / (2 * pptr->received), pptr->ms_max); + } else + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :UPING: no response " + "from %s within %d seconds", pptr->client, pptr->name, + UPINGTIMEOUT); + } else + sendcmdto_one(&me, CMD_NOTICE, pptr->client, "%C :UPING: Could not " + "start ping to %s", pptr->client, pptr->name); } + close(pptr->fd); pptr->fd = -1; uping_erase(pptr); diff --git a/ircd/userload.c b/ircd/userload.c index 7b64dd0..b51d2f9 100644 --- a/ircd/userload.c +++ b/ircd/userload.c @@ -28,6 +28,7 @@ #include "userload.h" #include "client.h" #include "ircd.h" +#include "msg.h" #include "numnicks.h" #include "querycmds.h" #include "s_misc.h" @@ -243,29 +244,13 @@ void calc_load(struct Client *sptr) times[i][2] /= 86400; } - if (MyUser(sptr) || Protocol(sptr->from) < 10) - { - sendto_one(sptr, ":%s NOTICE %s :%s", me.name, sptr->name, header); - for (i = 0; i < 3; ++i) - sendto_one(sptr, - ":%s NOTICE %s :%4d.%1d %4d.%1d %4d %4d %4d %s", - me.name, sptr->name, - times[0][i] / 10, times[0][i] % 10, - times[1][i] / 10, times[1][i] % 10, - times[2][i], times[3][i], times[4][i], what[i]); - } - else - { - sendto_one(sptr, "%s NOTICE %s%s :%s", - NumServ(&me), NumNick(sptr), header); - for (i = 0; i < 3; ++i) - sendto_one(sptr, - "%s NOTICE %s%s :%4d.%1d %4d.%1d %4d %4d %4d %s", - NumServ(&me), NumNick(sptr), - times[0][i] / 10, times[0][i] % 10, - times[1][i] / 10, times[1][i] % 10, - times[2][i], times[3][i], times[4][i], what[i]); - } + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s", sptr, header); + for (i = 0; i < 3; ++i) + sendcmdto_one(&me, CMD_NOTICE, sptr, + "%C :%4d.%1d %4d.%1d %4d %4d %4d %s", sptr, + times[0][i] / 10, times[0][i] % 10, + times[1][i] / 10, times[1][i] % 10, + times[2][i], times[3][i], times[4][i], what[i]); } void initload(void) diff --git a/ircd/whocmds.c b/ircd/whocmds.c index a7c121f..c06a3af 100644 --- a/ircd/whocmds.c +++ b/ircd/whocmds.c @@ -29,6 +29,7 @@ #include "hash.h" #include "ircd.h" #include "ircd_chattr.h" +#include "ircd_reply.h" #include "ircd_string.h" #include "list.h" #include "match.h" @@ -219,7 +220,6 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, need to terminate buf1 */ *p1 = '\0'; p1 = buf1; - sendto_one(sptr, rpl_str(fields ? RPL_WHOSPCRPL : RPL_WHOREPLY), - me.name, sptr->name, ++p1); + send_reply(sptr, fields ? RPL_WHOSPCRPL : RPL_WHOREPLY, ++p1); } -- 2.20.1