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.
#
#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
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 */
ircd_relay.c \
ircd_reply.c \
ircd_signal.c \
+ ircd_snprintf.c \
ircd_string.c \
ircd_xopen.c \
jupe.c \
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
../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 \
../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 \
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
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;
}
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 */
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);
}
}
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;
}
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;
#include "hash.h"
#include "ircd.h"
#include "ircd_alloc.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "match.h"
#include "msg.h"
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
*/
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;
}
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);
}
}
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;
}
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,
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;
}
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
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;
}
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]);
struct User* user = sptr->user;
char ip_base64[8];
char featurebuf[512];
+ struct Gline* gline;
user->last = CurrentTime;
parv[0] = sptr->name;
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);
if (IsServer(sptr)) {
int i;
const char* p;
- struct Gline *gline;
/*
* A server introducing a new client, change source
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]) {
#include "class.h"
#include "client.h"
#include "ircd.h"
+#include "ircd_snprintf.h"
#include "ircd_string.h"
#include "list.h"
#include "match.h"
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)
{
}
+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()
*