From: Kevin L. Mitchell Date: Fri, 29 Jun 2001 15:51:03 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=56f512008e81aeae915b2b7f6bcdd54b549188d3;hp=03c46045d7842ef91735201a7ec14f229bc47c12;p=ircu2.10.12-pk.git Author: Kev Log message: Write doc/readme.chroot; remove a bunch of code commented out with #if 0; remove the last vestiges of sprintf_irc() and use ircd_snprintf() instead. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@523 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 75257b5..41d6e87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,199 @@ +2001-06-29 Kevin L. Mitchell + + * ircd/whocmds.c (do_who): use ircd_snprintf() instead of + sprintf_irc(); it's a bit hackish, but it'll do for now + + * ircd/support.c: remove unused #include + + * ircd/send.c: remove unused #include + + * ircd/s_user.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/s_serv.c: remove unused #include + + * ircd/s_misc.c: use ircd_snprintf() and friends instead of + sprintf_irc() and friends + + * ircd/s_err.c: moved atoi_tab[] from ircd/sprintf_irc.c to + ircd/s_err.c, which is the only other file to refer to it + + * ircd/s_conf.c (conf_add_deny): use ircd_snprintf() instead of + sprintf_irc() + + * ircd/s_bsd.c (connect_server): use ircd_snprintf() instead of + sprintf_irc() + + * ircd/s_auth.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/res.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/m_version.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/m_kill.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/listener.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/gline.c: use ircd_snprintf() instead of sprintf_irc() + + * ircd/channel.c: don't include sprintf_irc.h; use ircd_snprintf() + instead of sprintf_irc() + + * ircd/Makefile.in: remove sprintf_irc.c from sources list; run + make depend + + * include/ircd_string.h: remove declaration of sprintf_irc() (what + was it doing here anyway?) + + * include/sprintf_irc.h: removed unneeded source file + + * ircd/sprintf_irc.c: removed unneeded source file + + * ircd/s_debug.c (count_memory): remove some dead code + + * ircd/s_auth.c: remove some dead code + + * ircd/res.c (update_list): remove some dead code + + * ircd/m_whowas.c: remove some dead code + + * ircd/m_whois.c: remove some dead code + + * ircd/m_who.c: remove some dead code + + * ircd/m_wallusers.c: remove some dead code + + * ircd/m_wallops.c: remove some dead code + + * ircd/m_wallchops.c: remove some dead code + + * ircd/m_version.c: remove some dead code + + * ircd/m_userip.c: remove some dead code + + * ircd/m_userhost.c: remove some dead code + + * ircd/m_uping.c: remove some dead code + + * ircd/m_trace.c: remove some dead code + + * ircd/m_topic.c: remove some dead code + + * ircd/m_tmpl.c: remove some dead code + + * ircd/m_time.c: remove some dead code + + * ircd/m_squit.c: remove some dead code + + * ircd/m_silence.c: remove some dead code + + * ircd/m_settime.c: remove some dead code + + * ircd/m_set.c: remove some dead code + + * ircd/m_server.c: remove some dead code + + * ircd/m_rpong.c: remove some dead code + + * ircd/m_rping.c: remove some dead code + + * ircd/m_restart.c: remove some dead code + + * ircd/m_reset.c: remove some dead code + + * ircd/m_rehash.c: remove some dead code + + * ircd/m_quit.c: remove some dead code + + * ircd/m_proto.c: remove some dead code + + * ircd/m_privs.c: remove some dead code + + * ircd/m_privmsg.c: remove some dead code + + * ircd/m_pong.c: remove some dead code + + * ircd/m_ping.c: remove some dead code + + * ircd/m_pass.c: remove some dead code + + * ircd/m_part.c: remove some dead code + + * ircd/m_opmode.c: remove some dead code + + * ircd/m_oper.c: remove some dead code + + * ircd/m_notice.c: remove some dead code + + * ircd/m_nick.c: remove some dead code + + * ircd/m_map.c: remove some dead code + + * ircd/m_lusers.c: remove some dead code + + * ircd/m_list.c: remove some dead code + + * ircd/m_links.c: remove some dead code + + * ircd/m_kill.c: remove some dead code + + * ircd/m_kick.c: remove some dead code + + * ircd/m_jupe.c: remove some dead code + + * ircd/m_join.c: remove some dead code + + * ircd/m_ison.c: remove some dead code + + * ircd/m_invite.c: remove some dead code + + * ircd/m_info.c: remove some dead code + + * ircd/m_help.c: remove some dead code + + * ircd/m_gline.c: remove some dead code + + * ircd/m_get.c: remove some dead code + + * ircd/m_error.c: remove some dead code + + * ircd/m_endburst.c: remove some dead code + + * ircd/m_die.c: remove some dead code + + * ircd/m_desynch.c: remove some dead code + + * ircd/m_destruct.c: remove some dead code + + * ircd/m_defaults.c: remove some dead code + + * ircd/m_create.c: remove some dead code, along with an #if 1 + + * ircd/m_cprivmsg.c: remove some dead code + + * ircd/m_connect.c: remove some dead code + + * ircd/m_close.c: remove some dead code + + * ircd/m_clearmode.c: remove some dead code + + * ircd/m_burst.c: remove some dead code + + * ircd/m_away.c: remove some dead code + + * ircd/m_admin.c: remove some dead code + + * ircd/listener.c (accept_connection): remove some dead code + + * ircd/ircd_reply.c (need_more_params): remove some dead code + + * ircd/channel.c (add_banid): remove some dead code + + * include/support.h: remove some dead code + + * include/querycmds.h: remove some dead code + + * doc/readme.chroot: document how to do chroot operation + 2001-06-28 Kevin L. Mitchell * ircd/Makefile.in: tune for VPATH builds/installs; add a rule to diff --git a/doc/readme.chroot b/doc/readme.chroot new file mode 100644 index 0000000..2c42cac --- /dev/null +++ b/doc/readme.chroot @@ -0,0 +1,91 @@ +Using Chroot With IRCD + +Introduction + +Many system administrators like to run certain daemons within a +"jail," a secure area of the file system that the daemon supposedly +cannot break out of. That way, if the daemon is compromised somehow, +the attacker cannot get out and affect the rest of the system in any +way. There are problems with this--the standard UNIX way of doing +this is with the chroot() call, which has been deprecated by the +UNIX98 standard. Moreover, if an attacker has root within the jail, +it is trivial to get *out* of the jail in most circumstances. +Nevertheless, it is still often a good idea, and some systems can use +more secure jails than other systems. + +Older versions of ircd supported chroot() operation within the server +itself, but these were fraught with problems--chroot() can only be +called by a process running as root, so ircd had to be started as +root, typically by making it setuid, and would then have to drop those +privileges after calling chroot(). Moreover, the design of the server +would require that the server binary be in DPATH, or the /RESTART +command would not work. In fact, /RESTART still wouldn't work, +because the server would then attempt to change directories to a DPATH +relative to the current root directory--and of course, the root +directory often would not contain the shared libraries necessary for +the ircd to even start. + +Configuring the Server For Use With Chroot + +In the versions of ircd starting with u2.10.11, all the setuid and +chroot() code has been removed from the server. It is still possible +to cause the daemon to run in a chroot() jail, however, through the +use of a wrapper script. This requires making all paths compiled in +to the server be relative to the new root directory; fortunately, this +can be done by giving the configure script the --with-chroot= +option. The argument specifies to configure where the root +directory will be, and the server restart path, data path, +configuration file, and debug log files will all be modified to be +relative to this root directory. If the data path or configuration +files cannot be made relative to the specified root directory, +configure will issue an error message and exit; if the server restart +path is not relative to the specified root directory, configure will +issue a warning. + +The various paths are made relative to the root directory through the +use of simple edits to their string representation. As an example, +assume that we will be using the root directory "/home/ircd"; if the +data path is "/home/ircd/lib," the data path that will be compiled +into the server will be simply "/lib"; if, on the other hand, the +specified data path were "/usr/local/lib/ircd," configure would issue +an error, since there is no way to make the data path relative to the +specified root directory. + +Preparing the Root Directory + +Most modern operating systems use shared libraries. When using +chroot(), these libraries are searched for relative to the new root +directory, and they must be present in order for a program to +execute. The root directory must be prepared, therefore, by coping +these libraries into the correct place. A script for this purpose has +been provided in tools/mkchroot. This script relies on the command +"ldd," which is used to report which shared libraries are used by a +particular program; it also relies on ldd printing out the full path +to those libraries. If either of these conditions is not met, it will +be necessary to track down the libraries by hand and place them into +the appropriate locations. The tools/mkchroot script takes as its +first argument the path to the directory to be prepared as a root +directory; following this argument should be a list of programs that +will be running with that directory as the root directory. + +Using the Wrapper + +Also provided in the tools subdirectory are the sources for a simple +wrapper program that can be used to start ircd. The program can be +compiled by executing "cc -o wrapper tools/wrapper.c"; it must be run +as root, but do not install it as root, since that would be a major +security risk. This tool can be used to set the hard limit on file +descriptors, as well as a root directory, and so may be useful to the +administrator even if chroot() operation is not desired. A summary of +the command line options for the wrapper tool can be obtained with the +"-h" option. To set the file descriptor limit, use the "-l" option +followed by the desired number of file descriptors; to select an +alternative root directory, use "-c" followed by the desired root +directory. You must use the "-u" option to specify a user name (or +user ID) that the command should be run as; otherwise, the command +will be run as root, which is not what you want (and why you should +never install this program setuid root). Follow the command line +arguments with "--" and the full path to the command that you wish to +run, along with arguments to that command. The "--" tells the wrapper +program to stop interpreting options, and is very important if you +must give the command any options. diff --git a/include/ircd_string.h b/include/ircd_string.h index d7b97c6..3f97249 100644 --- a/include/ircd_string.h +++ b/include/ircd_string.h @@ -33,8 +33,6 @@ extern const char* ircd_ntoa_r(char* buf, const char* addr); extern char* host_from_uh(char* buf, const char* userhost, size_t len); extern char* ircd_strtok(char** save, char* str, char* fs); -extern char* sprintf_irc(char* str, const char* format, ...); - extern char* canonize(char* buf); #define DupString(x, y) (strcpy((x = (char*) MyMalloc(strlen(y) + 1)), y)) diff --git a/include/querycmds.h b/include/querycmds.h index 621d888..3ebdaa5 100644 --- a/include/querycmds.h +++ b/include/querycmds.h @@ -43,9 +43,6 @@ extern struct UserStatistics UserStats; /* Macros for remote connections: */ #define Count_newremoteclient(UserStats, cptr) (++UserStats.clients, ++(cli_serv(cptr)->clients)) #define Count_newremoteserver(UserStats) (++UserStats.servers) -#if 0 -#define Count_remoteclientquits(UserStats) (--UserStats.clients) -#endif #define Count_remoteclientquits(UserStats,cptr) \ do { \ diff --git a/include/sprintf_irc.h b/include/sprintf_irc.h deleted file mode 100644 index 0a8042d..0000000 --- a/include/sprintf_irc.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * sprintf_irc.h - * - * $Id$ - */ -#ifndef INCLUDED_sprintf_irc_h -#define INCLUDED_sprintf_irc_h -#ifndef INCLUDED_stdarg_h -#include -#define INCLUDED_stdarg_h -#endif - -/* - * Proto types - */ - -extern char *vsprintf_irc(char *str, const char *format, va_list); -extern char *sprintf_irc(char *str, const char *format, ...); -extern const char atoi_tab[4000]; - -#endif /* INCLUDED_sprintf_irc_h */ diff --git a/include/support.h b/include/support.h index a580989..1ac7e78 100644 --- a/include/support.h +++ b/include/support.h @@ -5,12 +5,6 @@ */ #ifndef INCLUDED_support_h #define INCLUDED_support_h -#if 0 -#ifndef INCLUDED_sys_types_h -#include /* broken BSD system headers */ -#define INCLUDED_sys_types_h -#endif -#endif /* 0 */ /* * Given a number of bits, make a netmask out of it. diff --git a/ircd/Makefile.in b/ircd/Makefile.in index d803749..ad6ddf1 100644 --- a/ircd/Makefile.in +++ b/ircd/Makefile.in @@ -189,7 +189,6 @@ IRCD_SRC = \ s_stats.c \ s_user.c \ send.c \ - sprintf_irc.c \ support.c \ uping.c \ userload.c \ @@ -355,8 +354,8 @@ channel.o: channel.c ../config.h ../include/channel.h \ ../include/match.h ../include/msg.h ../include/numeric.h \ ../include/numnicks.h ../include/querycmds.h ../include/s_bsd.h \ ../include/s_conf.h ../include/s_debug.h ../include/s_misc.h \ - ../include/s_user.h ../include/send.h ../include/sprintf_irc.h \ - ../include/support.h ../include/sys.h ../include/whowas.h + ../include/s_user.h ../include/send.h ../include/support.h \ + ../include/sys.h ../include/whowas.h class.o: class.c ../config.h ../include/class.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/ircd.h \ @@ -491,10 +490,10 @@ listener.o: listener.c ../config.h ../include/listener.h \ ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \ ../include/ircd.h ../include/struct.h ../include/ircd_alloc.h \ ../include/fda.h ../include/ircd_features.h ../include/ircd_osdep.h \ - ../include/ircd_reply.h ../include/ircd_string.h \ - ../include/ircd_chattr.h ../include/numeric.h ../include/s_bsd.h \ - ../include/s_conf.h ../include/s_misc.h ../include/send.h \ - ../include/sprintf_irc.h ../include/sys.h + ../include/ircd_reply.h ../include/ircd_snprintf.h \ + ../include/ircd_string.h ../include/ircd_chattr.h \ + ../include/numeric.h ../include/s_bsd.h ../include/s_conf.h \ + ../include/s_misc.h ../include/send.h ../include/sys.h m_admin.o: m_admin.c ../config.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/hash.h \ @@ -667,10 +666,10 @@ m_kill.o: m_kill.c ../config.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/hash.h \ ../include/ircd.h ../include/struct.h ../include/ircd_log.h \ - ../include/ircd_reply.h ../include/ircd_string.h \ - ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \ - ../include/numnicks.h ../include/s_misc.h ../include/send.h \ - ../include/whowas.h + ../include/ircd_reply.h ../include/ircd_snprintf.h \ + ../include/ircd_string.h ../include/ircd_chattr.h ../include/msg.h \ + ../include/numeric.h ../include/numnicks.h ../include/s_misc.h \ + ../include/send.h ../include/whowas.h m_links.o: m_links.c ../config.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/ircd.h \ @@ -956,10 +955,11 @@ m_version.o: m_version.c ../config.h ../include/client.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/hash.h \ ../include/ircd.h ../include/struct.h ../include/ircd_features.h \ ../include/ircd_policy.h ../include/ircd_reply.h \ - ../include/ircd_string.h ../include/ircd_chattr.h ../include/msg.h \ - ../include/numeric.h ../include/numnicks.h ../include/s_debug.h \ - ../include/s_user.h ../include/send.h ../include/supported.h \ - ../include/channel.h ../include/version.h + ../include/ircd_snprintf.h ../include/ircd_string.h \ + ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \ + ../include/numnicks.h ../include/s_debug.h ../include/s_user.h \ + ../include/send.h ../include/supported.h ../include/channel.h \ + ../include/version.h m_wallchops.o: m_wallchops.c ../config.h ../include/channel.h \ ../include/ircd_defs.h ../include/client.h ../include/dbuf.h \ ../include/msgq.h ../include/ircd_events.h ../include/ircd_handler.h \ @@ -1062,34 +1062,36 @@ res.o: res.c ../config.h ../include/res.h ../include/client.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/ircd.h \ ../include/struct.h ../include/ircd_alloc.h ../include/fda.h \ ../include/ircd_log.h ../include/ircd_osdep.h ../include/ircd_reply.h \ - ../include/ircd_string.h ../include/ircd_chattr.h ../include/msg.h \ - ../include/numeric.h ../include/s_bsd.h ../include/s_debug.h \ - ../include/s_misc.h ../include/send.h ../include/sprintf_irc.h \ - ../include/support.h ../include/sys.h + ../include/ircd_snprintf.h ../include/ircd_string.h \ + ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \ + ../include/s_bsd.h ../include/s_debug.h ../include/s_misc.h \ + ../include/send.h ../include/support.h ../include/sys.h s_auth.o: s_auth.c ../config.h ../include/s_auth.h \ ../include/ircd_events.h ../include/client.h ../include/ircd_defs.h \ ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h \ ../include/IPcheck.h ../include/ircd.h ../include/struct.h \ ../include/ircd_alloc.h ../include/fda.h ../include/ircd_chattr.h \ ../include/ircd_features.h ../include/ircd_log.h \ - ../include/ircd_osdep.h ../include/ircd_string.h ../include/list.h \ - ../include/numeric.h ../include/querycmds.h ../include/res.h \ - ../include/s_bsd.h ../include/s_debug.h ../include/s_misc.h \ - ../include/send.h ../include/sprintf_irc.h ../include/sys.h + ../include/ircd_osdep.h ../include/ircd_snprintf.h \ + ../include/ircd_string.h ../include/list.h ../include/numeric.h \ + ../include/querycmds.h ../include/res.h ../include/s_bsd.h \ + ../include/s_debug.h ../include/s_misc.h ../include/send.h \ + ../include/sys.h s_bsd.o: s_bsd.c ../config.h ../include/s_bsd.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h \ ../include/IPcheck.h ../include/channel.h ../include/class.h \ ../include/hash.h ../include/ircd_log.h ../include/ircd_features.h \ ../include/ircd_osdep.h ../include/ircd_reply.h \ - ../include/ircd_string.h ../include/ircd_chattr.h ../include/ircd.h \ - ../include/struct.h ../include/list.h ../include/listener.h \ - ../include/msg.h ../include/numeric.h ../include/numnicks.h \ - ../include/packet.h ../include/parse.h ../include/querycmds.h \ - ../include/res.h ../include/s_auth.h ../include/s_conf.h \ - ../include/s_debug.h ../include/s_misc.h ../include/s_user.h \ - ../include/send.h ../include/sprintf_irc.h ../include/support.h \ - ../include/sys.h ../include/uping.h ../include/version.h + ../include/ircd_snprintf.h ../include/ircd_string.h \ + ../include/ircd_chattr.h ../include/ircd.h ../include/struct.h \ + ../include/list.h ../include/listener.h ../include/msg.h \ + ../include/numeric.h ../include/numnicks.h ../include/packet.h \ + ../include/parse.h ../include/querycmds.h ../include/res.h \ + ../include/s_auth.h ../include/s_conf.h ../include/s_debug.h \ + ../include/s_misc.h ../include/s_user.h ../include/send.h \ + ../include/support.h ../include/sys.h ../include/uping.h \ + ../include/version.h s_conf.o: s_conf.c ../config.h ../include/s_conf.h \ ../include/IPcheck.h ../include/class.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ @@ -1103,7 +1105,7 @@ s_conf.o: s_conf.c ../config.h ../include/s_conf.h \ ../include/numeric.h ../include/numnicks.h ../include/opercmds.h \ ../include/parse.h ../include/res.h ../include/s_bsd.h \ ../include/s_debug.h ../include/s_misc.h ../include/send.h \ - ../include/sprintf_irc.h ../include/support.h ../include/sys.h + ../include/support.h ../include/sys.h s_debug.o: s_debug.c ../config.h ../include/s_debug.h \ ../include/ircd_defs.h ../include/channel.h ../include/class.h \ ../include/client.h ../include/dbuf.h ../include/msgq.h \ @@ -1115,20 +1117,20 @@ s_debug.o: s_debug.c ../config.h ../include/s_debug.h \ ../include/s_bsd.h ../include/s_conf.h ../include/send.h \ ../include/sys.h ../include/whowas.h s_err.o: s_err.c ../config.h ../include/numeric.h ../include/s_debug.h \ - ../include/ircd_defs.h ../include/sprintf_irc.h + ../include/ircd_defs.h s_misc.o: s_misc.c ../config.h ../include/s_misc.h \ ../include/IPcheck.h ../include/channel.h ../include/ircd_defs.h \ ../include/client.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/hash.h \ ../include/ircd.h ../include/struct.h ../include/ircd_alloc.h \ ../include/fda.h ../include/ircd_log.h ../include/ircd_policy.h \ - ../include/ircd_reply.h ../include/ircd_string.h \ - ../include/ircd_chattr.h ../include/list.h ../include/match.h \ - ../include/msg.h ../include/numeric.h ../include/numnicks.h \ - ../include/parse.h ../include/querycmds.h ../include/ircd_features.h \ - ../include/res.h ../include/s_bsd.h ../include/s_conf.h \ - ../include/s_debug.h ../include/s_user.h ../include/send.h \ - ../include/sprintf_irc.h ../include/support.h ../include/sys.h \ + ../include/ircd_reply.h ../include/ircd_snprintf.h \ + ../include/ircd_string.h ../include/ircd_chattr.h ../include/list.h \ + ../include/match.h ../include/msg.h ../include/numeric.h \ + ../include/numnicks.h ../include/parse.h ../include/querycmds.h \ + ../include/ircd_features.h ../include/res.h ../include/s_bsd.h \ + ../include/s_conf.h ../include/s_debug.h ../include/s_user.h \ + ../include/send.h ../include/support.h ../include/sys.h \ ../include/uping.h ../include/userload.h s_numeric.o: s_numeric.c ../config.h ../include/s_numeric.h \ ../include/channel.h ../include/ircd_defs.h ../include/client.h \ @@ -1148,8 +1150,8 @@ s_serv.o: s_serv.c ../config.h ../include/s_serv.h \ ../include/numeric.h ../include/numnicks.h ../include/parse.h \ ../include/querycmds.h ../include/ircd_features.h ../include/s_bsd.h \ ../include/s_conf.h ../include/s_debug.h ../include/s_misc.h \ - ../include/s_user.h ../include/send.h ../include/sprintf_irc.h \ - ../include/sys.h ../include/userload.h + ../include/s_user.h ../include/send.h ../include/sys.h \ + ../include/userload.h s_stats.o: s_stats.c ../config.h ../include/s_stats.h \ ../include/class.h ../include/client.h ../include/ircd_defs.h \ ../include/dbuf.h ../include/msgq.h ../include/ircd_events.h \ @@ -1167,12 +1169,12 @@ s_user.o: s_user.c ../config.h ../include/s_user.h \ ../include/ircd_alloc.h ../include/fda.h ../include/ircd_chattr.h \ ../include/ircd_features.h ../include/ircd_log.h \ ../include/ircd_policy.h ../include/ircd_reply.h \ - ../include/ircd_string.h ../include/list.h ../include/match.h \ - ../include/motd.h ../include/msg.h ../include/numeric.h \ - ../include/numnicks.h ../include/parse.h ../include/querycmds.h \ - ../include/random.h ../include/s_bsd.h ../include/s_conf.h \ - ../include/s_debug.h ../include/s_misc.h ../include/s_serv.h \ - ../include/send.h ../include/sprintf_irc.h ../include/support.h \ + ../include/ircd_snprintf.h ../include/ircd_string.h ../include/list.h \ + ../include/match.h ../include/motd.h ../include/msg.h \ + ../include/numeric.h ../include/numnicks.h ../include/parse.h \ + ../include/querycmds.h ../include/random.h ../include/s_bsd.h \ + ../include/s_conf.h ../include/s_debug.h ../include/s_misc.h \ + ../include/s_serv.h ../include/send.h ../include/support.h \ ../include/supported.h ../include/sys.h ../include/userload.h \ ../include/version.h ../include/whowas.h ../include/handlers.h send.o: send.c ../config.h ../include/send.h ../include/channel.h \ @@ -1183,14 +1185,12 @@ send.o: send.c ../config.h ../include/send.h ../include/channel.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 ../config.h ../include/sprintf_irc.h \ ../include/sys.h support.o: support.c ../config.h ../include/support.h \ ../include/fileio.h ../include/ircd.h ../include/struct.h \ ../include/ircd_defs.h ../include/ircd_chattr.h \ ../include/ircd_snprintf.h ../include/s_bsd.h ../include/s_debug.h \ - ../include/send.h ../include/sprintf_irc.h ../include/sys.h + ../include/send.h ../include/sys.h uping.o: uping.c ../config.h ../include/uping.h ../include/ircd_defs.h \ ../include/ircd_events.h ../include/client.h ../include/dbuf.h \ ../include/msgq.h ../include/ircd_handler.h ../include/ircd.h \ @@ -1218,9 +1218,9 @@ whocmds.o: whocmds.c ../config.h ../include/whocmds.h \ ../include/numeric.h ../include/numnicks.h ../include/querycmds.h \ ../include/ircd_features.h ../include/random.h ../include/s_bsd.h \ ../include/s_conf.h ../include/s_misc.h ../include/s_user.h \ - ../include/send.h ../include/sprintf_irc.h ../include/support.h \ - ../include/sys.h ../include/userload.h ../include/version.h \ - ../include/whowas.h ../include/msg.h + ../include/send.h ../include/support.h ../include/sys.h \ + ../include/userload.h ../include/version.h ../include/whowas.h \ + ../include/msg.h whowas.o: whowas.c ../config.h ../include/whowas.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/ircd.h \ diff --git a/ircd/channel.c b/ircd/channel.c index d10e5c0..ea46920 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -47,7 +47,6 @@ #include "s_misc.h" #include "s_user.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "sys.h" @@ -169,7 +168,7 @@ static char *make_nick_user_host(const char *nick, const char *name, const char *host) { static char namebuf[NICKLEN + USERLEN + HOSTLEN + 3]; - sprintf_irc(namebuf, "%s!%s@%s", nick, name, host); + ircd_snprintf(0, namebuf, sizeof(namebuf), "%s!%s@%s", nick, name, host); return namebuf; } @@ -180,7 +179,8 @@ static char *make_nick_user_host(const char *nick, const char *name, static char *make_nick_user_ip(char *nick, char *name, struct in_addr ip) { static char ipbuf[NICKLEN + USERLEN + 16 + 3]; - sprintf_irc(ipbuf, "%s!%s@%s", nick, name, ircd_ntoa((const char*) &ip)); + ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%s!%s@%s", nick, name, + ircd_ntoa((const char*) &ip)); return ipbuf; } @@ -313,18 +313,10 @@ int add_banid(struct Client *cptr, struct Channel *chptr, char *banid, len -= strlen(tmp->value.ban.banstr); } *banp = tmp->next; -#if 0 - /* Silently remove overlapping bans */ - MyFree(tmp->value.ban.banstr); - MyFree(tmp->value.ban.who); - free_link(tmp); - tmp = 0; -#else /* These will be sent to the user later as -b */ tmp->next = removed_bans_list; removed_bans_list = tmp; removed_bans = 1; -#endif } else if (!(tmp->flags & CHFL_BURST_BAN_WIPEOUT)) { @@ -763,7 +755,7 @@ void channel_modes(struct Client *cptr, char *mbuf, char *pbuf, *mbuf++ = 'n'; if (chptr->mode.limit) { *mbuf++ = 'l'; - sprintf_irc(pbuf, "%d", chptr->mode.limit); + ircd_snprintf(0, pbuf, sizeof(pbuf), "%d", chptr->mode.limit); } if (*chptr->mode.key) { @@ -1480,7 +1472,7 @@ modebuf_flush_int(struct ModeBuf *mbuf, int all) } } else if (MB_TYPE(mbuf, i) & MODE_LIMIT) { /* if it's a limit, we also format the number */ - sprintf_irc(limitbuf, "%d", MB_UINT(mbuf, i)); + ircd_snprintf(0, limitbuf, sizeof(limitbuf), "%d", MB_UINT(mbuf, i)); tmp = strlen(limitbuf); diff --git a/ircd/gline.c b/ircd/gline.c index 7ed3f1c..403a1d4 100644 --- a/ircd/gline.c +++ b/ircd/gline.c @@ -145,7 +145,8 @@ make_gline(char *user, char *host, char *reason, time_t expire, time_t lastmod, else { gline->bits=bits2; } - sprintf_irc(ipname,"%d.%d.%d.%d",ad[0],ad[1],ad[2],ad[3]); + ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1], + ad[2], ad[3]); gline->ipnum.s_addr = inet_addr(ipname); Debug((DEBUG_DEBUG,"IP gline: %08x/%i",gline->ipnum.s_addr,gline->bits)); gline->gl_flags |= GLINE_IPMASK; diff --git a/ircd/ircd_reply.c b/ircd/ircd_reply.c index 0a25fe5..f4220ce 100644 --- a/ircd/ircd_reply.c +++ b/ircd/ircd_reply.c @@ -61,16 +61,6 @@ int protocol_violation(struct Client* cptr, const char* pattern, ...) int need_more_params(struct Client* cptr, const char* cmd) { -#if 0 - /* - * XXX - bug - * shouldn't try to do more than one thing at a time, - * call protocol_violation explicitly where it's needed and - * context is available. - */ - if (!MyUser(cptr)) - protocol_violation(cptr, "Not enough parameters for %s",cmd); -#endif send_reply(cptr, ERR_NEEDMOREPARAMS, cmd); return 0; } diff --git a/ircd/listener.c b/ircd/listener.c index f780287..e0f9213 100644 --- a/ircd/listener.c +++ b/ircd/listener.c @@ -28,13 +28,13 @@ #include "ircd_features.h" #include "ircd_osdep.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "numeric.h" #include "s_bsd.h" #include "s_conf.h" #include "s_misc.h" #include "send.h" -#include "sprintf_irc.h" #include "sys.h" /* MAXCLIENTS */ #include @@ -90,7 +90,7 @@ const char* get_listener_name(const struct Listener* listener) { static char buf[HOSTLEN + PORTNAMELEN + 4]; assert(0 != listener); - sprintf_irc(buf, "%s:%u", cli_name(&me), listener->port); + ircd_snprintf(0, buf, sizeof(buf), "%s:%u", cli_name(&me), listener->port); return buf; } @@ -275,7 +275,8 @@ static void set_listener_mask(struct Listener* listener, const char* mask) * easy conversion of "*" 0.0.0.0 or 134.* to 134.0.0.0 :-) */ sscanf(mask, "%d.%d.%d.%d", &ad[0], &ad[1], &ad[2], &ad[3]); - sprintf_irc(ipname, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]); + ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1], ad[2], + ad[3]); listener->mask.s_addr = inet_addr(ipname); } @@ -480,17 +481,6 @@ static void accept_connection(struct Event* ev) close(fd); return; } -#if 0 - /* - * check conf for ip address access - */ - if (!conf_connect_allowed(addr.sin_addr)) { - ++ServerStats->is_ref; - send(fd, "ERROR :Not authorized\r\n", 23, 0); - close(fd); - return; - } -#endif ++ServerStats->is_ac; /* nextping = CurrentTime; */ diff --git a/ircd/m_admin.c b/ircd/m_admin.c index f1c5fbb..3fed22c 100644 --- a/ircd/m_admin.c +++ b/ircd/m_admin.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_away.c b/ircd/m_away.c index ebd3cf7..cf4efe0 100644 --- a/ircd/m_away.c +++ b/ircd/m_away.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_alloc.h" diff --git a/ircd/m_burst.c b/ircd/m_burst.c index 1d4c1ec..498b64d 100644 --- a/ircd/m_burst.c +++ b/ircd/m_burst.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_clearmode.c b/ircd/m_clearmode.c index d71708e..cbd961f 100644 --- a/ircd/m_clearmode.c +++ b/ircd/m_clearmode.c @@ -82,14 +82,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "channel.h" #include "hash.h" diff --git a/ircd/m_close.c b/ircd/m_close.c index 9f87177..b121a83 100644 --- a/ircd/m_close.c +++ b/ircd/m_close.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_reply.h" diff --git a/ircd/m_connect.c b/ircd/m_connect.c index 5e372d4..0a067e5 100644 --- a/ircd/m_connect.c +++ b/ircd/m_connect.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "crule.h" #include "hash.h" diff --git a/ircd/m_cprivmsg.c b/ircd/m_cprivmsg.c index 9c81c4a..f714d8f 100644 --- a/ircd/m_cprivmsg.c +++ b/ircd/m_cprivmsg.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" diff --git a/ircd/m_create.c b/ircd/m_create.c index 26a4b9c..fcedeb0 100644 --- a/ircd/m_create.c +++ b/ircd/m_create.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" @@ -140,18 +132,9 @@ int ms_create(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) MAGIC_REMOTE_JOIN_TS != chanTS) cli_serv(cli_user(sptr)->server)->lag = TStime() - chanTS; -#if 1 /* If this server is >5 minutes fast, squit it */ if (TStime() - chanTS<-5*60*60) return exit_client(sptr, sptr, &me, "Timestamp Drift/Bogus TS"); -#endif -#if 0 - /* If we recieve a CREATE for a channel from a server before that server - * was linked, then it's a HACK - */ - if (MyConnect(sptr) && chanTS 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>"; - - Debug((DEBUG_ERROR, "Received ERROR message from %s: %s", sptr->name, para)); - /* - * Ignore error messages generated by normal user clients - * (because ill-behaving user clients would flood opers - * screen otherwise). Pass ERROR's from other sources to - * the local operator... - */ - if (IsUser(cptr)) - return 0; - if (IsUnknown(cptr)) - return exit_client_msg(cptr, cptr, &me, "Register first"); - - if (cptr == sptr) - sendto_ops("ERROR :from %s -- %s", cptr->name, para); /* XXX DEAD */ - else - sendto_ops("ERROR :from %s via %s -- %s", sptr->name, cptr->name, para); /* XXX DEAD */ - - if (sptr->serv) - { - MyFree(sptr->serv->last_error_msg); - DupString(sptr->serv->last_error_msg, para); - } - - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_get.c b/ircd/m_get.c index e136577..2982995 100644 --- a/ircd/m_get.c +++ b/ircd/m_get.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_gline.c b/ircd/m_gline.c index a0f8b22..e0d0f9a 100644 --- a/ircd/m_gline.c +++ b/ircd/m_gline.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "gline.h" #include "hash.h" diff --git a/ircd/m_help.c b/ircd/m_help.c index 3e63723..1c09943 100644 --- a/ircd/m_help.c +++ b/ircd/m_help.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_info.c b/ircd/m_info.c index e98639c..952e1c3 100644 --- a/ircd/m_info.c +++ b/ircd/m_info.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_reply.h" diff --git a/ircd/m_invite.c b/ircd/m_invite.c index ae9be82..4134bce 100644 --- a/ircd/m_invite.c +++ b/ircd/m_invite.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_ison.c b/ircd/m_ison.c index 9968a44..1dfa6f2 100644 --- a/ircd/m_ison.c +++ b/ircd/m_ison.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_join.c b/ircd/m_join.c index 82f3655..9381d2d 100644 --- a/ircd/m_join.c +++ b/ircd/m_join.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "gline.h" diff --git a/ircd/m_jupe.c b/ircd/m_jupe.c index f49cb61..418efea 100644 --- a/ircd/m_jupe.c +++ b/ircd/m_jupe.c @@ -82,14 +82,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "jupe.h" #include "hash.h" diff --git a/ircd/m_kick.c b/ircd/m_kick.c index 86e7af8..1951dd7 100644 --- a/ircd/m_kick.c +++ b/ircd/m_kick.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_kill.c b/ircd/m_kill.c index f7b8bf2..10ace4a 100644 --- a/ircd/m_kill.c +++ b/ircd/m_kill.c @@ -81,19 +81,12 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" #include "ircd_log.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "msg.h" #include "numeric.h" @@ -216,7 +209,7 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } else killer = path; - sprintf_irc(buf, "Killed (%s)", killer); + ircd_snprintf(0, buf, sizeof(buf), "Killed (%s)", killer); return exit_client(cptr, victim, sptr, buf); } @@ -299,8 +292,8 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) inpath = cli_user(sptr)->host; - sprintf_irc(buf, - "%s%s (%s)", cli_name(cptr), IsOper(sptr) ? "" : "(L)", comment); + ircd_snprintf(0, buf, sizeof(buf), "%s%s (%s)", cli_name(cptr), + IsOper(sptr) ? "" : "(L)", comment); path = buf; /* @@ -333,7 +326,8 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ cli_flags(victim) |= FLAGS_KILLED; - sprintf_irc(buf, "Killed by %s (%s)", cli_name(sptr), comment); + ircd_snprintf(0, buf, sizeof(buf), "Killed by %s (%s)", cli_name(sptr), + comment); } else { /* @@ -343,7 +337,8 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * anyway (as this user don't exist there any more either) */ sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s!%s", victim, inpath, path); - sprintf_irc(buf, "Local kill by %s (%s)", cli_name(sptr), comment); + ircd_snprintf(0, buf, sizeof(buf), "Local kill by %s (%s)", + cli_name(sptr), comment); } return exit_client(cptr, victim, sptr, buf); diff --git a/ircd/m_links.c b/ircd/m_links.c index 61d1501..7814a51 100644 --- a/ircd/m_links.c +++ b/ircd/m_links.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_policy.h" @@ -203,56 +195,3 @@ int ms_links(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(sptr, RPL_ENDOFLINKS, BadPtr(mask) ? "*" : mask); return 0; } - - -#if 0 -/* - * m_links - * - * parv[0] = sender prefix - * parv[1] = servername mask - * - * or - * - * parv[0] = sender prefix - * parv[1] = server to query - * parv[2] = servername mask - */ -int m_links(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char *mask; - struct Client *acptr; - - if (parc > 2) - { - if (hunt_server(1, cptr, sptr, "%s%s LINKS %s :%s", 1, parc, parv) != /* XXX DEAD */ - HUNTED_ISME) - return 0; - mask = parv[2]; - } - else - mask = parc < 2 ? 0 : parv[1]; - - for (acptr = GlobalClientList, collapse(mask); acptr; acptr = acptr->next) - { - if (!IsServer(acptr) && !IsMe(acptr)) - continue; - if (!BadPtr(mask) && match(mask, acptr->name)) - continue; - sendto_one(sptr, rpl_str(RPL_LINKS), /* XXX DEAD */ - me.name, parv[0], acptr->name, acptr->serv->up->name, -#ifndef GODMODE - acptr->hopcount, acptr->serv->prot, -#else /* GODMODE */ - acptr->hopcount, acptr->serv->prot, acptr->serv->timestamp, - NumServ(acptr), -#endif /* GODMODE */ - (acptr->info[0] ? acptr->info : "(Unknown Location)")); - } - - sendto_one(sptr, rpl_str(RPL_ENDOFLINKS), me.name, parv[0], /* XXX DEAD */ - BadPtr(mask) ? "*" : mask); - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_list.c b/ircd/m_list.c index e4c3a5d..dc71963 100644 --- a/ircd/m_list.c +++ b/ircd/m_list.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_lusers.c b/ircd/m_lusers.c index d06ffdb..02da8d7 100644 --- a/ircd/m_lusers.c +++ b/ircd/m_lusers.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_policy.h" @@ -169,46 +161,3 @@ int ms_lusers(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - - -#if 0 -/* - * m_lusers - * - * parv[0] = sender - * parv[1] = ignored - * parv[2] = server to query - */ -int m_lusers(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - int longoutput = MyUser(sptr) || IsOper(sptr); - if (parc > 2) - if (hunt_server(0, cptr, sptr, "%s%s " TOK_LUSERS " %s :%s", 2, parc, parv) != /* XXX DEAD */ - HUNTED_ISME) - return 0; - - sendto_one(sptr, rpl_str(RPL_LUSERCLIENT), me.name, parv[0], /* XXX DEAD */ - UserStats.clients - UserStats.inv_clients, UserStats.inv_clients, UserStats.servers); - if (longoutput && UserStats.opers) - sendto_one(sptr, rpl_str(RPL_LUSEROP), me.name, parv[0], UserStats.opers); /* XXX DEAD */ - if (UserStats.unknowns > 0) - sendto_one(sptr, rpl_str(RPL_LUSERUNKNOWN), me.name, parv[0], /* XXX DEAD */ - UserStats.unknowns); - if (longoutput && UserStats.channels > 0) - sendto_one(sptr, rpl_str(RPL_LUSERCHANNELS), me.name, parv[0], /* XXX DEAD */ - UserStats.channels); - sendto_one(sptr, rpl_str(RPL_LUSERME), me.name, parv[0], UserStats.local_clients, /* XXX DEAD */ - UserStats.local_servers); - - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, /* XXX DEAD */ - ":%s NOTICE %s :Highest connection count: %d (%d clients)", - me.name, parv[0], max_connection_count, max_client_count); - else - sendto_one(sptr, /* XXX DEAD */ - "%s NOTICE %s%s :Highest connection count: %d (%d clients)", - NumServ(&me), NumNick(sptr), max_connection_count, max_client_count); - - return 0; -} -#endif /* 0 */ diff --git a/ircd/m_map.c b/ircd/m_map.c index 74ed166..bf0da2e 100644 --- a/ircd/m_map.c +++ b/ircd/m_map.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_policy.h" @@ -188,23 +180,3 @@ int m_map_redirect(struct Client* cptr, struct Client* sptr, int parc, return 0; } #endif - -#if 0 -/* - * m_map -- by Run - * - * parv[0] = sender prefix - * parv[1] = server mask - */ -int m_map(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - if (parc < 2) - parv[1] = "*"; - - dump_map(sptr, &me, parv[1], 0); - sendto_one(sptr, rpl_str(RPL_MAPEND), me.name, parv[0]); /* XXX DEAD */ - - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_motd.c b/ircd/m_motd.c index a3cb47d..b33cfd2 100644 --- a/ircd/m_motd.c +++ b/ircd/m_motd.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_policy.h" diff --git a/ircd/m_names.c b/ircd/m_names.c index 1ccb304..01df991 100644 --- a/ircd/m_names.c +++ b/ircd/m_names.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" @@ -490,206 +482,3 @@ int ms_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 1; } - - -#if 0 -/* - * m_names - Added by Jto 27 Apr 1989 - * - * parv[0] = sender prefix - * parv[1] = channel - */ -int m_names(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Channel *chptr; - struct Client *c2ptr; - struct Membership* member; - struct Channel *ch2ptr = 0; - int idx, flag, len, mlen; - char *s, *para = parc > 1 ? parv[1] : 0; - char buf[BUFSIZE]; - - if (parc > 2 && hunt_server(1, cptr, sptr, "%s%s " TOK_NAMES " %s %s", 2, parc, parv)) /* XXX DEAD */ - return 0; - - mlen = strlen(me.name) + 10 + strlen(sptr->name); - - if (!EmptyString(para)) - { - s = strchr(para, ','); - if (s) - { - parv[1] = ++s; - m_names(cptr, sptr, parc, parv); - } - clean_channelname(para); - ch2ptr = FindChannel(para); - } - - /* - * First, do all visible channels (public and the one user self is) - */ - - for (chptr = GlobalChannelList; chptr; chptr = chptr->next) - { - if ((chptr != ch2ptr) && !EmptyString(para)) - continue; /* -- wanted a specific channel */ - if (!MyConnect(sptr) && EmptyString(para)) - continue; -#ifndef GODMODE - if (!ShowChannel(sptr, chptr)) - continue; /* -- users on this are not listed */ -#endif - - /* Find users on same channel (defined by chptr) */ - - strcpy(buf, "* "); - len = strlen(chptr->chname); - strcpy(buf + 2, chptr->chname); - strcpy(buf + 2 + len, " :"); - - if (PubChannel(chptr)) - *buf = '='; - else if (SecretChannel(chptr)) - *buf = '@'; - idx = len + 4; - flag = 1; - for (member = chptr->members; member; member = member->next_member) - { - c2ptr = member->user; -#ifndef GODMODE - if (sptr != c2ptr && IsInvisible(c2ptr) && !find_channel_member(sptr, chptr)) - continue; -#endif - if (IsZombie(member)) - { - if (member->user != sptr) - continue; - else - { - strcat(buf, "!"); - idx++; - } - } - else if (IsChanOp(member)) - { - strcat(buf, "@"); - idx++; - } - else if (HasVoice(member)) - { - strcat(buf, "+"); - idx++; - } - strcat(buf, c2ptr->name); - strcat(buf, " "); - idx += strlen(c2ptr->name) + 1; - flag = 1; -#ifdef GODMODE - { - char yxx[6]; - sprintf_irc(yxx, "%s%s", NumNick(c2ptr)); - assert(c2ptr == findNUser(yxx)); - sprintf_irc(buf + strlen(buf), "(%s) ", yxx); - idx += 6; - } - if (mlen + idx + NICKLEN + 11 > BUFSIZE) -#else - if (mlen + idx + NICKLEN + 5 > BUFSIZE) -#endif - /* space, modifier, nick, \r \n \0 */ - { - sendto_one(sptr, rpl_str(RPL_NAMREPLY), me.name, parv[0], buf); /* XXX DEAD */ - strcpy(buf, "* "); - ircd_strncpy(buf + 2, chptr->chname, len + 1); - buf[len + 2] = 0; - strcat(buf, " :"); - if (PubChannel(chptr)) - *buf = '='; - else if (SecretChannel(chptr)) - *buf = '@'; - idx = len + 4; - flag = 0; - } - } - if (flag) - sendto_one(sptr, rpl_str(RPL_NAMREPLY), me.name, parv[0], buf); /* XXX DEAD */ - } - if (!EmptyString(para)) - { - sendto_one(sptr, rpl_str(RPL_ENDOFNAMES), me.name, parv[0], /* XXX DEAD */ - ch2ptr ? ch2ptr->chname : para); - return (1); - } - - /* Second, do all non-public, non-secret channels in one big sweep */ - - strcpy(buf, "* * :"); - idx = 5; - flag = 0; - for (c2ptr = GlobalClientList; c2ptr; c2ptr = c2ptr->next) - { - struct Channel *ch3ptr; - int showflag = 0, secret = 0; - -#ifndef GODMODE - if (!IsUser(c2ptr) || (sptr != c2ptr && IsInvisible(c2ptr))) -#else - if (!IsUser(c2ptr)) -#endif - continue; - member = c2ptr->user->channel; - /* - * Don't show a client if they are on a secret channel or when - * they are on a channel sptr is on since they have already - * been show earlier. -avalon - */ - while (member) - { - ch3ptr = member->channel; -#ifndef GODMODE - if (PubChannel(ch3ptr) || find_channel_member(sptr, ch3ptr)) -#endif - showflag = 1; - if (SecretChannel(ch3ptr)) - secret = 1; - member = member->next_channel; - } - if (showflag) /* Have we already shown them ? */ - continue; -#ifndef GODMODE - if (secret) /* On any secret channels ? */ - continue; -#endif - strcat(buf, c2ptr->name); - strcat(buf, " "); - idx += strlen(c2ptr->name) + 1; - flag = 1; -#ifdef GODMODE - { - char yxx[6]; - sprintf_irc(yxx, "%s%s", NumNick(c2ptr)); - assert(c2ptr == findNUser(yxx)); - sprintf_irc(buf + strlen(buf), "(%s) ", yxx); - idx += 6; - } -#endif -#ifdef GODMODE - if (mlen + idx + NICKLEN + 9 > BUFSIZE) -#else - if (mlen + idx + NICKLEN + 3 > BUFSIZE) /* space, \r\n\0 */ -#endif - { - sendto_one(sptr, rpl_str(RPL_NAMREPLY), me.name, parv[0], buf); /* XXX DEAD */ - strcpy(buf, "* * :"); - idx = 5; - flag = 0; - } - } - if (flag) - sendto_one(sptr, rpl_str(RPL_NAMREPLY), me.name, parv[0], buf); /* XXX DEAD */ - sendto_one(sptr, rpl_str(RPL_ENDOFNAMES), me.name, parv[0], "*"); /* XXX DEAD */ - return 1; -} -#endif /* 0 */ - diff --git a/ircd/m_nick.c b/ircd/m_nick.c index 83cefe3..76b29ff 100644 --- a/ircd/m_nick.c +++ b/ircd/m_nick.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "IPcheck.h" #include "client.h" #include "hash.h" @@ -491,299 +483,3 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) assert(0 != sptr); return set_nick_name(cptr, sptr, nick, parc, parv); } - -#if 0 -/* - * m_nick - * - * parv[0] = sender prefix - * parv[1] = nickname - * - * If from server, source is client: - * parv[2] = timestamp - * - * Source is server: - * parv[2] = hopcount - * parv[3] = timestamp - * parv[4] = username - * parv[5] = hostname - * parv[6] = umode (optional) - * parv[parc-3] = IP# <- Only Protocol >= 10 - * parv[parc-2] = YXX, numeric nick <- Only Protocol >= 10 - * parv[parc-1] = info - * parv[0] = server - */ -int m_nick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client* acptr; - char nick[NICKLEN + 2]; - char* s; - time_t lastnick = 0; - int differ = 1; - - if (parc < 2) { - sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - else if ((IsServer(sptr) && parc < 8) || (IsServer(cptr) && parc < 3)) - { - need_more_params(sptr, "NICK"); - sendto_ops("bad NICK param count for %s from %s", parv[1], cptr->name); /* XXX DEAD */ - return 0; - } - if (MyConnect(sptr) && (s = strchr(parv[1], '~'))) - *s = '\0'; - ircd_strncpy(nick, parv[1], NICKLEN); - nick[NICKLEN] = '\0'; - if (IsServer(cptr)) { - if (IsServer(sptr)) { - lastnick = atoi(parv[3]); - if (lastnick > OLDEST_TS) - sptr->serv->lag = TStime() - lastnick; - } else { - lastnick = atoi(parv[2]); - if (lastnick > OLDEST_TS) - sptr->user->server->serv->lag = TStime() - lastnick; - } - } - /* - * If do_nick_name() returns a null name OR if the server sent a nick - * name and do_nick_name() changed it in some way (due to rules of nick - * creation) then reject it. If from a server and we reject it, - * and KILL it. -avalon 4/4/92 - */ - if (do_nick_name(nick) == 0 || (IsServer(cptr) && strcmp(nick, parv[1]))) - { - sendto_one(sptr, err_str(ERR_ERRONEUSNICKNAME), me.name, parv[0], parv[1]); /* XXX DEAD */ - - if (IsServer(cptr)) - { - ServerStats->is_kill++; - sendto_ops("Bad Nick: %s From: %s %s", /* XXX DEAD */ - parv[1], parv[0], cptr->name); - sendto_one(cptr, "%s " TOK_KILL " %s :%s (%s <- %s[%s])", /* XXX DEAD */ - NumServ(&me), IsServer(sptr) ? parv[parc - 2] : parv[0], me.name, - parv[1], nick, cptr->name); - if (!IsServer(sptr)) /* bad nick _change_ */ - { - sendto_highprot_butone(&me, 10, "%s " TOK_KILL " %s :%s (%s <- %s!%s@%s)", /* XXX DEAD */ - NumServ(&me), parv[0], me.name, cptr->name, - parv[0], sptr->user ? sptr->username : "", - sptr->user ? sptr->user->server->name : cptr->name); - } - } - return 0; - } - - /* - * Check if this is a LOCAL user trying to use a reserved (Juped) - * nick, if so tell him that it's a nick in use... - */ - if ((!IsServer(cptr)) && isNickJuped(nick)) - { - sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */ - /* parv[0] is empty when connecting */ - EmptyString(parv[0]) ? "*" : parv[0], nick); - return 0; /* NICK message ignored */ - } - - /* - * Check against nick name collisions. - * - * Put this 'if' here so that the nesting goes nicely on the screen :) - * We check against server name list before determining if the nickname - * is present in the nicklist (due to the way the below for loop is - * constructed). -avalon - */ - - acptr = FindServer(nick); - - if (acptr) { /* There is a nick collision with a server */ - if (MyConnect(sptr)) - { - /* Local user trying to use a nick thats a server - * Return an error message and ignore the command - */ - sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */ - EmptyString(parv[0]) ? "*" : parv[0], nick); - return 0; /* NICK message ignored */ - } - - /* - * We have a nickname trying to use the same name as - * a server. Send out a nick collision KILL to remove - * the nickname. As long as only a KILL is sent out, - * there is no danger of the server being disconnected. - * Ultimate way to jupiter a nick ? >;-). -avalon - */ - sendto_ops("Nick collision on %s(%s <- %s)", /* XXX DEAD */ - sptr->name, acptr->from->name, cptr->name); - ServerStats->is_kill++; - sendto_one(cptr, "%s " TOK_KILL " %s%s :%s (%s <- %s)", /* XXX DEAD */ - NumServ(&me), NumNick(sptr), me.name, acptr->from->name, - cptr->name); - sptr->flags |= FLAGS_KILLED; - return exit_client(cptr, sptr, &me, "Nick/Server collision"); - } - - acptr = FindClient(nick); - - /* No collisions? Set the nick name and we're done */ - if (!acptr) - return set_nick_name(cptr, sptr, nick, parc, parv); - /* - * If acptr == sptr, then we have a client doing a nick - * change between *equivalent* nicknames as far as server - * is concerned (user is changing the case of his/her - * nickname or somesuch) - */ - if (acptr == sptr) - { - if (strcmp(acptr->name, nick) != 0) - /* - * Allows change of case in his/her nick - */ - return set_nick_name(cptr, sptr, nick, parc, parv); - else - /* - * This is just ':old NICK old' type thing. - * Just forget the whole thing here. There is - * no point forwarding it to anywhere, - * especially since servers prior to this - * version would treat it as nick collision. - */ - return 0; /* NICK Message ignored */ - } - - /* - * Note: From this point forward it can be assumed that - * acptr != sptr (point to different client structures). - */ - /* - * If the older one is "non-person", the new entry is just - * allowed to overwrite it. Just silently drop non-person, - * and proceed with the nick. This should take care of the - * "dormant nick" way of generating collisions... - */ - if (IsUnknown(acptr) && MyConnect(acptr)) - { - ++ServerStats->is_ref; - IPcheck_connect_fail(acptr->ip); - exit_client(cptr, acptr, &me, "Overridden by other sign on"); - return set_nick_name(cptr, sptr, nick, parc, parv); - } - /* - * Decide, we really have a nick collision and deal with it - */ - if (!IsServer(cptr)) - { - /* - * NICK is coming from local client connection. Just - * send error reply and ignore the command. - */ - sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */ - /* parv[0] is empty when connecting */ - EmptyString(parv[0]) ? "*" : parv[0], nick); - return 0; /* NICK message ignored */ - } - /* - * NICK was coming from a server connection. - * This means we have a race condition (two users signing on - * at the same time), or two net fragments reconnecting with the same nick. - * The latter can happen because two different users connected - * or because one and the same user switched server during a net break. - * If the TimeStamps are equal, we kill both (or only 'new' - * if it was a ":server NICK new ..."). - * Otherwise we kill the youngest when user@host differ, - * or the oldest when they are the same. - * We treat user and ~user as different, because if it wasn't - * a faked ~user the AUTH wouldn't have added the '~'. - * --Run - * - */ - if (IsServer(sptr)) - { - /* - * A new NICK being introduced by a neighbouring - * server (e.g. message type ":server NICK new ..." received) - */ - differ = (acptr->ip.s_addr != htonl(base64toint(parv[parc - 3]))) || - (0 != ircd_strcmp(acptr->user->username, parv[4])); - sendto_ops("Nick collision on %s (%s " TIME_T_FMT " <- %s " TIME_T_FMT /* XXX DEAD */ - " (%s user@host))", acptr->name, acptr->from->name, acptr->lastnick, - cptr->name, lastnick, differ ? "Different" : "Same"); - } - else - { - /* - * A NICK change has collided (e.g. message type ":old NICK new"). - */ - lastnick = atoi(parv[2]); - differ = (acptr->ip.s_addr != sptr->ip.s_addr) || - (0 != ircd_strcmp(acptr->user->username, sptr->user->username)); - sendto_ops("Nick change collision from %s to %s (%s " TIME_T_FMT " <- %s " /* XXX DEAD */ - TIME_T_FMT ")", sptr->name, acptr->name, acptr->from->name, - acptr->lastnick, cptr->name, lastnick); - } - /* - * Now remove (kill) the nick on our side if it is the youngest. - * If no timestamp was received, we ignore the incoming nick - * (and expect a KILL for our legit nick soon ): - * When the timestamps are equal we kill both nicks. --Run - * acptr->from != cptr should *always* be true (?). - */ - if (acptr->from != cptr) - { - if ((differ && lastnick >= acptr->lastnick) || - (!differ && lastnick <= acptr->lastnick)) - { - if (!IsServer(sptr)) - { - ServerStats->is_kill++; - sendto_highprot_butone(cptr, 10, /* Kill old from outgoing servers */ /* XXX DEAD */ - "%s " TOK_KILL " %s%s :%s (%s <- %s (Nick collision))", - NumServ(&me), NumNick(sptr), me.name, acptr->from->name, - cptr->name); - if (MyConnect(sptr) && IsServer(cptr) && Protocol(cptr) > 9) - sendto_one(cptr, "%s " TOK_KILL " %s%s :%s (Ghost2)", /* XXX DEAD */ - NumServ(&me), NumNick(sptr), me.name); - sptr->flags |= FLAGS_KILLED; - exit_client(cptr, sptr, &me, "Nick collision (you're a ghost)"); - } - if (lastnick != acptr->lastnick) - return 0; /* Ignore the NICK */ - } - sendto_one(acptr, err_str(ERR_NICKCOLLISION), me.name, acptr->name, nick); /* XXX DEAD */ - } - ServerStats->is_kill++; - acptr->flags |= FLAGS_KILLED; - if (differ) - { - sendto_highprot_butone(cptr, 10, /* Kill our old from outgoing servers */ /* XXX DEAD */ - "%s " TOK_KILL " %s%s :%s (%s <- %s (older nick overruled))", - NumServ(&me), NumNick(acptr), me.name, acptr->from->name, - cptr->name); - if (MyConnect(acptr) && IsServer(cptr) && Protocol(cptr) > 9) - sendto_one(cptr, "%s%s " TOK_QUIT " :Local kill by %s (Ghost)", /* XXX DEAD */ - NumNick(acptr), me.name); - exit_client(cptr, acptr, &me, "Nick collision (older nick overruled)"); - } - else - { - sendto_highprot_butone(cptr, 10, /* Kill our old from outgoing servers */ /* XXX DEAD */ - "%s " TOK_KILL " %s%s :%s (%s <- %s (nick collision from same user@host))", - NumServ(&me), NumNick(acptr), me.name, acptr->from->name, - cptr->name); - if (MyConnect(acptr) && IsServer(cptr) && Protocol(cptr) > 9) - sendto_one(cptr, /* XXX DEAD */ - "%s%s " TOK_QUIT " :Local kill by %s (Ghost: switched servers too fast)", - NumNick(acptr), me.name); - exit_client(cptr, acptr, &me, "Nick collision (You collided yourself)"); - } - if (lastnick == acptr->lastnick) - return 0; - - return set_nick_name(cptr, sptr, nick, parc, parv); -} - -#endif /* 0 */ diff --git a/ircd/m_notice.c b/ircd/m_notice.c index 8610da3..b195172 100644 --- a/ircd/m_notice.c +++ b/ircd/m_notice.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_chattr.h" #include "ircd_relay.h" @@ -244,218 +236,3 @@ int mo_notice(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 0; } - - -#if 0 -/* - * m_message (used in m_private() and m_notice()) - * - * The general function to deliver MSG's between users/channels - * - * parv[0] = sender prefix - * parv[1] = receiver list - * parv[parc-1] = message text - * - * massive cleanup - * rev argv 6/91 - */ -static int m_message(struct Client *cptr, struct Client *sptr, - int parc, char *parv[], int notice) -{ - struct Client* acptr; - char* s; - struct Channel* chptr; - char* nick; - char* server; - char* cmd; - char* host; - int i; - int count; - char* vector[MAXTARGETS]; - - sptr->flags &= ~FLAGS_TS8; - - cmd = notice ? MSG_NOTICE : MSG_PRIVATE; - - if (parc < 2 || EmptyString(parv[1])) - return send_error_to_client(sptr, ERR_NORECIPIENT, cmd); /* XXX DEAD */ - - if (parc < 3 || EmptyString(parv[parc - 1])) - return send_error_to_client(sptr, ERR_NOTEXTTOSEND); /* XXX DEAD */ - - -#if 0 - if (MyUser(sptr)) - parv[1] = canonize(parv[1]); - for (p = 0, nick = ircd_strtok(&p, parv[1], ","); nick; - nick = ircd_strtok(&p, 0, ",")) -#endif - - count = unique_name_vector(parv[1], ',', vector, MAXTARGETS); - for (i = 0; i < count; ++i) { - nick = vector[i]; - /* - * channel msg? - */ - if (IsChannelName(nick)) - { - if ((chptr = FindChannel(nick))) - { - /* This first: Almost never a server/service */ - if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) - { - if (MyUser(sptr) && (chptr->mode.mode & MODE_NOPRIVMSGS) && - check_target_limit(sptr, chptr, chptr->chname, 0)) - continue; - sendmsgto_channel_butone(cptr, sptr, chptr, /* XXX DEAD */ - parv[0], (notice ? TOK_NOTICE : TOK_PRIVATE), - chptr->chname, parv[parc - 1]); - } - else if (!notice) - sendto_one(sptr, err_str(ERR_CANNOTSENDTOCHAN), /* XXX DEAD */ - me.name, parv[0], chptr->chname); - continue; - } - } - else if (*nick != '$' && !strchr(nick, '@')) - { - /* - * nickname addressed? - */ - if (MyUser(sptr)) - acptr = FindUser(nick); - else if ((acptr = findNUser(nick)) && !IsUser(acptr)) - acptr = 0; - if (acptr) - { - if (MyUser(sptr) && !IsChannelService(acptr) && - check_target_limit(sptr, acptr, acptr->name, 0)) - continue; - if (!is_silenced(sptr, acptr)) - { - if (!notice && MyConnect(sptr) && acptr->user && acptr->user->away) - sendto_one(sptr, rpl_str(RPL_AWAY), /* XXX DEAD */ - me.name, parv[0], acptr->name, acptr->user->away); - if (MyUser(acptr)) - { - add_target(acptr, sptr); - sendto_prefix_one(acptr, sptr, ":%s %s %s :%s", /* XXX DEAD */ - parv[0], cmd, acptr->name, parv[parc - 1]); - } - else - sendto_prefix_one(acptr, sptr, ":%s %s %s%s :%s", /* XXX DEAD */ - parv[0], (notice ? TOK_NOTICE : TOK_PRIVATE), - NumNick(acptr), parv[parc - 1]); - } - } - else if (MyUser(sptr)) - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], nick); /* XXX DEAD */ - else - sendto_one(sptr, /* XXX DEAD */ - ":%s %d %s * :Target left UnderNet. Failed to deliver: [%.50s]", - me.name, ERR_NOSUCHNICK, sptr->name, parv[parc - 1]); - continue; - } - /* - * The following two cases allow masks in NOTICEs - * (for OPERs only) - * - * Armin, 8Jun90 (gruner@informatik.tu-muenchen.de) - */ - if ((*nick == '$' || *nick == '#') && IsAnOper(sptr)) - { - if (MyConnect(sptr)) - { - if (!(s = strrchr(nick, '.'))) - { - sendto_one(sptr, err_str(ERR_NOTOPLEVEL), me.name, parv[0], nick); /* XXX DEAD */ - continue; - } - while (*++s) - if (*s == '.' || *s == '*' || *s == '?') - break; - if (*s == '*' || *s == '?') - { - sendto_one(sptr, err_str(ERR_WILDTOPLEVEL), me.name, parv[0], nick); /* XXX DEAD */ - continue; - } - } - sendto_match_butone(IsServer(cptr) ? cptr : 0, /* XXX DEAD */ - sptr, nick + 1, (*nick == '#') ? MATCH_HOST : MATCH_SERVER, - ":%s %s %s :%s", parv[0], cmd, nick, parv[parc - 1]); - continue; - } - else if ((server = strchr(nick, '@')) && (acptr = FindServer(server + 1))) - { - /* - * NICK[%host]@server addressed? See if is me first - */ - if (!IsMe(acptr)) - { - sendto_one(acptr, ":%s %s %s :%s", parv[0], cmd, nick, parv[parc - 1]); /* XXX DEAD */ - continue; - } - - /* Look for an user whose NICK is equal to and then - * check if it's hostname matches and if it's a local - * user. */ - *server = '\0'; - if ((host = strchr(nick, '%'))) - *host++ = '\0'; - - if ((!(acptr = FindUser(nick))) || - (!(MyUser(acptr))) || - ((!(EmptyString(host))) && match(host, acptr->user->host))) - acptr = 0; - - *server = '@'; - if (host) - *--host = '%'; - - if (acptr) - { - if (!(is_silenced(sptr, acptr))) - sendto_prefix_one(acptr, sptr, ":%s %s %s :%s", /* XXX DEAD */ - parv[0], cmd, nick, parv[parc - 1]); - continue; - } - } - if (IsChannelName(nick)) - sendto_one(sptr, err_str(ERR_NOSUCHCHANNEL), me.name, parv[0], nick); /* XXX DEAD */ - else - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], nick); /* XXX DEAD */ - } - return 0; -} - -/* - * m_private - * - * parv[0] = sender prefix - * parv[1] = receiver list - * parv[parc-1] = message text - */ -int m_private(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - return m_message(cptr, sptr, parc, parv, 0); -} - -/* - * m_notice - * - * parv[0] = sender prefix - * parv[1] = receiver list - * parv[parc-1] = notice text - */ -int m_notice(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - if (MyUser(sptr) && parv[1] && parv[1][0] == '@' && - IsChannelName(&parv[1][1])) - { - parv[1]++; /* Get rid of '@' */ - return m_wallchops(cptr, sptr, parc, parv); - } - return m_message(cptr, sptr, parc, parv, 1); -} - -#endif diff --git a/ircd/m_oper.c b/ircd/m_oper.c index 47cb0b0..c6986ee 100644 --- a/ircd/m_oper.c +++ b/ircd/m_oper.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -233,121 +225,3 @@ int mo_oper(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(sptr, RPL_YOUREOPER); return 0; } - -#if 0 -/* - * m_oper - * parv[0] = sender prefix - * parv[1] = oper name - * parv[2] = oper password - */ -int m_oper(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct ConfItem* aconf; - char* name; - char* password; - const char* encr; -#ifdef CRYPT_OPER_PASSWORD - char salt[3]; -#endif /* CRYPT_OPER_PASSWORD */ - - name = parc > 1 ? parv[1] : 0; - password = parc > 2 ? parv[2] : 0; - - if (!IsServer(cptr) && (EmptyString(name) || EmptyString(password))) - return need_more_params(sptr, "OPER"); - - /* if message arrived from server, trust it, and set to oper */ - - if (IsServer(cptr) && !IsOper(sptr)) { - ++UserStats.opers; - sptr->flags |= FLAGS_OPER; - sendto_serv_butone(cptr, "%s%s " TOK_MODE " %s :+o", NumNick(sptr), parv[0]); /* XXX DEAD */ - return 0; - } - else if (IsAnOper(sptr)) { - if (MyConnect(sptr)) - sendto_one(sptr, rpl_str(RPL_YOUREOPER), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - assert(cptr == sptr); - aconf = find_conf_exact(name, sptr->username, sptr->sockhost, CONF_OPS); - if (!aconf) - aconf = find_conf_exact(name, sptr->username, - ircd_ntoa((const char*) &cptr->ip), CONF_OPS); - - if (!aconf || IsIllegal(aconf)) { - sendto_one(sptr, err_str(ERR_NOOPERHOST), me.name, parv[0]); /* XXX DEAD */ - sendto_realops("Failed OPER attempt by %s (%s@%s)", /* XXX DEAD */ - parv[0], sptr->user->username, sptr->sockhost); - return 0; - } - assert(0 != (aconf->status & CONF_OPS)); - -#ifdef CRYPT_OPER_PASSWORD - /* use first two chars of the password they send in as salt */ - - /* passwd may be NULL. Head it off at the pass... */ - salt[0] = '\0'; - if (password && aconf->passwd) - { - salt[0] = aconf->passwd[0]; - salt[1] = aconf->passwd[1]; - salt[2] = '\0'; - encr = ircd_crypt(password, salt); - } - else - encr = ""; -#else - encr = password; -#endif /* CRYPT_OPER_PASSWORD */ - - if (0 == strcmp(encr, aconf->passwd)) { - int old = (sptr->flags & ALL_UMODES); - - if (ACR_OK != attach_conf(sptr, aconf)) { - sendto_one(sptr, err_str(ERR_NOOPERHOST), me.name, parv[0]); /* XXX DEAD */ - sendto_realops("Failed OPER attempt by %s (%s@%s)", /* XXX DEAD */ - parv[0], sptr->user->username, sptr->sockhost); - return 0; - } -#ifdef OPER_REMOTE - if (aconf->status == CONF_LOCOP) { -#else - if (!IsLocal(sptr)) || aconf->status == CONF_LOCOP) { -#endif - ClearOper(sptr); - SetLocOp(sptr); - } - else { - /* prevent someone from being both oper and local oper */ - ClearLocOp(sptr); - SetOper(sptr); - ++UserStats.opers; - } - cptr->handler = OPER_HANDLER; - sendto_ops("%s (%s@%s) is now operator (%c)", parv[0], /* XXX DEAD */ - sptr->user->username, sptr->sockhost, IsOper(sptr) ? 'O' : 'o'); - - sptr->flags |= (FLAGS_WALLOP | FLAGS_SERVNOTICE | FLAGS_DEBUG); - set_snomask(sptr, SNO_OPERDEFAULT, SNO_ADD); - send_umode_out(cptr, sptr, old); - sendto_one(sptr, rpl_str(RPL_YOUREOPER), me.name, parv[0]); /* XXX DEAD */ - - ircd_log(L_INFO, "OPER (%s) by (%s!%s@%s)", /* XXX DEAD */ - name, parv[0], sptr->user->username, sptr->sockhost); -#ifdef FNAME_OPERLOG - if (IsUser(sptr)) - write_log(FNAME_OPERLOG, /* XXX DEAD */ - "%s OPER (%s) by (%s!%s@%s)\n", myctime(CurrentTime), - name, parv[0], sptr->user->username, sptr->sockhost); -#endif - } - else { - sendto_one(sptr, err_str(ERR_PASSWDMISMATCH), me.name, parv[0]); /* XXX DEAD */ - sendto_realops("Failed OPER attempt by %s (%s@%s)", /* XXX DEAD */ - parv[0], sptr->user->username, sptr->sockhost); - } - return 0; -} -#endif /* 0 */ diff --git a/ircd/m_opmode.c b/ircd/m_opmode.c index f0f1eec..01db05a 100644 --- a/ircd/m_opmode.c +++ b/ircd/m_opmode.c @@ -82,14 +82,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "channel.h" #include "hash.h" diff --git a/ircd/m_part.c b/ircd/m_part.c index 86d772d..34e6b64 100644 --- a/ircd/m_part.c +++ b/ircd/m_part.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_pass.c b/ircd/m_pass.c index 4629f69..5848c0e 100644 --- a/ircd/m_pass.c +++ b/ircd/m_pass.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" @@ -119,32 +111,3 @@ int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN); return 0; } - -#if 0 -/* - * m_pass - * - * parv[0] = sender prefix - * parv[1] = password - */ -int m_pass(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char *password = parc > 1 ? parv[1] : 0; - - if (EmptyString(password)) - return need_more_params(cptr, "PASS"); - - if (!MyConnect(sptr) || (!IsUnknown(cptr) && !IsHandshake(cptr))) - { - sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - if (ircd_strcmp("PROTO",password)) { - proto_send_supported(sptr); - return 0; - } - ircd_strncpy(cptr->passwd, password, PASSWDLEN); - return 0; -} -#endif - diff --git a/ircd/m_ping.c b/ircd/m_ping.c index d882ce7..f0de8a8 100644 --- a/ircd/m_ping.c +++ b/ircd/m_ping.c @@ -132,14 +132,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd_reply.h" @@ -253,47 +245,3 @@ int ms_ping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 0; } - - -#if 0 -/* - * m_ping - * - * parv[0] = sender prefix - * parv[1] = origin - * parv[2] = destination - */ -int m_ping(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client *acptr; - char *origin, *destination; - - if (parc < 2 || *parv[1] == '\0') - { - sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - origin = parv[1]; - destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ - - acptr = FindClient(origin); - if (acptr && acptr != sptr) - origin = cptr->name; - - if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name) != 0) - { - if ((acptr = FindServer(destination))) - sendto_one(acptr, ":%s PING %s :%s", parv[0], origin, destination); /* XXX DEAD */ - else - { - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), /* XXX DEAD */ - me.name, parv[0], destination); - return 0; - } - } - else - sendto_one(sptr, ":%s PONG %s :%s", me.name, me.name, origin); /* XXX DEAD */ - return 0; -} -#endif - diff --git a/ircd/m_pong.c b/ircd/m_pong.c index 5072126..74b4fcb 100644 --- a/ircd/m_pong.c +++ b/ircd/m_pong.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -187,71 +179,3 @@ int m_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) cli_lasttime(cptr) = CurrentTime; return 0; } - - -#if 0 -/* - * m_pong - * - * parv[0] = sender prefix - * parv[1] = origin - * parv[2] = destination - */ -int m_pong(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client *acptr; - char *origin, *destination; - - if (MyUser(sptr)) - return 0; - - /* Check to see if this is a PONG :cookie reply from an - * unregistered user. If so, process it. -record */ - - if ((!IsRegistered(sptr)) && (sptr->cookie != 0) && - (sptr->cookie != COOKIE_VERIFIED) && (parc > 1)) - { - if (atol(parv[parc - 1]) == (long)sptr->cookie) - { - sptr->cookie = COOKIE_VERIFIED; - if (sptr->user && *sptr->user->host && sptr->name[0]) /* NICK and - USER OK */ - return register_user(cptr, sptr, sptr->name, sptr->user->username); /* XXX DEAD */ - } - else - sendto_one(sptr, ":%s %d %s :To connect, type /QUOTE PONG %u", /* XXX DEAD */ - me.name, ERR_BADPING, sptr->name, sptr->cookie); - - return 0; - } - - if (parc < 2 || *parv[1] == '\0') - { - sendto_one(sptr, err_str(ERR_NOORIGIN), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - - origin = parv[1]; - destination = parv[2]; - cptr->flags &= ~FLAGS_PINGSENT; - sptr->flags &= ~FLAGS_PINGSENT; - - if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name)) - { - if ((acptr = FindClient(destination))) - sendto_one(acptr, ":%s PONG %s %s", parv[0], origin, destination); /* XXX DEAD */ - else - { - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), /* XXX DEAD */ - me.name, parv[0], destination); - return 0; - } - } -#ifdef DEBUGMODE - else - Debug((DEBUG_NOTICE, "PONG: %s %s", - origin, destination ? destination : "*")); -#endif - return 0; -} -#endif /* 0 */ diff --git a/ircd/m_privmsg.c b/ircd/m_privmsg.c index 09b5a44..aee3c85 100644 --- a/ircd/m_privmsg.c +++ b/ircd/m_privmsg.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_chattr.h" @@ -241,221 +233,3 @@ int mo_privmsg(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 0; } - - -#if 0 -/* - * m_message (used in m_private() and m_notice()) - * - * The general function to deliver MSG's between users/channels - * - * parv[0] = sender prefix - * parv[1] = receiver list - * parv[parc-1] = message text - * - * massive cleanup - * rev argv 6/91 - */ -static int m_message(struct Client *cptr, struct Client *sptr, - int parc, char *parv[], int notice) -{ - struct Client* acptr; - char* s; - struct Channel* chptr; - char* nick; - char* server; - char* cmd; - char* host; - int i; - int count; - char* vector[MAXTARGETS]; - - sptr->flags &= ~FLAGS_TS8; - - cmd = notice ? MSG_NOTICE : MSG_PRIVATE; - - if (parc < 2 || EmptyString(parv[1])) - return send_error_to_client(sptr, ERR_NORECIPIENT, cmd); /* XXX DEAD */ - - if (parc < 3 || EmptyString(parv[parc - 1])) - return send_error_to_client(sptr, ERR_NOTEXTTOSEND); /* XXX DEAD */ - - -#if 0 - if (MyUser(sptr)) - parv[1] = canonize(parv[1]); - for (p = 0, nick = ircd_strtok(&p, parv[1], ","); nick; - nick = ircd_strtok(&p, 0, ",")) -#endif - - count = unique_name_vector(parv[1], ',', vector, MAXTARGETS); - for (i = 0; i < count; ++i) { - nick = vector[i]; - /* - * channel msg? - */ - if (IsChannelName(nick)) - { - if ((chptr = FindChannel(nick))) - { - /* This first: Almost never a server/service */ - if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) - { - if (MyUser(sptr) && (chptr->mode.mode & MODE_NOPRIVMSGS) && - check_target_limit(sptr, chptr, chptr->chname, 0)) - continue; - sendmsgto_channel_butone(cptr, sptr, chptr, /* XXX DEAD */ - parv[0], (notice ? TOK_NOTICE : TOK_PRIVATE), - chptr->chname, parv[parc - 1]); - } - else if (!notice) - sendto_one(sptr, err_str(ERR_CANNOTSENDTOCHAN), /* XXX DEAD */ - me.name, parv[0], chptr->chname); - continue; - } - } - else if (*nick != '$' && !strchr(nick, '@')) - { - /* - * nickname addressed? - */ - if (MyUser(sptr)) - acptr = FindUser(nick); - else if ((acptr = findNUser(nick)) && !IsUser(acptr)) - acptr = 0; - if (acptr) - { - if (MyUser(sptr) && !IsChannelService(acptr) && - check_target_limit(sptr, acptr, acptr->name, 0)) - continue; - if (!is_silenced(sptr, acptr)) - { - if (!notice && MyConnect(sptr) && acptr->user && acptr->user->away) - sendto_one(sptr, rpl_str(RPL_AWAY), /* XXX DEAD */ - me.name, parv[0], acptr->name, acptr->user->away); - if (MyUser(acptr)) - { - add_target(acptr, sptr); - sendto_prefix_one(acptr, sptr, ":%s %s %s :%s", /* XXX DEAD */ - parv[0], cmd, acptr->name, parv[parc - 1]); - } - else - sendto_prefix_one(acptr, sptr, ":%s %s %s%s :%s", /* XXX DEAD */ - parv[0], (notice ? TOK_NOTICE : TOK_PRIVATE), - NumNick(acptr), parv[parc - 1]); - } - } - else if (MyUser(sptr)) - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], nick); /* XXX DEAD */ - else - sendto_one(sptr, /* XXX DEAD */ - ":%s %d %s * :Target left UnderNet. Failed to deliver: [%.50s]", - me.name, ERR_NOSUCHNICK, sptr->name, parv[parc - 1]); - continue; - } - /* - * The following two cases allow masks in NOTICEs - * (for OPERs only) - * - * Armin, 8Jun90 (gruner@informatik.tu-muenchen.de) - */ - if ((*nick == '$' || *nick == '#') && IsAnOper(sptr)) - { - if (MyConnect(sptr)) - { - if (!(s = strrchr(nick, '.'))) - { - sendto_one(sptr, err_str(ERR_NOTOPLEVEL), me.name, parv[0], nick); /* XXX DEAD */ - continue; - } - while (*++s) - if (*s == '.' || *s == '*' || *s == '?') - break; - if (*s == '*' || *s == '?') - { - sendto_one(sptr, err_str(ERR_WILDTOPLEVEL), me.name, parv[0], nick); /* XXX DEAD */ - continue; - } - } - sendto_match_butone(IsServer(cptr) ? cptr : 0, /* XXX DEAD */ - sptr, nick + 1, (*nick == '#') ? MATCH_HOST : MATCH_SERVER, - ":%s %s %s :%s", parv[0], cmd, nick, parv[parc - 1]); - continue; - } - else if ((server = strchr(nick, '@')) && (acptr = FindServer(server + 1))) - { - /* - * NICK[%host]@server addressed? See if is me first - */ - if (!IsMe(acptr)) - { - sendto_one(acptr, ":%s %s %s :%s", parv[0], cmd, nick, parv[parc - 1]); /* XXX DEAD */ - continue; - } - - /* Look for an user whose NICK is equal to and then - * check if it's hostname matches and if it's a local - * user. */ - *server = '\0'; - if ((host = strchr(nick, '%'))) - *host++ = '\0'; - - if ((!(acptr = FindUser(nick))) || - (!(MyUser(acptr))) || - ((!(EmptyString(host))) && match(host, acptr->user->host))) - acptr = 0; - - *server = '@'; - if (host) - *--host = '%'; - - if (acptr) - { - if (!(is_silenced(sptr, acptr))) - sendto_prefix_one(acptr, sptr, ":%s %s %s :%s", /* XXX DEAD */ - parv[0], cmd, nick, parv[parc - 1]); - continue; - } - } - if (IsChannelName(nick)) - sendto_one(sptr, err_str(ERR_NOSUCHCHANNEL), me.name, parv[0], nick); /* XXX DEAD */ - else - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], nick); /* XXX DEAD */ - } - return 0; -} - -/* - * m_private - * - * parv[0] = sender prefix - * parv[1] = receiver list - * parv[parc-1] = message text - */ -int m_private(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - return m_message(cptr, sptr, parc, parv, 0); -} - -#if !defined(XXX_BOGUS_TEMP_HACK) -#include "handlers.h" -#endif -/* - * m_notice - * - * parv[0] = sender prefix - * parv[1] = receiver list - * parv[parc-1] = notice text - */ -int m_notice(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - if (MyUser(sptr) && parv[1] && parv[1][0] == '@' && - IsChannelName(&parv[1][1])) - { - parv[1]++; /* Get rid of '@' */ - return m_wallchops(cptr, sptr, parc, parv); - } - return m_message(cptr, sptr, parc, parv, 1); -} - -#endif diff --git a/ircd/m_privs.c b/ircd/m_privs.c index 3603c20..f72f38c 100644 --- a/ircd/m_privs.c +++ b/ircd/m_privs.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_proto.c b/ircd/m_proto.c index e7731d2..3a9f3ca 100644 --- a/ircd/m_proto.c +++ b/ircd/m_proto.c @@ -24,14 +24,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_alloc.h" diff --git a/ircd/m_quit.c b/ircd/m_quit.c index d1a7751..7d6015a 100644 --- a/ircd/m_quit.c +++ b/ircd/m_quit.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "ircd_string.h" @@ -152,33 +144,3 @@ int ms_quit(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) */ return exit_client(cptr, sptr, sptr, parv[parc - 1]); } - -#if 0 -/* - * m_quit - * - * parv[0] = sender prefix - * parv[parc-1] = comment - */ -int m_quit(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char *comment = (parc > 1 && parv[parc - 1]) ? parv[parc - 1] : cptr->name; - - if (MyUser(sptr)) - { - if (!strncmp("Local Kill", comment, 10) || !strncmp(comment, "Killed", 6)) - comment = parv[0]; - if (sptr->user) - { - struct Membership* chan; - for (chan = sptr->user->channel; chan; chan = chan->next_channel) - if (!IsZombie(chan) && !member_can_send_to_channel(chan)) - return exit_client(cptr, sptr, sptr, "Signed off"); - } - } - if (strlen(comment) > TOPICLEN) - comment[TOPICLEN] = '\0'; - return IsServer(sptr) ? 0 : exit_client(cptr, sptr, sptr, comment); -} - -#endif /* 0 */ diff --git a/ircd/m_rehash.c b/ircd/m_rehash.c index e43793c..e14df38 100644 --- a/ircd/m_rehash.c +++ b/ircd/m_rehash.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_log.h" diff --git a/ircd/m_reset.c b/ircd/m_reset.c index 3bdd7aa..3c48e17 100644 --- a/ircd/m_reset.c +++ b/ircd/m_reset.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_restart.c b/ircd/m_restart.c index 6c52b93..b031161 100644 --- a/ircd/m_restart.c +++ b/ircd/m_restart.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_log.h" diff --git a/ircd/m_rping.c b/ircd/m_rping.c index e30acb6..3841390 100644 --- a/ircd/m_rping.c +++ b/ircd/m_rping.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -242,73 +234,3 @@ int mo_rping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - -#if 0 -/* - * m_rping -- by Run - * - * parv[0] = sender (sptr->name thus) - * if sender is a person: (traveling towards start server) - * parv[1] = pinged server[mask] - * parv[2] = start server (current target) - * parv[3] = optional remark - * if sender is a server: (traveling towards pinged server) - * parv[1] = pinged server (current target) - * parv[2] = original sender (person) - * parv[3] = start time in s - * parv[4] = start time in us - * parv[5] = the optional remark - */ -int m_rping(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client *acptr; - - if (!IsPrivileged(sptr)) - return 0; - - if (parc < (IsAnOper(sptr) ? (MyConnect(sptr) ? 2 : 3) : 6)) - { - return need_more_params(sptr, "RPING"); - return 0; - } - if (MyUser(sptr)) - { - if (parc == 2) - parv[parc++] = me.name; - else if (!(acptr = find_match_server(parv[2]))) - { - parv[3] = parv[2]; - parv[2] = me.name; - parc++; - } - else - parv[2] = acptr->name; - if (parc == 3) - parv[parc++] = ""; - } - - if (IsAnOper(sptr)) - { - if (hunt_server(1, cptr, sptr, "%s%s " TOK_RPING " %s %s :%s", 2, parc, parv) != /* XXX DEAD */ - HUNTED_ISME) - return 0; - if (!(acptr = find_match_server(parv[1])) || !IsServer(acptr)) - { - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]); /* XXX DEAD */ - return 0; - } - sendto_one(acptr, ":%s RPING %s %s %s :%s", /* XXX DEAD */ - me.name, NumServ(acptr), sptr->name, militime(0, 0), parv[3]); - } - else - { - if (hunt_server(1, cptr, sptr, "%s%s " TOK_RPING " %s %s %s %s :%s", 1, parc, parv) /* XXX DEAD */ - != HUNTED_ISME) - return 0; - sendto_one(cptr, ":%s RPONG %s %s %s %s :%s", me.name, parv[0], /* XXX DEAD */ - parv[2], parv[3], parv[4], parv[5]); - } - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_rpong.c b/ircd/m_rpong.c index 1ff2916..fc2cb42 100644 --- a/ircd/m_rpong.c +++ b/ircd/m_rpong.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -153,54 +145,3 @@ int ms_rpong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 0; } - - -#if 0 -/* - * m_rpong -- by Run too :) - * - * parv[0] = sender prefix - * parv[1] = from pinged server: start server; from start server: sender - * parv[2] = from pinged server: sender; from start server: pinged server - * parv[3] = pingtime in ms - * parv[4] = client info (for instance start time) - */ -int m_rpong(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client *acptr; - - if (!IsServer(sptr)) - return 0; - - if (parc < 5) - return need_more_params(sptr, "RPING"); - - if (!(acptr = FindClient(parv[1]))) - return 0; - - if (!IsMe(acptr)) - { - if (IsServer(acptr) && parc > 5) - { - sendto_one(acptr, ":%s RPONG %s %s %s %s :%s", /* XXX DEAD */ - parv[0], parv[1], parv[2], parv[3], parv[4], parv[5]); - return 0; - } - } - else - { - parv[1] = parv[2]; - parv[2] = sptr->name; - parv[0] = me.name; - parv[3] = militime(parv[3], parv[4]); - parv[4] = parv[5]; - if (!(acptr = FindUser(parv[1]))) - return 0; /* No bouncing between servers ! */ - } - - sendto_one(acptr, ":%s RPONG %s %s %s :%s", /* XXX DEAD */ - parv[0], parv[1], parv[2], parv[3], parv[4]); - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_server.c b/ircd/m_server.c index 56ce072..5be7971 100644 --- a/ircd/m_server.c +++ b/ircd/m_server.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -1398,659 +1390,3 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return ret; } - - -#if 0 -/* - * m_server - * - * parv[0] = sender prefix - * parv[1] = servername - * parv[2] = hopcount - * parv[3] = start timestamp - * parv[4] = link timestamp - * parv[5] = major protocol version: P09/P10 - * parv[parc-1] = serverinfo - * If cptr is P10: - * parv[6] = "YMM", where 'Y' is the server numeric and "MM" is the - * numeric nick mask of this server. - * parv[7] = 0 (not used yet, mandatory unsigned int after u2.10.06) - */ -int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char* ch; - int i; - char info[REALLEN + 1]; - char* host; - struct Client* acptr; - struct Client* bcptr; - struct Client* LHcptr = 0; - struct ConfItem* aconf = 0; - struct ConfItem* lhconf = 0; - struct Jupe* ajupe = 0; - int hop; - int ret; - int active_lh_line = 0; - unsigned short prot; - time_t start_timestamp; - time_t timestamp = 0; - time_t recv_time; - time_t ghost = 0; - - if (IsUser(cptr)) - { - sendto_one(cptr, err_str(ERR_ALREADYREGISTRED), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - - if (IsUserPort(cptr)) - return exit_client_msg(cptr, cptr, &me, - "You cannot connect a server to a user port; connect to %s port %u", - me.name, server_port); - - recv_time = TStime(); - info[0] = '\0'; - if (parc < 7) - { - return need_more_params(sptr, "SERVER"); - return exit_client(cptr, cptr, &me, "Need more parameters"); - } - host = parv[1]; - /* - * Detect protocol - */ - if (strlen(parv[5]) != 3 || (parv[5][0] != 'P' && parv[5][0] != 'J')) - return exit_client_msg(cptr, sptr, &me, "Bogus protocol (%s)", parv[5]); - - if (!IsServer(cptr)) /* Don't allow silently connecting a server */ - *parv[5] = 'J'; - - prot = atoi(parv[5] + 1); - if (prot > atoi(MAJOR_PROTOCOL)) - prot = atoi(MAJOR_PROTOCOL); - /* - * Because the previous test is only in 2.10, the following is needed - * till all servers are 2.10: - */ - if (IsServer(cptr) && prot > Protocol(cptr)) - prot = Protocol(cptr); - hop = atoi(parv[2]); - start_timestamp = atoi(parv[3]); - timestamp = atoi(parv[4]); - Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age " TIME_T_FMT " (" - TIME_T_FMT ")", host, parv[4], start_timestamp, me.serv->timestamp)); - if ((timestamp < OLDEST_TS || (hop == 1 && start_timestamp < OLDEST_TS))) - { - return exit_client_msg(cptr, sptr, &me, - "Bogus timestamps (%s %s)", parv[3], parv[4]); - } - ircd_strncpy(info, parv[parc - 1], REALLEN); - info[REALLEN] = '\0'; - if (prot < atoi(MINOR_PROTOCOL)) { - sendto_ops("Got incompatible protocol version (%s) from %s", /* XXX DEAD */ - parv[5], cptr->name); - return exit_new_server(cptr, sptr, host, timestamp, - "Incompatible protocol: %s", parv[5]); - } - /* - * Check for "FRENCH " infection ;-) (actually this should - * be replaced with routine to check the hostname syntax in - * general). [ This check is still needed, even after the parse - * is fixed, because someone can send "SERVER :foo bar " ]. - * Also, changed to check other "difficult" characters, now - * that parse lets all through... --msa - */ - if (strlen(host) > HOSTLEN) - host[HOSTLEN] = '\0'; - for (ch = host; *ch; ch++) - if (*ch <= ' ' || *ch > '~') - break; - if (*ch || !strchr(host, '.')) - { - sendto_ops("Bogus server name (%s) from %s", host, cptr->name); /* XXX DEAD */ - return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host); - } - - if (IsServer(cptr)) - { - /* - * A local server introduces a new server behind this link. - * Check if this is allowed according L:, H: and Q: lines. - */ - if (info[0] == '\0') - return exit_client_msg(cptr, cptr, &me, - "No server info specified for %s", host); - /* - * See if the newly found server is behind a guaranteed - * leaf (L-line). If so, close the link. - */ - if ((lhconf = find_conf_byhost(cptr->confs, cptr->name, CONF_LEAF)) && - (!lhconf->port || (hop > lhconf->port))) - { - /* - * L: lines normally come in pairs, here we try to - * make sure that the oldest link is squitted, not - * both. - */ - active_lh_line = 1; - if (timestamp <= cptr->serv->timestamp) - LHcptr = 0; /* Kill incoming server */ - else - LHcptr = cptr; /* Squit ourselfs */ - } - else if (!(lhconf = find_conf_byname(cptr->confs, cptr->name, CONF_HUB)) || - (lhconf->port && (hop > lhconf->port))) - { - struct Client *ac3ptr; - active_lh_line = 2; - /* Look for net junction causing this: */ - LHcptr = 0; /* incoming server */ - if (*parv[5] != 'J') { - for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up) { - if (IsJunction(ac3ptr)) { - LHcptr = ac3ptr; - break; - } - } - } - } - } - - if (IsUnknown(cptr) || IsHandshake(cptr)) - { - const char* encr; - - /* - * A local link that is still in undefined state wants - * to be a SERVER. Check if this is allowed and change - * status accordingly... - */ - /* - * If there is more then one server on the same machine - * that we try to connect to, it could be that the /CONNECT - * caused this connect to be put at the wrong place - * in the hashtable. --Run - * Same thing for Unknown connections that first send NICK. - * --Xorath - * Better check if the two strings are (caseless) identical - * and not mess with hash internals. - * --Nemesi - */ - if ((!(EmptyString(cptr->name))) - && (IsUnknown(cptr) || IsHandshake(cptr)) - && 0 != ircd_strcmp(cptr->name, host)) - hChangeClient(cptr, host); - ircd_strncpy(cptr->name, host, HOSTLEN); - ircd_strncpy(cptr->info, info[0] ? info : me.name, REALLEN); - cptr->hopcount = hop; - - /* check connection rules */ - if (0 != conf_eval_crule(host, CRULE_ALL)) { - ServerStats->is_ref++; - sendto_ops("Refused connection from %s.", cptr->name); /* XXX DEAD */ - return exit_client(cptr, cptr, &me, "Disallowed by connection rule"); - } - if (conf_check_server(cptr)) { - ++ServerStats->is_ref; - sendto_ops("Received unauthorized connection from %s.", cptr->name); /* XXX DEAD */ - return exit_client(cptr, cptr, &me, "No C/N conf lines"); - } - - host = cptr->name; - - update_load(); - - if (!(aconf = find_conf_byname(cptr->confs, host, CONF_SERVER))) { - ++ServerStats->is_ref; -#ifndef GODMODE - sendto_ops("Access denied. No conf line for server %s", cptr->name); /* XXX DEAD */ - return exit_client_msg(cptr, cptr, &me, - "Access denied. No conf line for server %s", cptr->name); -#else /* GODMODE */ - sendto_ops("General C/N: line active: No line for server %s", cptr->name); /* XXX DEAD */ - aconf = - find_conf_byname(cptr->confs, "general.undernet.org", CONF_SERVER); - if (!aconf) { - sendto_ops("Neither C/N lines for server %s nor " /* XXX DEAD */ - "\"general.undernet.org\"", cptr->name); - return exit_client_msg(cptr, cptr, &me, - "No C/N lines for server %s", cptr->name); - } -#endif /* GODMODE */ - } -#ifdef CRYPT_LINK_PASSWORD - /* passwd may be NULL. Head it off at the pass... */ - if (*cptr->passwd) - { - encr = ircd_crypt(cptr->passwd, aconf->passwd); - } - else - encr = ""; -#else - encr = cptr->passwd; -#endif /* CRYPT_LINK_PASSWORD */ -#ifndef GODMODE - if (*aconf->passwd && !!strcmp(aconf->passwd, encr)) { - ++ServerStats->is_ref; - sendto_ops("Access denied (passwd mismatch) %s", cptr->name); /* XXX DEAD */ - return exit_client_msg(cptr, cptr, &me, - "No Access (passwd mismatch) %s", cptr->name); - } -#endif /* not GODMODE */ - memset(cptr->passwd, 0, sizeof(cptr->passwd)); - -#ifndef HUB - for (i = 0; i <= HighestFd; i++) - if (LocalClientArray[i] && IsServer(LocalClientArray[i])) { - active_lh_line = 3; - LHcptr = 0; - break; - } -#endif - } - - /* - * We want to find IsConnecting() and IsHandshake() too, - * use FindClient(). - * The second finds collisions with numeric representation of existing - * servers - these shouldn't happen anymore when all upgraded to 2.10. - * -- Run - */ - while ((acptr = FindClient(host)) || - (parc > 7 && (acptr = FindNServer(parv[6])))) - { - /* - * This link is trying feed me a server that I already have - * access through another path - * - * Do not allow Uworld to do this. - * Do not allow servers that are juped. - * Do not allow servers that have older link timestamps - * then this try. - * Do not allow servers that use the same numeric as an existing - * server, but have a different name. - * - * If my ircd.conf sucks, I can try to connect to myself: - */ - if (acptr == &me) - return exit_client_msg(cptr, cptr, &me, - "nick collision with me, check server number in M:? (%s)", host); - /* - * Detect wrong numeric. - */ - if (0 != ircd_strcmp(acptr->name, host)) - { - sendto_serv_butone(cptr, /* XXX DEAD */ - ":%s WALLOPS :SERVER Numeric Collision: %s != %s", - me.name, acptr->name, host); - return exit_client_msg(cptr, cptr, &me, - "NUMERIC collision between %s and %s." - " Is your server numeric correct ?", host, acptr->name); - } - /* - * Kill our try, if we had one. - */ - if (IsConnecting(acptr)) - { - if (!active_lh_line && exit_client(cptr, acptr, &me, - "Just connected via another link") == CPTR_KILLED) - return CPTR_KILLED; - /* - * We can have only ONE 'IsConnecting', 'IsHandshake' or - * 'IsServer', because new 'IsConnecting's are refused to - * the same server if we already had it. - */ - break; - } - /* - * Avoid other nick collisions... - * This is a doubtfull test though, what else would it be - * when it has a server.name ? - */ - else if (!IsServer(acptr) && !IsHandshake(acptr)) - return exit_client_msg(cptr, cptr, &me, - "Nickname %s already exists!", host); - /* - * Our new server might be a juped server, - * or someone trying abuse a second Uworld: - */ - else if (IsServer(acptr) && (0 == ircd_strncmp(acptr->info, "JUPE", 4) || - find_conf_byhost(cptr->confs, acptr->name, CONF_UWORLD))) - { - if (!IsServer(sptr)) - return exit_client(cptr, sptr, &me, acptr->info); - sendto_one(cptr, ":%s WALLOPS :Received :%s SERVER %s from %s !?!", /* XXX DEAD */ - me.name, parv[0], parv[1], cptr->name); - return exit_new_server(cptr, sptr, host, timestamp, "%s", acptr->info); - } - /* - * Of course we find the handshake this link was before :) - */ - else if (IsHandshake(acptr) && acptr == cptr) - break; - /* - * Here we have a server nick collision... - * We don't want to kill the link that was last /connected, - * but we neither want to kill a good (old) link. - * Therefor we kill the second youngest link. - */ - if (1) - { - struct Client* c2ptr = 0; - struct Client* c3ptr = acptr; - struct Client* ac2ptr; - struct Client* ac3ptr; - - /* Search youngest link: */ - for (ac3ptr = acptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up) - if (ac3ptr->serv->timestamp > c3ptr->serv->timestamp) - c3ptr = ac3ptr; - if (IsServer(sptr)) - { - for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = ac3ptr->serv->up) - if (ac3ptr->serv->timestamp > c3ptr->serv->timestamp) - c3ptr = ac3ptr; - } - if (timestamp > c3ptr->serv->timestamp) - { - c3ptr = 0; - c2ptr = acptr; /* Make sure they differ */ - } - /* Search second youngest link: */ - for (ac2ptr = acptr; ac2ptr != &me; ac2ptr = ac2ptr->serv->up) - if (ac2ptr != c3ptr && - ac2ptr->serv->timestamp > - (c2ptr ? c2ptr->serv->timestamp : timestamp)) - c2ptr = ac2ptr; - if (IsServer(sptr)) - { - for (ac2ptr = sptr; ac2ptr != &me; ac2ptr = ac2ptr->serv->up) - if (ac2ptr != c3ptr && - ac2ptr->serv->timestamp > - (c2ptr ? c2ptr->serv->timestamp : timestamp)) - c2ptr = ac2ptr; - } - if (c3ptr && timestamp > (c2ptr ? c2ptr->serv->timestamp : timestamp)) - c2ptr = 0; - /* If timestamps are equal, decide which link to break - * by name. - */ - if ((c2ptr ? c2ptr->serv->timestamp : timestamp) == - (c3ptr ? c3ptr->serv->timestamp : timestamp)) - { - char* n2; - char* n2up; - char* n3; - char* n3up; - if (c2ptr) - { - n2 = c2ptr->name; - n2up = MyConnect(c2ptr) ? me.name : c2ptr->serv->up->name; - } - else - { - n2 = host; - n2up = IsServer(sptr) ? sptr->name : me.name; - } - if (c3ptr) - { - n3 = c3ptr->name; - n3up = MyConnect(c3ptr) ? me.name : c3ptr->serv->up->name; - } - else - { - n3 = host; - n3up = IsServer(sptr) ? sptr->name : me.name; - } - if (strcmp(n2, n2up) > 0) - n2 = n2up; - if (strcmp(n3, n3up) > 0) - n3 = n3up; - if (strcmp(n3, n2) > 0) - { - ac2ptr = c2ptr; - c2ptr = c3ptr; - c3ptr = ac2ptr; - } - } - /* Now squit the second youngest link: */ - if (!c2ptr) - return exit_new_server(cptr, sptr, host, timestamp, - "server %s already exists and is %ld seconds younger.", - host, (long)acptr->serv->timestamp - (long)timestamp); - else if (c2ptr->from == cptr || IsServer(sptr)) - { - struct Client *killedptrfrom = c2ptr->from; - if (active_lh_line) - { - /* - * If the L: or H: line also gets rid of this link, - * we sent just one squit. - */ - if (LHcptr && a_kills_b_too(LHcptr, c2ptr)) - break; - /* - * If breaking the loop here solves the L: or H: - * line problem, we don't squit that. - */ - if (c2ptr->from == cptr || (LHcptr && a_kills_b_too(c2ptr, LHcptr))) - active_lh_line = 0; - else - { - /* - * If we still have a L: or H: line problem, - * we prefer to squit the new server, solving - * loop and L:/H: line problem with only one squit. - */ - LHcptr = 0; - break; - } - } - /* - * If the new server was introduced by a server that caused a - * Ghost less then 20 seconds ago, this is probably also - * a Ghost... (20 seconds is more then enough because all - * SERVER messages are at the beginning of a net.burst). --Run - */ - if (CurrentTime - cptr->serv->ghost < 20) - { - killedptrfrom = acptr->from; - if (exit_client(cptr, acptr, &me, "Ghost loop") == CPTR_KILLED) - return CPTR_KILLED; - } - else if (exit_client_msg(cptr, c2ptr, &me, - "Loop <-- %s (new link is %ld seconds younger)", host, - (c3ptr ? (long)c3ptr->serv->timestamp : timestamp) - - (long)c2ptr->serv->timestamp) == CPTR_KILLED) - return CPTR_KILLED; - /* - * Did we kill the incoming server off already ? - */ - if (killedptrfrom == cptr) - return 0; - } - else - { - if (active_lh_line) - { - if (LHcptr && a_kills_b_too(LHcptr, acptr)) - break; - if (acptr->from == cptr || (LHcptr && a_kills_b_too(acptr, LHcptr))) - active_lh_line = 0; - else - { - LHcptr = 0; - break; - } - } - /* - * We can't believe it is a lagged server message - * when it directly connects to us... - * kill the older link at the ghost, rather then - * at the second youngest link, assuming it isn't - * a REAL loop. - */ - ghost = CurrentTime; /* Mark that it caused a ghost */ - if (exit_client(cptr, acptr, &me, "Ghost") == CPTR_KILLED) - return CPTR_KILLED; - break; - } - } - } - - if (active_lh_line) - { - if (LHcptr == 0) { - return exit_new_server(cptr, sptr, host, timestamp, - (active_lh_line == 2) ? "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)", - cptr->name, host, - lhconf ? (lhconf->name ? lhconf->name : "*") : "!"); - } - else - { - int killed = a_kills_b_too(LHcptr, sptr); - if (active_lh_line < 3) - { - if (exit_client_msg(cptr, LHcptr, &me, - (active_lh_line == 2) ? "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)", - cptr->name, host, - lhconf ? (lhconf->name ? lhconf->name : "*") : "!") == CPTR_KILLED) - return CPTR_KILLED; - } - else - { - ServerStats->is_ref++; - if (exit_client(cptr, LHcptr, &me, "I'm a leaf") == CPTR_KILLED) - return CPTR_KILLED; - } - /* - * Did we kill the incoming server off already ? - */ - if (killed) - return 0; - } - } - - if (IsServer(cptr)) - { - /* - * Server is informing about a new server behind - * this link. Create REMOTE server structure, - * add it to list and propagate word to my other - * server links... - */ - - acptr = make_client(cptr, STAT_SERVER); - make_server(acptr); - acptr->serv->prot = prot; - acptr->serv->timestamp = timestamp; - acptr->hopcount = hop; - ircd_strncpy(acptr->name, host, HOSTLEN); - ircd_strncpy(acptr->info, info, REALLEN); - acptr->serv->up = sptr; - acptr->serv->updown = add_dlink(&sptr->serv->down, acptr); - /* Use cptr, because we do protocol 9 -> 10 translation - for numeric nicks ! */ - SetServerYXX(cptr, acptr, parv[6]); - - Count_newremoteserver(UserStats); - if (Protocol(acptr) < 10) - acptr->flags |= FLAGS_TS8; - add_client_to_list(acptr); - hAddClient(acptr); - if (*parv[5] == 'J') - { - SetBurst(acptr); - sendto_op_mask(SNO_NETWORK, "Net junction: %s %s", /* XXX DEAD */ - sptr->name, acptr->name); - SetJunction(acptr); - } - /* - * Old sendto_serv_but_one() call removed because we now need to send - * different names to different servers (domain name matching). - */ - for (i = 0; i <= HighestFd; i++) - { - if (!(bcptr = LocalClientArray[i]) || !IsServer(bcptr) || - bcptr == cptr || IsMe(bcptr)) - continue; - if (0 == match(me.name, acptr->name)) - continue; - sendto_one(bcptr, "%s " TOK_SERVER " %s %d 0 %s %s %s%s 0 :%s", /* XXX DEAD */ - NumServ(sptr), acptr->name, hop + 1, parv[4], parv[5], - NumServCap(acptr), acptr->info); - } - return 0; - } - - if (IsUnknown(cptr) || IsHandshake(cptr)) - { - make_server(cptr); - cptr->serv->timestamp = timestamp; - cptr->serv->prot = prot; - cptr->serv->ghost = ghost; - SetServerYXX(cptr, cptr, parv[6]); - if (start_timestamp > OLDEST_TS) - { -#ifndef RELIABLE_CLOCK -#ifdef TESTNET - sendto_ops("Debug: my start time: " TIME_T_FMT " ; others start time: " /* XXX DEAD */ - TIME_T_FMT, me.serv->timestamp, start_timestamp); - sendto_ops("Debug: receive time: " TIME_T_FMT " ; received timestamp: " /* XXX DEAD */ - TIME_T_FMT " ; difference %ld", - recv_time, timestamp, timestamp - recv_time); -#endif - if (start_timestamp < me.serv->timestamp) - { - sendto_ops("got earlier start time: " TIME_T_FMT " < " TIME_T_FMT, /* XXX DEAD */ - start_timestamp, me.serv->timestamp); - me.serv->timestamp = start_timestamp; - TSoffset += timestamp - recv_time; - sendto_ops("clock adjusted by adding %d", (int)(timestamp - recv_time)); /* XXX DEAD */ - } - else if ((start_timestamp > me.serv->timestamp) && IsUnknown(cptr)) - cptr->serv->timestamp = TStime(); - - else if (timestamp != recv_time) - { - /* - * Equal start times, we have a collision. Let the connected-to server - * decide. This assumes leafs issue more than half of the connection - * attempts. - */ - if (IsUnknown(cptr)) - cptr->serv->timestamp = TStime(); - else if (IsHandshake(cptr)) - { - sendto_ops("clock adjusted by adding %d", /* XXX DEAD */ - (int)(timestamp - recv_time)); - TSoffset += timestamp - recv_time; - } - } -#else /* RELIABLE CLOCK IS TRUE, we _always_ use our own clock */ - if (start_timestamp < me.serv->timestamp) - me.serv->timestamp = start_timestamp; - if (IsUnknown(cptr)) - cptr->serv->timestamp = TStime(); -#endif - } - - ret = server_estab(cptr, aconf); /* XXX DEAD */ - } - else - ret = 0; -#ifdef RELIABLE_CLOCK - if (abs(cptr->serv->timestamp - recv_time) > 30) - { - sendto_ops("Connected to a net with a timestamp-clock" /* XXX DEAD */ - " difference of " STIME_T_FMT " seconds! Used SETTIME to correct" - " this.", timestamp - recv_time); - sendto_one(cptr, ":%s SETTIME " TIME_T_FMT " :%s", /* XXX DEAD */ - me.name, TStime(), me.name); - } -#endif - - return ret; -} -#endif /* 0 */ - diff --git a/ircd/m_set.c b/ircd/m_set.c index 6059ee7..4cca91a 100644 --- a/ircd/m_set.c +++ b/ircd/m_set.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_settime.c b/ircd/m_settime.c index e1cfa05..ad6ac3c 100644 --- a/ircd/m_settime.c +++ b/ircd/m_settime.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -258,91 +250,3 @@ int mo_settime(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - - -#if 0 -/* - * m_settime - * - * parv[0] = sender prefix - * parv[1] = new time - * parv[2] = servername (Only used when sptr is an Oper). - */ -int m_settime(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - time_t t; - long int dt; - static char tbuf[11]; - struct DLink *lp; - - if (!IsPrivileged(sptr)) - return 0; - - if (parc < 2) - return need_more_params(sptr, "SETTIME"); - - if (parc == 2 && MyUser(sptr)) - parv[parc++] = me.name; - - t = atoi(parv[1]); - dt = TStime() - t; - - if (t < OLDEST_TS || dt < -9000000) - { - sendto_one(sptr, ":%s NOTICE %s :SETTIME: Bad value", me.name, parv[0]); /* XXX DEAD */ - return 0; - } - - if (IsServer(sptr)) /* send to unlagged servers */ - { -#ifdef RELIABLE_CLOCK - sprintf_irc(tbuf, TIME_T_FMT, TStime()); - parv[1] = tbuf; -#endif - for (lp = me.serv->down; lp; lp = lp->next) - if (cptr != lp->value.cptr && DBufLength(&lp->value.cptr->sendQ) < 8000) /* XXX DEAD */ - sendto_one(lp->value.cptr, ":%s SETTIME %s", parv[0], parv[1]); /* XXX DEAD */ - } - else - { - sprintf_irc(tbuf, TIME_T_FMT, TStime()); - parv[1] = tbuf; - if (hunt_server(1, cptr, sptr, "%s%s " TOK_SETTIME " %s %s", 2, parc, parv) != /* XXX DEAD */ - HUNTED_ISME) - return 0; - } - -#ifdef RELIABLE_CLOCK - if ((dt > 600) || (dt < -600)) - sendto_serv_butone(0, ":%s " TOK_WALLOPS " :Bad SETTIME from %s: " TIME_T_FMT, /* XXX DEAD */ - me.name, sptr->name, t); - if (IsUser(sptr)) - { - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, ":%s NOTICE %s :clock is not set %ld seconds %s : " /* XXX DEAD */ - "RELIABLE_CLOCK is defined", me.name, parv[0], - (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards"); - else - sendto_one(sptr, "%s NOTICE %s%s :clock is not set %ld seconds %s : " /* XXX DEAD */ - "RELIABLE_CLOCK is defined", NumServ(&me), NumNick(sptr), - (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards"); - } -#else - sendto_ops("SETTIME from %s, clock is set %ld seconds %s", /* XXX DEAD */ - sptr->name, (dt < 0) ? -dt : dt, - (dt < 0) ? "forwards" : "backwards"); - TSoffset -= dt; - if (IsUser(sptr)) - { - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, ":%s NOTICE %s :clock is set %ld seconds %s", me.name, /* XXX DEAD */ - parv[0], (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards"); - else - sendto_one(sptr, "%s NOTICE %s%s :clock is set %ld seconds %s", /* XXX DEAD */ - NumServ(&me), NumNick(sptr), - (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards"); - } -#endif - return 0; -} -#endif /* 0 */ diff --git a/ircd/m_silence.c b/ircd/m_silence.c index 2c92997..21df5b6 100644 --- a/ircd/m_silence.c +++ b/ircd/m_silence.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" @@ -195,89 +187,3 @@ int ms_silence(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 0; } - - -#if 0 -/* - * m_silence() - Added 19 May 1994 by Run. - * - * parv[0] = sender prefix - * From local client: - * parv[1] = mask (NULL sends the list) - * From remote client: - * parv[1] = Numeric nick that must be silenced - * parv[2] = mask - */ -int m_silence(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct SLink *lp; - struct Client *acptr; - char c, *cp; - - if (MyUser(sptr)) - { - acptr = sptr; - if (parc < 2 || *parv[1] == '\0' || (acptr = FindUser(parv[1]))) - { - if (!(acptr->user)) - return 0; - for (lp = acptr->user->silence; lp; lp = lp->next) - sendto_one(sptr, rpl_str(RPL_SILELIST), me.name, /* XXX DEAD */ - sptr->name, acptr->name, lp->value.cp); - sendto_one(sptr, rpl_str(RPL_ENDOFSILELIST), me.name, sptr->name, /* XXX DEAD */ - acptr->name); - return 0; - } - cp = parv[1]; - c = *cp; - if (c == '-' || c == '+') - cp++; - else if (!(strchr(cp, '@') || strchr(cp, '.') || - strchr(cp, '!') || strchr(cp, '*'))) - { - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]); /* XXX DEAD */ - return -1; - } - else - c = '+'; - cp = pretty_mask(cp); - if ((c == '-' && !del_silence(sptr, cp)) || - (c != '-' && !add_silence(sptr, cp))) - { - sendto_prefix_one(sptr, sptr, ":%s SILENCE %c%s", parv[0], c, cp); /* XXX DEAD */ - if (c == '-') - sendto_serv_butone(0, ":%s SILENCE * -%s", sptr->name, cp); /* XXX DEAD */ - } - } - else if (parc < 3 || *parv[2] == '\0') - return need_more_params(sptr, "SILENCE"); - - else - { - if (*parv[1]) /* can be a server */ - acptr = findNUser(parv[1]); - else - acptr = FindNServer(parv[1]); - - if (*parv[2] == '-') - { - if (!del_silence(sptr, parv[2] + 1)) - sendto_serv_butone(cptr, ":%s SILENCE * %s", parv[0], parv[2]); /* XXX DEAD */ - } - else - { - add_silence(sptr, parv[2]); - if (acptr && IsServer(acptr->from)) - { - if (IsServer(acptr)) - sendto_one(acptr, ":%s SILENCE %s %s", /* XXX DEAD */ - parv[0], NumServ(acptr), parv[2]); - else - sendto_one(acptr, ":%s SILENCE %s%s %s", /* XXX DEAD */ - parv[0], NumNick(acptr), parv[2]); - } - } - } - return 0; -} -#endif /* 0 */ diff --git a/ircd/m_squit.c b/ircd/m_squit.c index dbe234b..791b4b5 100644 --- a/ircd/m_squit.c +++ b/ircd/m_squit.c @@ -24,14 +24,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_time.c b/ircd/m_time.c index e64ed4c..5d145c9 100644 --- a/ircd/m_time.c +++ b/ircd/m_time.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd.h" #include "ircd_policy.h" @@ -118,20 +110,3 @@ int m_time(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(sptr, RPL_TIME, cli_name(&me), TStime(), TSoffset, date((long)0)); return 0; } - -#if 0 -/* - * m_time - * - * parv[0] = sender prefix - * parv[1] = servername - */ -int m_time(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - if (hunt_server(0, cptr, sptr, "%s%s TIME :%s", 1, parc, parv) == HUNTED_ISME) /* XXX DEAD */ - sendto_one(sptr, rpl_str(RPL_TIME), me.name, /* XXX DEAD */ - parv[0], me.name, TStime(), TSoffset, date((long)0)); - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_tmpl.c b/ircd/m_tmpl.c index 2bc58fc..24aaaaa 100644 --- a/ircd/m_tmpl.c +++ b/ircd/m_tmpl.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" diff --git a/ircd/m_topic.c b/ircd/m_topic.c index 1cd2433..950e0f4 100644 --- a/ircd/m_topic.c +++ b/ircd/m_topic.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_trace.c b/ircd/m_trace.c index f06aaa9..f4d8464 100644 --- a/ircd/m_trace.c +++ b/ircd/m_trace.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "class.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_uping.c b/ircd/m_uping.c index 584f93a..cc10cf9 100644 --- a/ircd/m_uping.c +++ b/ircd/m_uping.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -248,173 +240,3 @@ int mo_uping(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } return 0; } - - -#if 0 -/* - * m_uping -- by Run - * - * parv[0] = sender prefix - * parv[1] = pinged server - * parv[2] = port - * parv[3] = hunted server - * parv[4] = number of requested pings - */ -int m_uping(struct Client* cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct ConfItem *aconf; - int port; - int fd; - struct UPing* pptr = 0; - - if (!IsPrivileged(sptr)) - { - sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); /* XXX DEAD */ - return -1; - } - - if (parc < 2) - { - sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "UPING"); /* XXX DEAD */ - return 0; - } - - if (MyUser(sptr)) - { - if (parc == 2) - { - parv[parc++] = UDP_PORT; - parv[parc++] = me.name; - parv[parc++] = "5"; - } - else if (parc == 3) - { - if (IsDigit(*parv[2])) - parv[parc++] = me.name; - else - { - parv[parc++] = parv[2]; - parv[2] = UDP_PORT; - } - parv[parc++] = "5"; - } - else if (parc == 4) - { - if (IsDigit(*parv[2])) - { - if (IsDigit(*parv[3])) - { - parv[parc++] = parv[3]; - parv[3] = me.name; - } - else - parv[parc++] = "5"; - } - else - { - parv[parc++] = parv[3]; - parv[3] = parv[2]; - parv[2] = UDP_PORT; - } - } - } - if (hunt_server(1, cptr, sptr, ":%s UPING %s %s %s %s", 3, parc, parv) != HUNTED_ISME) /* XXX DEAD */ - return 0; - - if (BadPtr(parv[4]) || atoi(parv[4]) <= 0) - { - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, ":%s NOTICE %s :UPING: Illegal number of packets: %s", /* XXX DEAD */ - me.name, parv[0], parv[4]); - else - sendto_one(sptr, "%s NOTICE %s%s :UPING: Illegal number of packets: %s", /* XXX DEAD */ - NumServ(&me), NumNick(sptr), parv[4]); - return 0; - } - - /* Check if a CONNECT would be possible at all (adapted from m_connect) */ - for (aconf = GlobalConfList; aconf; aconf = aconf->next) - { - if (aconf->status == CONF_SERVER && - match(parv[1], aconf->name) == 0) - break; - } - if (!aconf) - { - for (aconf = GlobalConfList; aconf; aconf = aconf->next) - { - if (aconf->status == CONF_SERVER && - (match(parv[1], aconf->host) == 0 || - match(parv[1], strchr(aconf->host, '@') + 1) == 0)) - break; - } - } - if (!aconf) - { - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, ":%s NOTICE %s :UPING: Host %s not listed in ircd.conf", /* XXX DEAD */ - me.name, parv[0], parv[1]); - else - sendto_one(sptr, /* XXX DEAD */ - "%s NOTICE %s%s :UPING: Host %s not listed in ircd.conf", - NumServ(&me), NumNick(sptr), parv[1]); - return 0; - } - - if (IsUPing(sptr)) - cancel_ping(sptr, sptr); /* Cancel previous ping request */ - - /* - * Determine port: First user supplied, then default : 7007 - */ - if (BadPtr(parv[2]) || (port = atoi(parv[2])) <= 0) - port = atoi(UDP_PORT); - - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - int err = errno; - sendto_ops("m_uping: socket: %s", (err != EMFILE) /* XXX DEAD */ - ? ((strerror(err)) ? strerror(err) : "Unknown error") : "No more sockets"); - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, /* XXX DEAD */ - ":%s NOTICE %s :UPING: Unable to create udp ping socket", - me.name, parv[0]); - else - sendto_one(sptr, /* XXX DEAD */ - "%s NOTICE %s%s :UPING: Unable to create udp ping socket", - NumServ(&me), NumNick(sptr)); - ircd_log(L_ERROR, "UPING: Unable to create UDP socket"); /* XXX DEAD */ - return 0; - } - - if (!os_set_nonblocking(fd)) { - if (MyUser(sptr) || Protocol(cptr) < 10) - sendto_one(sptr, ":%s NOTICE %s :UPING: Can't set fd non-blocking", /* XXX DEAD */ - me.name, parv[0]); - else - sendto_one(sptr, "%s NOTICE %s%s :UPING: Can't set fd non-blocking", /* XXX DEAD */ - NumServ(&me), NumNick(sptr)); - close(fd); - return 0; - } - pptr = (struct UPing*) MyMalloc(sizeof(struct UPing)); - assert(0 != pptr); - memset(pptr, 0, sizeof(struct UPing)); - - pptr->fd = fd; - pptr->sin.sin_port = htons(port); - pptr->sin.sin_addr.s_addr = aconf->ipnum.s_addr; - pptr->sin.sin_family = AF_INET; - pptr->count = IRCD_MIN(20, atoi(parv[4])); - strcpy(pptr->name, aconf->host); - pptr->client = sptr; - pptr->index = -1; - - pptr->next = pingList; - pingList = pptr; - - SetUPing(sptr); - ping_server(pptr); - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_userhost.c b/ircd/m_userhost.c index db862b0..cf862e9 100644 --- a/ircd/m_userhost.c +++ b/ircd/m_userhost.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" @@ -122,49 +114,3 @@ int m_userhost(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_user_info(sptr, parv[1], RPL_USERHOST, userhost_formatter); return 0; } - -#if 0 -/* - * m_userhost - * - * Added by Darren Reed 13/8/91 to aid clients and reduce the need for - * complicated requests like WHOIS. - * - * Returns user/host information only (no spurious AWAY labels or channels). - * - * Rewritten to speed it up by Carlo Wood 3/8/97. - */ -int m_userhost(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char *s; - int i, j = 5; - char *p = 0, *sbuf; - struct Client *acptr; - - if (parc < 2) - return need_more_params(sptr, "USERHOST"); - - sbuf = sprintf_irc(sendbuf, rpl_str(RPL_USERHOST), me.name, parv[0]); /* XXX DEAD */ - for (i = j, s = ircd_strtok(&p, parv[1], " "); i && s; - s = ircd_strtok(&p, (char *)0, " "), i--) - if ((acptr = FindUser(s))) - { - if (i < j) - *sbuf++ = ' '; - sbuf = sprintf_irc(sbuf, "%s%s=%c%s@%s", acptr->name, - IsAnOper(acptr) ? "*" : "", (acptr->user->away) ? '-' : '+', - acptr->user->username, acptr->user->host); - } - else - { - if (i < j) - sendbufto_one(sptr); /* XXX DEAD */ - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], s); /* XXX DEAD */ - sbuf = sprintf_irc(sendbuf, rpl_str(RPL_USERHOST), me.name, parv[0]); /* XXX DEAD */ - j = i - 1; - } - if (j) - sendbufto_one(sptr); /* XXX DEAD */ - return 0; -} -#endif diff --git a/ircd/m_userip.c b/ircd/m_userip.c index 14ccba8..0f66e7b 100644 --- a/ircd/m_userip.c +++ b/ircd/m_userip.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" @@ -121,46 +113,3 @@ int m_userip(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_user_info(sptr, parv[1], RPL_USERIP, userip_formatter); return 0; } - - -#if 0 -/* - * m_userip added by Carlo Wood 3/8/97. - * - * The same as USERHOST, but with the IP-number instead of the hostname. - */ -int m_userip(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char *s; - int i, j = 5; - char *p = 0, *sbuf; - struct Client *acptr; - - if (parc < 2) - return need_more_params(sptr, "USERIP"); - - sbuf = sprintf_irc(sendbuf, rpl_str(RPL_USERIP), me.name, parv[0]); /* XXX DEAD */ - for (i = j, s = ircd_strtok(&p, parv[1], " "); i && s; - s = ircd_strtok(&p, (char *)0, " "), i--) - if ((acptr = FindUser(s))) - { - if (i < j) - *sbuf++ = ' '; - sbuf = sprintf_irc(sbuf, "%s%s=%c%s@%s", acptr->name, - IsAnOper(acptr) ? "*" : "", (acptr->user->away) ? '-' : '+', - acptr->user->username, ircd_ntoa((const char*) &acptr->ip)); - } - else - { - if (i < j) - sendbufto_one(sptr); /* XXX DEAD */ - sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], s); /* XXX DEAD */ - sbuf = sprintf_irc(sendbuf, rpl_str(RPL_USERIP), me.name, parv[0]); /* XXX DEAD */ - j = i - 1; - } - if (i < j) - sendbufto_one(sptr); /* XXX DEAD */ - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_version.c b/ircd/m_version.c index 65c3426..082deef 100644 --- a/ircd/m_version.c +++ b/ircd/m_version.c @@ -81,20 +81,13 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" #include "ircd_features.h" #include "ircd_policy.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "msg.h" #include "numeric.h" @@ -132,7 +125,7 @@ int m_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { char featurebuf[512]; - sprintf_irc(featurebuf,FEATURES,FEATURESVALUES); + ircd_snprintf(0, featurebuf, sizeof(featurebuf), FEATURES, FEATURESVALUES); send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me), debug_serveropts()); @@ -171,34 +164,3 @@ int ms_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - -#if 0 -/* - * m_version - * - * parv[0] = sender prefix - * parv[1] = remote server - */ -int m_version(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Client *acptr; - - if (MyConnect(sptr) && parc > 1) - { - if (!(acptr = find_match_server(parv[1]))) - { - sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]); /* XXX DEAD */ - return 0; - } - parv[1] = acptr->name; - } - - if (hunt_server(0, cptr, sptr, "%s%s " TOK_VERSION " :%s", 1, parc, parv) == /* XXX DEAD */ - HUNTED_ISME) - sendto_one(sptr, rpl_str(RPL_VERSION), /* XXX DEAD */ - me.name, parv[0], version, debugmode, me.name, serveropts); - - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_wallchops.c b/ircd/m_wallchops.c index f5163b4..9ff5a09 100644 --- a/ircd/m_wallchops.c +++ b/ircd/m_wallchops.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" @@ -161,60 +153,3 @@ int ms_wallchops(struct Client* cptr, struct Client* sptr, int parc, char* parv[ } return 0; } - -#if 0 -/* - * m_wallchops - * - * parv[0] = sender prefix - * parv[1] = target channel - * parv[parc - 1] = wallchops text - */ -int m_wallchops(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Channel *chptr; - - sptr->flags &= ~FLAGS_TS8; - - if (parc < 2 || *parv[1] == '\0') - { - sendto_one(sptr, err_str(ERR_NORECIPIENT), me.name, parv[0], "WALLCHOPS"); /* XXX DEAD */ - return -1; - } - - if (parc < 3 || *parv[parc - 1] == '\0') - { - sendto_one(sptr, err_str(ERR_NOTEXTTOSEND), me.name, parv[0]); /* XXX DEAD */ - return -1; - } - - if (MyUser(sptr)) - parv[1] = canonize(parv[1]); - - if (IsChannelName(parv[1])) - { - if ((chptr = FindChannel(parv[1]))) - { - if (client_can_send_to_channel(sptr, chptr)) - { - if (MyUser(sptr) && (chptr->mode.mode & MODE_NOPRIVMSGS) && - check_target_limit(sptr, chptr, chptr->chname, 0)) - return 0; - /* Send to local clients: */ - sendto_lchanops_butone(cptr, sptr, chptr, /* XXX DEAD */ - ":%s NOTICE @%s :%s", parv[0], parv[1], parv[parc - 1]); - /* And to other servers: */ - sendto_chanopsserv_butone(cptr, sptr, chptr, /* XXX DEAD */ - ":%s WC %s :%s", parv[0], parv[1], parv[parc - 1]); - } - else - sendto_one(sptr, err_str(ERR_CANNOTSENDTOCHAN), /* XXX DEAD */ - me.name, parv[0], parv[1]); - } - } - else - sendto_one(sptr, err_str(ERR_NOSUCHCHANNEL), me.name, parv[0], parv[1]); /* XXX DEAD */ - - return 0; -} -#endif /* 0 */ diff --git a/ircd/m_wallops.c b/ircd/m_wallops.c index 442a97d..466eeab 100644 --- a/ircd/m_wallops.c +++ b/ircd/m_wallops.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" diff --git a/ircd/m_wallusers.c b/ircd/m_wallusers.c index cd840d7..b453e88 100644 --- a/ircd/m_wallusers.c +++ b/ircd/m_wallusers.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "ircd_reply.h" #include "ircd_string.h" diff --git a/ircd/m_who.c b/ircd/m_who.c index d131248..052e562 100644 --- a/ircd/m_who.c +++ b/ircd/m_who.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" @@ -462,326 +454,3 @@ int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - - -#if 0 -/* - * m_who - * - * parv[0] = sender prefix - * parv[1] = nickname mask list - * parv[2] = additional selection flag, only 'o' for now. - * and %flags to specify what fields to output - * plus a ,querytype if the t flag is specified - * so the final thing will be like o%tnchu,777 - * parv[3] = _optional_ parameter that overrides parv[1] - * This can be used as "/quote who foo % :The Black Hacker - * to find me, parv[3] _can_ contain spaces !. - */ - -int m_who(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - char *mask; /* The mask we are looking for */ - char ch; /* Scratch char register */ - struct Channel *chptr; /* Channel to show */ - struct Client *acptr; /* Client to show */ - - int bitsel; /* Mask of selectors to apply */ - int matchsel; /* Wich fields the match should apply on */ - int counter; /* Query size counter, - initially used to count fields */ - int commas; /* Does our mask contain any comma ? - If so is a list.. */ - int fields; /* Mask of fields to show */ - int isthere = 0; /* When this set the user is member of chptr */ - char *nick; /* Single element extracted from - the mask list */ - char *p; /* Scratch char pointer */ - char *qrt; /* Pointer to the query type */ - static char mymask[512]; /* To save the mask before corrupting it */ - - /* Let's find where is our mask, and if actually contains something */ - mask = ((parc > 1) ? parv[1] : 0); - if (parc > 3 && parv[3]) - mask = parv[3]; - if (mask && ((mask[0] == '\0') || - (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*'))))) - mask = 0; - - /* Evaluate the flags now, we consider the second parameter - as "matchFlags%fieldsToInclude,querytype" */ - bitsel = fields = counter = matchsel = 0; - qrt = 0; - if (parc > 2 && parv[2] && *parv[2]) - { - p = parv[2]; - while (((ch = *(p++))) && (ch != '%') && (ch != ',')) - switch (ch) - { - case 'o': - case 'O': - bitsel |= WHOSELECT_OPER; - continue; - case 'x': - case 'X': - bitsel |= WHOSELECT_EXTRA; -#ifdef WPATH - if (IsAnOper(sptr)) - write_log(WPATH, "# " TIME_T_FMT " %s!%s@%s WHO %s %s\n", /* XXX DEAD */ - CurrentTime, sptr->name, sptr->user->username, sptr->user->host, - (BadPtr(parv[3]) ? parv[1] : parv[3]), parv[2]); -#endif /* WPATH */ - continue; - case 'n': - case 'N': - matchsel |= WHO_FIELD_NIC; - continue; - case 'u': - case 'U': - matchsel |= WHO_FIELD_UID; - continue; - case 'h': - case 'H': - matchsel |= WHO_FIELD_HOS; - continue; - case 'i': - case 'I': - matchsel |= WHO_FIELD_NIP; - continue; - case 's': - case 'S': - matchsel |= WHO_FIELD_SER; - continue; - case 'r': - case 'R': - matchsel |= WHO_FIELD_REN; - continue; - } - if (ch == '%') - while ((ch = *p++) && (ch != ',')) - { - counter++; - switch (ch) - { - case 'c': - case 'C': - fields |= WHO_FIELD_CHA; - break; - case 'd': - case 'D': - fields |= WHO_FIELD_DIS; - break; - case 'f': - case 'F': - fields |= WHO_FIELD_FLA; - break; - case 'h': - case 'H': - fields |= WHO_FIELD_HOS; - break; - case 'i': - case 'I': - fields |= WHO_FIELD_NIP; - break; - case 'n': - case 'N': - fields |= WHO_FIELD_NIC; - break; - case 'r': - case 'R': - fields |= WHO_FIELD_REN; - break; - case 's': - case 'S': - fields |= WHO_FIELD_SER; - break; - case 't': - case 'T': - fields |= WHO_FIELD_QTY; - break; - case 'u': - case 'U': - fields |= WHO_FIELD_UID; - break; - default: - break; - } - }; - if (ch) - qrt = p; - } - - if (!matchsel) - matchsel = WHO_FIELD_DEF; - if (!fields) - counter = 7; - - if (qrt && (fields & WHO_FIELD_QTY)) - { - p = qrt; - if (!((*p > '9') || (*p < '0'))) - p++; - if (!((*p > '9') || (*p < '0'))) - p++; - if (!((*p > '9') || (*p < '0'))) - p++; - *p = '\0'; - } - else - qrt = 0; - - /* I'd love to add also a check on the number of matches fields per time */ - counter = (2048 / (counter + 4)); - if (mask && (strlen(mask) > 510)) - mask[510] = '\0'; - move_marker(); - commas = (mask && strchr(mask, ',')); - - /* First treat mask as a list of plain nicks/channels */ - if (mask) - { - strcpy(mymask, mask); - for (p = 0, nick = ircd_strtok(&p, mymask, ","); nick; - nick = ircd_strtok(&p, 0, ",")) - { - if (IsChannelName(nick) && (chptr = FindChannel(nick))) - { - isthere = (find_channel_member(sptr, chptr) != 0); - if (isthere || SEE_CHANNEL(sptr, chptr, bitsel)) - { - struct Membership* member; - for (member = chptr->members; member; member = member->next_member) - { - acptr = member->user; - if ((bitsel & WHOSELECT_OPER) && !(IsAnOper(acptr))) - continue; - if ((acptr != sptr) && (member->status & CHFL_ZOMBIE)) - continue; - if (!(isthere || (SEE_USER(sptr, acptr, bitsel)))) - continue; - if (!Process(acptr)) /* This can't be moved before other checks */ - continue; - if (!(isthere || (SHOW_MORE(sptr, counter)))) - break; - do_who(sptr, acptr, chptr, fields, qrt); - } - } - } - else - { - if ((acptr = FindUser(nick)) && - ((!(bitsel & WHOSELECT_OPER)) || IsAnOper(acptr)) && - Process(acptr) && SHOW_MORE(sptr, counter)) - { - do_who(sptr, acptr, 0, fields, qrt); - } - } - } - } - - /* If we didn't have any comma in the mask treat it as a - real mask and try to match all relevant fields */ - if (!(commas || (counter < 1))) - { - int minlen, cset; - static struct in_mask imask; - if (mask) - { - matchcomp(mymask, &minlen, &cset, mask); - if (matchcompIP(&imask, mask)) - matchsel &= ~WHO_FIELD_NIP; - if ((minlen > NICKLEN) || !(cset & NTL_IRCNK)) - matchsel &= ~WHO_FIELD_NIC; - if ((matchsel & WHO_FIELD_SER) && - ((minlen > HOSTLEN) || (!(cset & NTL_IRCHN)) - || (!markMatchexServer(mymask, minlen)))) - matchsel &= ~WHO_FIELD_SER; - if ((minlen > USERLEN) || !(cset & NTL_IRCUI)) - matchsel &= ~WHO_FIELD_UID; - if ((minlen > HOSTLEN) || !(cset & NTL_IRCHN)) - matchsel &= ~WHO_FIELD_HOS; - } - - /* First of all loop through the clients in common channels */ - if ((!(counter < 1)) && matchsel) { - struct Membership* member; - struct Membership* chan; - for (chan = sptr->user->channel; chan; chan = chan->next_channel) { - chptr = chan->channel; - for (member = chptr->members; member; member = member->next_member) - { - acptr = member->user; - if (!(IsUser(acptr) && Process(acptr))) - continue; /* Now Process() is at the beginning, if we fail - we'll never have to show this acptr in this query */ - if ((bitsel & WHOSELECT_OPER) && !IsAnOper(acptr)) - continue; - if ((mask) && - ((!(matchsel & WHO_FIELD_NIC)) - || matchexec(acptr->name, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_UID)) - || matchexec(acptr->user->username, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_SER)) - || (!(acptr->user->server->flags & FLAGS_MAP))) - && ((!(matchsel & WHO_FIELD_HOS)) - || matchexec(acptr->user->host, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_REN)) - || matchexec(acptr->info, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_NIP)) - || ((((acptr->ip.s_addr & imask.mask.s_addr) != - imask.bits.s_addr)) || (imask.fall - && matchexec(inet_ntoa(acptr->ip), mymask, minlen))))) - continue; - if (!SHOW_MORE(sptr, counter)) - break; - do_who(sptr, acptr, chptr, fields, qrt); - } - } - } - /* Loop through all clients :-\, if we still have something to match to - and we can show more clients */ - if ((!(counter < 1)) && matchsel) - for (acptr = me.prev; acptr; acptr = acptr->prev) - { - if (!(IsUser(acptr) && Process(acptr))) - continue; - if ((bitsel & WHOSELECT_OPER) && !IsAnOper(acptr)) - continue; - if (!(SEE_USER(sptr, acptr, bitsel))) - continue; - if ((mask) && - ((!(matchsel & WHO_FIELD_NIC)) - || matchexec(acptr->name, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_UID)) - || matchexec(acptr->user->username, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_SER)) - || (!(acptr->user->server->flags & FLAGS_MAP))) - && ((!(matchsel & WHO_FIELD_HOS)) - || matchexec(acptr->user->host, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_REN)) - || matchexec(acptr->info, mymask, minlen)) - && ((!(matchsel & WHO_FIELD_NIP)) - || ((((acptr->ip.s_addr & imask.mask.s_addr) != imask.bits.s_addr)) - || (imask.fall - && matchexec(inet_ntoa(acptr->ip), mymask, minlen))))) - continue; - if (!SHOW_MORE(sptr, counter)) - break; - do_who(sptr, acptr, 0, fields, qrt); - } - } - - /* Make a clean mask suitable to be sent in the "end of" */ - if (mask && (p = strchr(mask, ' '))) - *p = '\0'; - sendto_one(sptr, rpl_str(RPL_ENDOFWHO), /* XXX DEAD */ - me.name, parv[0], BadPtr(mask) ? "*" : mask); - - /* Notify the user if we decided that his query was too long */ - if (counter < 0) - sendto_one(sptr, err_str(ERR_QUERYTOOLONG), me.name, parv[0], "WHO"); /* XXX DEAD */ - - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_whois.c b/ircd/m_whois.c index 5a5d8cb..45ac83b 100644 --- a/ircd/m_whois.c +++ b/ircd/m_whois.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "channel.h" #include "client.h" #include "hash.h" diff --git a/ircd/m_whowas.c b/ircd/m_whowas.c index 8090d0f..2d8e9d1 100644 --- a/ircd/m_whowas.c +++ b/ircd/m_whowas.c @@ -81,14 +81,6 @@ */ #include "config.h" -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ #include "client.h" #include "hash.h" #include "ircd.h" @@ -170,67 +162,3 @@ int m_whowas(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) send_reply(sptr, RPL_ENDOFWHOWAS, parv[1]); return 0; } - - -#if 0 -/* - * m_whowas - * - * parv[0] = sender prefix - * parv[1] = nickname queried - * parv[2] = maximum returned items (optional, default is unlimitted) - * parv[3] = remote server target (Opers only, max returned items 20) - */ -int m_whowas(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct Whowas *temp; - int cur = 0; - int max = -1, found = 0; - char *p, *nick, *s; - - if (parc < 2) - { - sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]); /* XXX DEAD */ - return 0; - } - if (parc > 2) - max = atoi(parv[2]); - if (parc > 3) - if (hunt_server(1, cptr, sptr, "%s%s " TOK_WHOWAS " %s %s :%s", 3, parc, parv)) /* XXX DEAD */ - return 0; - - parv[1] = canonize(parv[1]); - if (!MyConnect(sptr) && (max > 20)) - max = 20; /* Set max replies at 20 */ - for (s = parv[1]; (nick = ircd_strtok(&p, s, ",")); s = 0) - { - /* Search through bucket, finding all nicknames that match */ - found = 0; - for (temp = whowashash[hash_whowas_name(nick)]; temp; temp = temp->hnext) - { - if (0 == ircd_strcmp(nick, temp->name)) - { - sendto_one(sptr, rpl_str(RPL_WHOWASUSER), /* XXX DEAD */ - me.name, parv[0], temp->name, temp->username, - temp->hostname, temp->realname); - sendto_one(sptr, rpl_str(RPL_WHOISSERVER), me.name, parv[0], /* XXX DEAD */ - temp->name, temp->servername, myctime(temp->logoff)); - if (temp->away) - sendto_one(sptr, rpl_str(RPL_AWAY), /* XXX DEAD */ - me.name, parv[0], temp->name, temp->away); - cur++; - found++; - } - if (max >= 0 && cur >= max) - break; - } - if (!found) - sendto_one(sptr, err_str(ERR_WASNOSUCHNICK), me.name, parv[0], nick); /* XXX DEAD */ - /* To keep parv[1] intact for ENDOFWHOWAS */ - if (p) - p[-1] = ','; - } - sendto_one(sptr, rpl_str(RPL_ENDOFWHOWAS), me.name, parv[0], parv[1]); /* XXX DEAD */ - return 0; -} -#endif /* 0 */ diff --git a/ircd/res.c b/ircd/res.c index 3ded4cc..3af11a5 100644 --- a/ircd/res.c +++ b/ircd/res.c @@ -20,6 +20,7 @@ #include "ircd_log.h" #include "ircd_osdep.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "msg.h" #include "numeric.h" @@ -27,7 +28,6 @@ #include "s_debug.h" #include "s_misc.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "sys.h" @@ -335,7 +335,8 @@ static void start_resolver(void) spare_fd = open("/dev/null",O_RDONLY,0); if ((spare_fd < 0) || (spare_fd > 255)) { char sparemsg[80]; - sprintf_irc(sparemsg, "invalid spare_fd %d", spare_fd); + ircd_snprintf(0, sparemsg, sizeof(sparemsg), "invalid spare_fd %d", + spare_fd); server_restart(sparemsg); } @@ -715,9 +716,9 @@ static void do_query_number(const struct DNSQuery* query, assert(0 != addr); cp = (const unsigned char*) &addr->s_addr; - sprintf_irc(ipbuf, "%u.%u.%u.%u.in-addr.arpa.", - (unsigned int)(cp[3]), (unsigned int)(cp[2]), - (unsigned int)(cp[1]), (unsigned int)(cp[0])); + ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%u.%u.%u.%u.in-addr.arpa.", + (unsigned int)(cp[3]), (unsigned int)(cp[2]), + (unsigned int)(cp[1]), (unsigned int)(cp[0])); if (!request) { request = make_request(query); @@ -1449,9 +1450,6 @@ static struct CacheEntry* add_to_cache(struct CacheEntry* ocp) */ static void update_list(struct ResRequest* request, struct CacheEntry* cachep) { -#if 0 - struct CacheEntry** cpp; -#endif struct CacheEntry* cp = cachep; char* s; char* t; @@ -1466,17 +1464,6 @@ static void update_list(struct ResRequest* request, struct CacheEntry* cachep) * If found, move the entry to the top of the list and return. */ ++cainfo.ca_updates; -#if 0 - for (cpp = &cacheTop; *cpp; cpp = &((*cpp)->list_next)) { - if (cp == *cpp) - break; - } - if (!*cpp) - return; - *cpp = cp->list_next; - cp->list_next = cacheTop; - cacheTop = cp; -#endif if (!request) return; diff --git a/ircd/s_auth.c b/ircd/s_auth.c index 5ac1702..6ad278a 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -39,6 +39,7 @@ #include "ircd_features.h" #include "ircd_log.h" #include "ircd_osdep.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "list.h" #include "numeric.h" @@ -48,7 +49,6 @@ #include "s_debug.h" #include "s_misc.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "sys.h" /* TRUE bleah */ @@ -430,24 +430,14 @@ static int start_auth_query(struct AuthRequest* auth) assert(0 != auth->client); if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { -#if 0 - report_error(SOCKET_ERROR_MSG, get_client_name(auth->client, HIDE_IP), errno); -#endif ++ServerStats->is_abad; return 0; } if ((MAXCONNECTIONS - 10) < fd) { -#if 0 - report_error(CONNLIMIT_ERROR_MSG, - get_client_name(auth->client, HIDE_IP), errno); -#endif close(fd); return 0; } if (!os_set_nonblocking(fd)) { -#if 0 - report_error(NONB_ERROR_MSG, get_client_name(auth->client, HIDE_IP), errno); -#endif close(fd); return 0; } @@ -465,10 +455,6 @@ static int start_auth_query(struct AuthRequest* auth) local_addr.sin_port = htons(0); if (bind(fd, (struct sockaddr*) &local_addr, sizeof(struct sockaddr_in))) { -#if 0 - report_error(BIND_ERROR_MSG, - get_client_name(auth->client, HIDE_IP), errno); -#endif close(fd); return 0; } @@ -578,69 +564,6 @@ static char* check_ident_reply(char* reply) return token; } -#if 0 -/* - * GetValidIdent - parse ident query reply from identd server - * - * Inputs - pointer to ident buf - * Output - NULL if no valid ident found, otherwise pointer to name - * Side effects - - */ -static char* GetValidIdent(char *buf) -{ - int remp = 0; - int locp = 0; - char* colon1Ptr; - char* colon2Ptr; - char* colon3Ptr; - char* commaPtr; - char* remotePortString; - - /* All this to get rid of a sscanf() fun. */ - remotePortString = buf; - - colon1Ptr = strchr(remotePortString,':'); - if(!colon1Ptr) - return 0; - - *colon1Ptr = '\0'; - colon1Ptr++; - colon2Ptr = strchr(colon1Ptr,':'); - if(!colon2Ptr) - return 0; - - *colon2Ptr = '\0'; - colon2Ptr++; - commaPtr = strchr(remotePortString, ','); - - if(!commaPtr) - return 0; - - *commaPtr = '\0'; - commaPtr++; - - remp = atoi(remotePortString); - if(!remp) - return 0; - - locp = atoi(commaPtr); - if(!locp) - return 0; - - /* look for USERID bordered by first pair of colons */ - if(!strstr(colon1Ptr, "USERID")) - return 0; - - colon3Ptr = strchr(colon2Ptr,':'); - if(!colon3Ptr) - return 0; - - *colon3Ptr = '\0'; - colon3Ptr++; - return(colon3Ptr); -} -#endif - /* * start_auth - starts auth (identd) and dns queries for a client */ @@ -722,9 +645,9 @@ void send_auth_query(struct AuthRequest* auth) auth_error(auth, 1); return; } - sprintf_irc(authbuf, "%u , %u\r\n", - (unsigned int) ntohs(them.sin_port), - (unsigned int) ntohs(us.sin_port)); + ircd_snprintf(0, authbuf, sizeof(authbuf), "%u , %u\r\n", + (unsigned int) ntohs(them.sin_port), + (unsigned int) ntohs(us.sin_port)); if (IO_SUCCESS == os_send_nonb(auth->fd, authbuf, strlen(authbuf), &count)) { ClearAuthConnect(auth); @@ -780,9 +703,6 @@ void read_auth_reply(struct AuthRequest* auth) } else { ++ServerStats->is_abad; -#if 0 - strcpy(cli_username(auth->client), "unknown"); -#endif } unlink_auth_request(auth, &AuthPollList); @@ -793,5 +713,3 @@ void read_auth_reply(struct AuthRequest* auth) free_auth_request(auth); } } - - diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index ed5bc83..459c9d3 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -31,6 +31,7 @@ #include "ircd_features.h" #include "ircd_osdep.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "ircd.h" #include "list.h" @@ -49,7 +50,6 @@ #include "s_misc.h" #include "s_user.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "sys.h" @@ -890,7 +890,8 @@ int connect_server(struct ConfItem* aconf, struct Client* by, */ make_server(cptr); if (by && IsUser(by)) { - sprintf_irc(cli_serv(cptr)->by, "%s%s", NumNick(by)); + ircd_snprintf(0, cli_serv(cptr)->by, sizeof(cli_serv(cptr)->by), "%s%s", + NumNick(by)); assert(0 == cli_serv(cptr)->user); cli_serv(cptr)->user = cli_user(by); cli_user(by)->refcnt++; diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 05cd7ce..276d426 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -50,7 +50,6 @@ #include "s_debug.h" #include "s_misc.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "sys.h" @@ -882,7 +881,8 @@ void conf_add_deny(const char* const* fields, int count, int ip_kill) else { conf->bits = bits2; } - sprintf_irc(ipname, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]); + ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1], + ad[2], ad[3]); /* * This ensures endian correctness diff --git a/ircd/s_debug.c b/ircd/s_debug.c index 8e3728a..dca9205 100644 --- a/ircd/s_debug.c +++ b/ircd/s_debug.c @@ -290,13 +290,6 @@ void count_memory(struct Client *cptr, char *nick) { ch++; chm += (strlen(chptr->chname) + sizeof(struct Channel)); -#if 0 - /* - * XXX - Members already counted in clients, don't count twice - */ - for (member = chptr->members; member; member = member->next_member) - chu++; -#endif for (link = chptr->invites; link; link = link->next) chi++; for (link = chptr->banlist; link; link = link->next) diff --git a/ircd/s_err.c b/ircd/s_err.c index f5a382d..837952b 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -22,7 +22,6 @@ #include "numeric.h" #include "s_debug.h" -#include "sprintf_irc.h" #include #include @@ -1245,6 +1244,212 @@ const struct Numeric* get_error_numeric(int n) static char numbuff[512]; +/* *INDENT-OFF* */ + +static const char atoi_tab[4000] = { + '0','0','0',0, '0','0','1',0, '0','0','2',0, '0','0','3',0, '0','0','4',0, + '0','0','5',0, '0','0','6',0, '0','0','7',0, '0','0','8',0, '0','0','9',0, + '0','1','0',0, '0','1','1',0, '0','1','2',0, '0','1','3',0, '0','1','4',0, + '0','1','5',0, '0','1','6',0, '0','1','7',0, '0','1','8',0, '0','1','9',0, + '0','2','0',0, '0','2','1',0, '0','2','2',0, '0','2','3',0, '0','2','4',0, + '0','2','5',0, '0','2','6',0, '0','2','7',0, '0','2','8',0, '0','2','9',0, + '0','3','0',0, '0','3','1',0, '0','3','2',0, '0','3','3',0, '0','3','4',0, + '0','3','5',0, '0','3','6',0, '0','3','7',0, '0','3','8',0, '0','3','9',0, + '0','4','0',0, '0','4','1',0, '0','4','2',0, '0','4','3',0, '0','4','4',0, + '0','4','5',0, '0','4','6',0, '0','4','7',0, '0','4','8',0, '0','4','9',0, + '0','5','0',0, '0','5','1',0, '0','5','2',0, '0','5','3',0, '0','5','4',0, + '0','5','5',0, '0','5','6',0, '0','5','7',0, '0','5','8',0, '0','5','9',0, + '0','6','0',0, '0','6','1',0, '0','6','2',0, '0','6','3',0, '0','6','4',0, + '0','6','5',0, '0','6','6',0, '0','6','7',0, '0','6','8',0, '0','6','9',0, + '0','7','0',0, '0','7','1',0, '0','7','2',0, '0','7','3',0, '0','7','4',0, + '0','7','5',0, '0','7','6',0, '0','7','7',0, '0','7','8',0, '0','7','9',0, + '0','8','0',0, '0','8','1',0, '0','8','2',0, '0','8','3',0, '0','8','4',0, + '0','8','5',0, '0','8','6',0, '0','8','7',0, '0','8','8',0, '0','8','9',0, + '0','9','0',0, '0','9','1',0, '0','9','2',0, '0','9','3',0, '0','9','4',0, + '0','9','5',0, '0','9','6',0, '0','9','7',0, '0','9','8',0, '0','9','9',0, + '1','0','0',0, '1','0','1',0, '1','0','2',0, '1','0','3',0, '1','0','4',0, + '1','0','5',0, '1','0','6',0, '1','0','7',0, '1','0','8',0, '1','0','9',0, + '1','1','0',0, '1','1','1',0, '1','1','2',0, '1','1','3',0, '1','1','4',0, + '1','1','5',0, '1','1','6',0, '1','1','7',0, '1','1','8',0, '1','1','9',0, + '1','2','0',0, '1','2','1',0, '1','2','2',0, '1','2','3',0, '1','2','4',0, + '1','2','5',0, '1','2','6',0, '1','2','7',0, '1','2','8',0, '1','2','9',0, + '1','3','0',0, '1','3','1',0, '1','3','2',0, '1','3','3',0, '1','3','4',0, + '1','3','5',0, '1','3','6',0, '1','3','7',0, '1','3','8',0, '1','3','9',0, + '1','4','0',0, '1','4','1',0, '1','4','2',0, '1','4','3',0, '1','4','4',0, + '1','4','5',0, '1','4','6',0, '1','4','7',0, '1','4','8',0, '1','4','9',0, + '1','5','0',0, '1','5','1',0, '1','5','2',0, '1','5','3',0, '1','5','4',0, + '1','5','5',0, '1','5','6',0, '1','5','7',0, '1','5','8',0, '1','5','9',0, + '1','6','0',0, '1','6','1',0, '1','6','2',0, '1','6','3',0, '1','6','4',0, + '1','6','5',0, '1','6','6',0, '1','6','7',0, '1','6','8',0, '1','6','9',0, + '1','7','0',0, '1','7','1',0, '1','7','2',0, '1','7','3',0, '1','7','4',0, + '1','7','5',0, '1','7','6',0, '1','7','7',0, '1','7','8',0, '1','7','9',0, + '1','8','0',0, '1','8','1',0, '1','8','2',0, '1','8','3',0, '1','8','4',0, + '1','8','5',0, '1','8','6',0, '1','8','7',0, '1','8','8',0, '1','8','9',0, + '1','9','0',0, '1','9','1',0, '1','9','2',0, '1','9','3',0, '1','9','4',0, + '1','9','5',0, '1','9','6',0, '1','9','7',0, '1','9','8',0, '1','9','9',0, + '2','0','0',0, '2','0','1',0, '2','0','2',0, '2','0','3',0, '2','0','4',0, + '2','0','5',0, '2','0','6',0, '2','0','7',0, '2','0','8',0, '2','0','9',0, + '2','1','0',0, '2','1','1',0, '2','1','2',0, '2','1','3',0, '2','1','4',0, + '2','1','5',0, '2','1','6',0, '2','1','7',0, '2','1','8',0, '2','1','9',0, + '2','2','0',0, '2','2','1',0, '2','2','2',0, '2','2','3',0, '2','2','4',0, + '2','2','5',0, '2','2','6',0, '2','2','7',0, '2','2','8',0, '2','2','9',0, + '2','3','0',0, '2','3','1',0, '2','3','2',0, '2','3','3',0, '2','3','4',0, + '2','3','5',0, '2','3','6',0, '2','3','7',0, '2','3','8',0, '2','3','9',0, + '2','4','0',0, '2','4','1',0, '2','4','2',0, '2','4','3',0, '2','4','4',0, + '2','4','5',0, '2','4','6',0, '2','4','7',0, '2','4','8',0, '2','4','9',0, + '2','5','0',0, '2','5','1',0, '2','5','2',0, '2','5','3',0, '2','5','4',0, + '2','5','5',0, '2','5','6',0, '2','5','7',0, '2','5','8',0, '2','5','9',0, + '2','6','0',0, '2','6','1',0, '2','6','2',0, '2','6','3',0, '2','6','4',0, + '2','6','5',0, '2','6','6',0, '2','6','7',0, '2','6','8',0, '2','6','9',0, + '2','7','0',0, '2','7','1',0, '2','7','2',0, '2','7','3',0, '2','7','4',0, + '2','7','5',0, '2','7','6',0, '2','7','7',0, '2','7','8',0, '2','7','9',0, + '2','8','0',0, '2','8','1',0, '2','8','2',0, '2','8','3',0, '2','8','4',0, + '2','8','5',0, '2','8','6',0, '2','8','7',0, '2','8','8',0, '2','8','9',0, + '2','9','0',0, '2','9','1',0, '2','9','2',0, '2','9','3',0, '2','9','4',0, + '2','9','5',0, '2','9','6',0, '2','9','7',0, '2','9','8',0, '2','9','9',0, + '3','0','0',0, '3','0','1',0, '3','0','2',0, '3','0','3',0, '3','0','4',0, + '3','0','5',0, '3','0','6',0, '3','0','7',0, '3','0','8',0, '3','0','9',0, + '3','1','0',0, '3','1','1',0, '3','1','2',0, '3','1','3',0, '3','1','4',0, + '3','1','5',0, '3','1','6',0, '3','1','7',0, '3','1','8',0, '3','1','9',0, + '3','2','0',0, '3','2','1',0, '3','2','2',0, '3','2','3',0, '3','2','4',0, + '3','2','5',0, '3','2','6',0, '3','2','7',0, '3','2','8',0, '3','2','9',0, + '3','3','0',0, '3','3','1',0, '3','3','2',0, '3','3','3',0, '3','3','4',0, + '3','3','5',0, '3','3','6',0, '3','3','7',0, '3','3','8',0, '3','3','9',0, + '3','4','0',0, '3','4','1',0, '3','4','2',0, '3','4','3',0, '3','4','4',0, + '3','4','5',0, '3','4','6',0, '3','4','7',0, '3','4','8',0, '3','4','9',0, + '3','5','0',0, '3','5','1',0, '3','5','2',0, '3','5','3',0, '3','5','4',0, + '3','5','5',0, '3','5','6',0, '3','5','7',0, '3','5','8',0, '3','5','9',0, + '3','6','0',0, '3','6','1',0, '3','6','2',0, '3','6','3',0, '3','6','4',0, + '3','6','5',0, '3','6','6',0, '3','6','7',0, '3','6','8',0, '3','6','9',0, + '3','7','0',0, '3','7','1',0, '3','7','2',0, '3','7','3',0, '3','7','4',0, + '3','7','5',0, '3','7','6',0, '3','7','7',0, '3','7','8',0, '3','7','9',0, + '3','8','0',0, '3','8','1',0, '3','8','2',0, '3','8','3',0, '3','8','4',0, + '3','8','5',0, '3','8','6',0, '3','8','7',0, '3','8','8',0, '3','8','9',0, + '3','9','0',0, '3','9','1',0, '3','9','2',0, '3','9','3',0, '3','9','4',0, + '3','9','5',0, '3','9','6',0, '3','9','7',0, '3','9','8',0, '3','9','9',0, + '4','0','0',0, '4','0','1',0, '4','0','2',0, '4','0','3',0, '4','0','4',0, + '4','0','5',0, '4','0','6',0, '4','0','7',0, '4','0','8',0, '4','0','9',0, + '4','1','0',0, '4','1','1',0, '4','1','2',0, '4','1','3',0, '4','1','4',0, + '4','1','5',0, '4','1','6',0, '4','1','7',0, '4','1','8',0, '4','1','9',0, + '4','2','0',0, '4','2','1',0, '4','2','2',0, '4','2','3',0, '4','2','4',0, + '4','2','5',0, '4','2','6',0, '4','2','7',0, '4','2','8',0, '4','2','9',0, + '4','3','0',0, '4','3','1',0, '4','3','2',0, '4','3','3',0, '4','3','4',0, + '4','3','5',0, '4','3','6',0, '4','3','7',0, '4','3','8',0, '4','3','9',0, + '4','4','0',0, '4','4','1',0, '4','4','2',0, '4','4','3',0, '4','4','4',0, + '4','4','5',0, '4','4','6',0, '4','4','7',0, '4','4','8',0, '4','4','9',0, + '4','5','0',0, '4','5','1',0, '4','5','2',0, '4','5','3',0, '4','5','4',0, + '4','5','5',0, '4','5','6',0, '4','5','7',0, '4','5','8',0, '4','5','9',0, + '4','6','0',0, '4','6','1',0, '4','6','2',0, '4','6','3',0, '4','6','4',0, + '4','6','5',0, '4','6','6',0, '4','6','7',0, '4','6','8',0, '4','6','9',0, + '4','7','0',0, '4','7','1',0, '4','7','2',0, '4','7','3',0, '4','7','4',0, + '4','7','5',0, '4','7','6',0, '4','7','7',0, '4','7','8',0, '4','7','9',0, + '4','8','0',0, '4','8','1',0, '4','8','2',0, '4','8','3',0, '4','8','4',0, + '4','8','5',0, '4','8','6',0, '4','8','7',0, '4','8','8',0, '4','8','9',0, + '4','9','0',0, '4','9','1',0, '4','9','2',0, '4','9','3',0, '4','9','4',0, + '4','9','5',0, '4','9','6',0, '4','9','7',0, '4','9','8',0, '4','9','9',0, + '5','0','0',0, '5','0','1',0, '5','0','2',0, '5','0','3',0, '5','0','4',0, + '5','0','5',0, '5','0','6',0, '5','0','7',0, '5','0','8',0, '5','0','9',0, + '5','1','0',0, '5','1','1',0, '5','1','2',0, '5','1','3',0, '5','1','4',0, + '5','1','5',0, '5','1','6',0, '5','1','7',0, '5','1','8',0, '5','1','9',0, + '5','2','0',0, '5','2','1',0, '5','2','2',0, '5','2','3',0, '5','2','4',0, + '5','2','5',0, '5','2','6',0, '5','2','7',0, '5','2','8',0, '5','2','9',0, + '5','3','0',0, '5','3','1',0, '5','3','2',0, '5','3','3',0, '5','3','4',0, + '5','3','5',0, '5','3','6',0, '5','3','7',0, '5','3','8',0, '5','3','9',0, + '5','4','0',0, '5','4','1',0, '5','4','2',0, '5','4','3',0, '5','4','4',0, + '5','4','5',0, '5','4','6',0, '5','4','7',0, '5','4','8',0, '5','4','9',0, + '5','5','0',0, '5','5','1',0, '5','5','2',0, '5','5','3',0, '5','5','4',0, + '5','5','5',0, '5','5','6',0, '5','5','7',0, '5','5','8',0, '5','5','9',0, + '5','6','0',0, '5','6','1',0, '5','6','2',0, '5','6','3',0, '5','6','4',0, + '5','6','5',0, '5','6','6',0, '5','6','7',0, '5','6','8',0, '5','6','9',0, + '5','7','0',0, '5','7','1',0, '5','7','2',0, '5','7','3',0, '5','7','4',0, + '5','7','5',0, '5','7','6',0, '5','7','7',0, '5','7','8',0, '5','7','9',0, + '5','8','0',0, '5','8','1',0, '5','8','2',0, '5','8','3',0, '5','8','4',0, + '5','8','5',0, '5','8','6',0, '5','8','7',0, '5','8','8',0, '5','8','9',0, + '5','9','0',0, '5','9','1',0, '5','9','2',0, '5','9','3',0, '5','9','4',0, + '5','9','5',0, '5','9','6',0, '5','9','7',0, '5','9','8',0, '5','9','9',0, + '6','0','0',0, '6','0','1',0, '6','0','2',0, '6','0','3',0, '6','0','4',0, + '6','0','5',0, '6','0','6',0, '6','0','7',0, '6','0','8',0, '6','0','9',0, + '6','1','0',0, '6','1','1',0, '6','1','2',0, '6','1','3',0, '6','1','4',0, + '6','1','5',0, '6','1','6',0, '6','1','7',0, '6','1','8',0, '6','1','9',0, + '6','2','0',0, '6','2','1',0, '6','2','2',0, '6','2','3',0, '6','2','4',0, + '6','2','5',0, '6','2','6',0, '6','2','7',0, '6','2','8',0, '6','2','9',0, + '6','3','0',0, '6','3','1',0, '6','3','2',0, '6','3','3',0, '6','3','4',0, + '6','3','5',0, '6','3','6',0, '6','3','7',0, '6','3','8',0, '6','3','9',0, + '6','4','0',0, '6','4','1',0, '6','4','2',0, '6','4','3',0, '6','4','4',0, + '6','4','5',0, '6','4','6',0, '6','4','7',0, '6','4','8',0, '6','4','9',0, + '6','5','0',0, '6','5','1',0, '6','5','2',0, '6','5','3',0, '6','5','4',0, + '6','5','5',0, '6','5','6',0, '6','5','7',0, '6','5','8',0, '6','5','9',0, + '6','6','0',0, '6','6','1',0, '6','6','2',0, '6','6','3',0, '6','6','4',0, + '6','6','5',0, '6','6','6',0, '6','6','7',0, '6','6','8',0, '6','6','9',0, + '6','7','0',0, '6','7','1',0, '6','7','2',0, '6','7','3',0, '6','7','4',0, + '6','7','5',0, '6','7','6',0, '6','7','7',0, '6','7','8',0, '6','7','9',0, + '6','8','0',0, '6','8','1',0, '6','8','2',0, '6','8','3',0, '6','8','4',0, + '6','8','5',0, '6','8','6',0, '6','8','7',0, '6','8','8',0, '6','8','9',0, + '6','9','0',0, '6','9','1',0, '6','9','2',0, '6','9','3',0, '6','9','4',0, + '6','9','5',0, '6','9','6',0, '6','9','7',0, '6','9','8',0, '6','9','9',0, + '7','0','0',0, '7','0','1',0, '7','0','2',0, '7','0','3',0, '7','0','4',0, + '7','0','5',0, '7','0','6',0, '7','0','7',0, '7','0','8',0, '7','0','9',0, + '7','1','0',0, '7','1','1',0, '7','1','2',0, '7','1','3',0, '7','1','4',0, + '7','1','5',0, '7','1','6',0, '7','1','7',0, '7','1','8',0, '7','1','9',0, + '7','2','0',0, '7','2','1',0, '7','2','2',0, '7','2','3',0, '7','2','4',0, + '7','2','5',0, '7','2','6',0, '7','2','7',0, '7','2','8',0, '7','2','9',0, + '7','3','0',0, '7','3','1',0, '7','3','2',0, '7','3','3',0, '7','3','4',0, + '7','3','5',0, '7','3','6',0, '7','3','7',0, '7','3','8',0, '7','3','9',0, + '7','4','0',0, '7','4','1',0, '7','4','2',0, '7','4','3',0, '7','4','4',0, + '7','4','5',0, '7','4','6',0, '7','4','7',0, '7','4','8',0, '7','4','9',0, + '7','5','0',0, '7','5','1',0, '7','5','2',0, '7','5','3',0, '7','5','4',0, + '7','5','5',0, '7','5','6',0, '7','5','7',0, '7','5','8',0, '7','5','9',0, + '7','6','0',0, '7','6','1',0, '7','6','2',0, '7','6','3',0, '7','6','4',0, + '7','6','5',0, '7','6','6',0, '7','6','7',0, '7','6','8',0, '7','6','9',0, + '7','7','0',0, '7','7','1',0, '7','7','2',0, '7','7','3',0, '7','7','4',0, + '7','7','5',0, '7','7','6',0, '7','7','7',0, '7','7','8',0, '7','7','9',0, + '7','8','0',0, '7','8','1',0, '7','8','2',0, '7','8','3',0, '7','8','4',0, + '7','8','5',0, '7','8','6',0, '7','8','7',0, '7','8','8',0, '7','8','9',0, + '7','9','0',0, '7','9','1',0, '7','9','2',0, '7','9','3',0, '7','9','4',0, + '7','9','5',0, '7','9','6',0, '7','9','7',0, '7','9','8',0, '7','9','9',0, + '8','0','0',0, '8','0','1',0, '8','0','2',0, '8','0','3',0, '8','0','4',0, + '8','0','5',0, '8','0','6',0, '8','0','7',0, '8','0','8',0, '8','0','9',0, + '8','1','0',0, '8','1','1',0, '8','1','2',0, '8','1','3',0, '8','1','4',0, + '8','1','5',0, '8','1','6',0, '8','1','7',0, '8','1','8',0, '8','1','9',0, + '8','2','0',0, '8','2','1',0, '8','2','2',0, '8','2','3',0, '8','2','4',0, + '8','2','5',0, '8','2','6',0, '8','2','7',0, '8','2','8',0, '8','2','9',0, + '8','3','0',0, '8','3','1',0, '8','3','2',0, '8','3','3',0, '8','3','4',0, + '8','3','5',0, '8','3','6',0, '8','3','7',0, '8','3','8',0, '8','3','9',0, + '8','4','0',0, '8','4','1',0, '8','4','2',0, '8','4','3',0, '8','4','4',0, + '8','4','5',0, '8','4','6',0, '8','4','7',0, '8','4','8',0, '8','4','9',0, + '8','5','0',0, '8','5','1',0, '8','5','2',0, '8','5','3',0, '8','5','4',0, + '8','5','5',0, '8','5','6',0, '8','5','7',0, '8','5','8',0, '8','5','9',0, + '8','6','0',0, '8','6','1',0, '8','6','2',0, '8','6','3',0, '8','6','4',0, + '8','6','5',0, '8','6','6',0, '8','6','7',0, '8','6','8',0, '8','6','9',0, + '8','7','0',0, '8','7','1',0, '8','7','2',0, '8','7','3',0, '8','7','4',0, + '8','7','5',0, '8','7','6',0, '8','7','7',0, '8','7','8',0, '8','7','9',0, + '8','8','0',0, '8','8','1',0, '8','8','2',0, '8','8','3',0, '8','8','4',0, + '8','8','5',0, '8','8','6',0, '8','8','7',0, '8','8','8',0, '8','8','9',0, + '8','9','0',0, '8','9','1',0, '8','9','2',0, '8','9','3',0, '8','9','4',0, + '8','9','5',0, '8','9','6',0, '8','9','7',0, '8','9','8',0, '8','9','9',0, + '9','0','0',0, '9','0','1',0, '9','0','2',0, '9','0','3',0, '9','0','4',0, + '9','0','5',0, '9','0','6',0, '9','0','7',0, '9','0','8',0, '9','0','9',0, + '9','1','0',0, '9','1','1',0, '9','1','2',0, '9','1','3',0, '9','1','4',0, + '9','1','5',0, '9','1','6',0, '9','1','7',0, '9','1','8',0, '9','1','9',0, + '9','2','0',0, '9','2','1',0, '9','2','2',0, '9','2','3',0, '9','2','4',0, + '9','2','5',0, '9','2','6',0, '9','2','7',0, '9','2','8',0, '9','2','9',0, + '9','3','0',0, '9','3','1',0, '9','3','2',0, '9','3','3',0, '9','3','4',0, + '9','3','5',0, '9','3','6',0, '9','3','7',0, '9','3','8',0, '9','3','9',0, + '9','4','0',0, '9','4','1',0, '9','4','2',0, '9','4','3',0, '9','4','4',0, + '9','4','5',0, '9','4','6',0, '9','4','7',0, '9','4','8',0, '9','4','9',0, + '9','5','0',0, '9','5','1',0, '9','5','2',0, '9','5','3',0, '9','5','4',0, + '9','5','5',0, '9','5','6',0, '9','5','7',0, '9','5','8',0, '9','5','9',0, + '9','6','0',0, '9','6','1',0, '9','6','2',0, '9','6','3',0, '9','6','4',0, + '9','6','5',0, '9','6','6',0, '9','6','7',0, '9','6','8',0, '9','6','9',0, + '9','7','0',0, '9','7','1',0, '9','7','2',0, '9','7','3',0, '9','7','4',0, + '9','7','5',0, '9','7','6',0, '9','7','7',0, '9','7','8',0, '9','7','9',0, + '9','8','0',0, '9','8','1',0, '9','8','2',0, '9','8','3',0, '9','8','4',0, + '9','8','5',0, '9','8','6',0, '9','8','7',0, '9','8','8',0, '9','8','9',0, + '9','9','0',0, '9','9','1',0, '9','9','2',0, '9','9','3',0, '9','9','4',0, + '9','9','5',0, '9','9','6',0, '9','9','7',0, '9','9','8',0, '9','9','9',0 }; + +/* *INDENT-ON* */ + /* "inline" */ #define prepbuf(buffer, num, tail) \ { \ diff --git a/ircd/s_misc.c b/ircd/s_misc.c index aafdb25..99ed512 100644 --- a/ircd/s_misc.c +++ b/ircd/s_misc.c @@ -34,6 +34,7 @@ #include "ircd_log.h" #include "ircd_policy.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "list.h" #include "match.h" @@ -48,7 +49,6 @@ #include "s_debug.h" #include "s_user.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "sys.h" @@ -168,7 +168,7 @@ const char* get_client_name(const struct Client* sptr, int showip) if (MyConnect(sptr)) { if (showip) - sprintf_irc(nbuf, "%s[%s@%s]", cli_name(sptr), + ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr), (IsIdented(sptr)) ? cli_username(sptr) : "", cli_sock_ip(sptr)); else return cli_name(sptr); @@ -498,7 +498,7 @@ int vexit_client_msg(struct Client *cptr, struct Client *bcptr, struct Client *s const char *pattern, va_list vl) { char msgbuf[1024]; - vsprintf_irc(msgbuf, pattern, vl); + ircd_vsnprintf(0, msgbuf, sizeof(msgbuf), pattern, vl); return exit_client(cptr, bcptr, sptr, msgbuf); } @@ -509,7 +509,7 @@ int exit_client_msg(struct Client *cptr, struct Client *bcptr, char msgbuf[1024]; va_start(vl, pattern); - vsprintf_irc(msgbuf, pattern, vl); + ircd_vsnprintf(0, msgbuf, sizeof(msgbuf), pattern, vl); va_end(vl); return exit_client(cptr, bcptr, sptr, msgbuf); diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 5b8cb84..e7b3ddf 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -51,7 +51,6 @@ #include "s_misc.h" #include "s_user.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "sys.h" #include "userload.h" diff --git a/ircd/s_user.c b/ircd/s_user.c index 3887a99..3af97a6 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -37,6 +37,7 @@ #include "ircd_log.h" #include "ircd_policy.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "list.h" #include "match.h" @@ -54,7 +55,6 @@ #include "s_misc.h" #include "s_serv.h" /* max_client_count */ #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "supported.h" @@ -567,7 +567,7 @@ int register_user(struct Client *cptr, struct Client *sptr, send_reply(sptr, RPL_YOURHOST, cli_name(&me), version); send_reply(sptr, RPL_CREATED, creation); send_reply(sptr, RPL_MYINFO, cli_name(&me), version); - sprintf_irc(featurebuf,FEATURES,FEATURESVALUES); + ircd_snprintf(0, featurebuf, sizeof(featurebuf), FEATURES, FEATURESVALUES); send_reply(sptr, RPL_ISUPPORT, featurebuf); m_lusers(sptr, sptr, 1, parv); update_load(); @@ -1448,9 +1448,10 @@ int is_silenced(struct Client *sptr, struct Client *acptr) if (!cli_user(acptr) || !(lp = cli_user(acptr)->silence) || !(user = cli_user(sptr))) return 0; - sprintf_irc(sender, "%s!%s@%s", cli_name(sptr), user->username, user->host); - sprintf_irc(senderip, "%s!%s@%s", cli_name(sptr), user->username, - ircd_ntoa((const char*) &(cli_ip(sptr)))); + ircd_snprintf(0, sender, sizeof(sender), "%s!%s@%s", cli_name(sptr), + user->username, user->host); + ircd_snprintf(0, senderip, sizeof(senderip), "%s!%s@%s", cli_name(sptr), + user->username, ircd_ntoa((const char*) &(cli_ip(sptr)))); for (; lp; lp = lp->next) { if ((!(lp->flags & CHFL_SILENCE_IPMASK) && !match(lp->value.cp, sender)) || diff --git a/ircd/send.c b/ircd/send.c index 6da453b..6f7e1d3 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -36,7 +36,6 @@ #include "s_debug.h" #include "s_misc.h" #include "s_user.h" -#include "sprintf_irc.h" #include "struct.h" #include "sys.h" diff --git a/ircd/sprintf_irc.c b/ircd/sprintf_irc.c deleted file mode 100644 index a9dc53b..0000000 --- a/ircd/sprintf_irc.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * IRC - Internet Relay Chat, ircd/sprintf_irc.c - * - * (C) Copyright 1997 - * - * Author: - * - * 1024/624ACAD5 1997/01/26 Carlo Wood, Run on IRC - * Key fingerprint = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 - * Get key from pgp-public-keys server or - * finger carlo@runaway.xs4all.nl for public key (dialin, try at 21-22h GMT). - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -#include "config.h" - -#include "sprintf_irc.h" -#include "sys.h" -#include - - -/* *INDENT-OFF* */ - -const char atoi_tab[4000] = { - '0','0','0',0, '0','0','1',0, '0','0','2',0, '0','0','3',0, '0','0','4',0, - '0','0','5',0, '0','0','6',0, '0','0','7',0, '0','0','8',0, '0','0','9',0, - '0','1','0',0, '0','1','1',0, '0','1','2',0, '0','1','3',0, '0','1','4',0, - '0','1','5',0, '0','1','6',0, '0','1','7',0, '0','1','8',0, '0','1','9',0, - '0','2','0',0, '0','2','1',0, '0','2','2',0, '0','2','3',0, '0','2','4',0, - '0','2','5',0, '0','2','6',0, '0','2','7',0, '0','2','8',0, '0','2','9',0, - '0','3','0',0, '0','3','1',0, '0','3','2',0, '0','3','3',0, '0','3','4',0, - '0','3','5',0, '0','3','6',0, '0','3','7',0, '0','3','8',0, '0','3','9',0, - '0','4','0',0, '0','4','1',0, '0','4','2',0, '0','4','3',0, '0','4','4',0, - '0','4','5',0, '0','4','6',0, '0','4','7',0, '0','4','8',0, '0','4','9',0, - '0','5','0',0, '0','5','1',0, '0','5','2',0, '0','5','3',0, '0','5','4',0, - '0','5','5',0, '0','5','6',0, '0','5','7',0, '0','5','8',0, '0','5','9',0, - '0','6','0',0, '0','6','1',0, '0','6','2',0, '0','6','3',0, '0','6','4',0, - '0','6','5',0, '0','6','6',0, '0','6','7',0, '0','6','8',0, '0','6','9',0, - '0','7','0',0, '0','7','1',0, '0','7','2',0, '0','7','3',0, '0','7','4',0, - '0','7','5',0, '0','7','6',0, '0','7','7',0, '0','7','8',0, '0','7','9',0, - '0','8','0',0, '0','8','1',0, '0','8','2',0, '0','8','3',0, '0','8','4',0, - '0','8','5',0, '0','8','6',0, '0','8','7',0, '0','8','8',0, '0','8','9',0, - '0','9','0',0, '0','9','1',0, '0','9','2',0, '0','9','3',0, '0','9','4',0, - '0','9','5',0, '0','9','6',0, '0','9','7',0, '0','9','8',0, '0','9','9',0, - '1','0','0',0, '1','0','1',0, '1','0','2',0, '1','0','3',0, '1','0','4',0, - '1','0','5',0, '1','0','6',0, '1','0','7',0, '1','0','8',0, '1','0','9',0, - '1','1','0',0, '1','1','1',0, '1','1','2',0, '1','1','3',0, '1','1','4',0, - '1','1','5',0, '1','1','6',0, '1','1','7',0, '1','1','8',0, '1','1','9',0, - '1','2','0',0, '1','2','1',0, '1','2','2',0, '1','2','3',0, '1','2','4',0, - '1','2','5',0, '1','2','6',0, '1','2','7',0, '1','2','8',0, '1','2','9',0, - '1','3','0',0, '1','3','1',0, '1','3','2',0, '1','3','3',0, '1','3','4',0, - '1','3','5',0, '1','3','6',0, '1','3','7',0, '1','3','8',0, '1','3','9',0, - '1','4','0',0, '1','4','1',0, '1','4','2',0, '1','4','3',0, '1','4','4',0, - '1','4','5',0, '1','4','6',0, '1','4','7',0, '1','4','8',0, '1','4','9',0, - '1','5','0',0, '1','5','1',0, '1','5','2',0, '1','5','3',0, '1','5','4',0, - '1','5','5',0, '1','5','6',0, '1','5','7',0, '1','5','8',0, '1','5','9',0, - '1','6','0',0, '1','6','1',0, '1','6','2',0, '1','6','3',0, '1','6','4',0, - '1','6','5',0, '1','6','6',0, '1','6','7',0, '1','6','8',0, '1','6','9',0, - '1','7','0',0, '1','7','1',0, '1','7','2',0, '1','7','3',0, '1','7','4',0, - '1','7','5',0, '1','7','6',0, '1','7','7',0, '1','7','8',0, '1','7','9',0, - '1','8','0',0, '1','8','1',0, '1','8','2',0, '1','8','3',0, '1','8','4',0, - '1','8','5',0, '1','8','6',0, '1','8','7',0, '1','8','8',0, '1','8','9',0, - '1','9','0',0, '1','9','1',0, '1','9','2',0, '1','9','3',0, '1','9','4',0, - '1','9','5',0, '1','9','6',0, '1','9','7',0, '1','9','8',0, '1','9','9',0, - '2','0','0',0, '2','0','1',0, '2','0','2',0, '2','0','3',0, '2','0','4',0, - '2','0','5',0, '2','0','6',0, '2','0','7',0, '2','0','8',0, '2','0','9',0, - '2','1','0',0, '2','1','1',0, '2','1','2',0, '2','1','3',0, '2','1','4',0, - '2','1','5',0, '2','1','6',0, '2','1','7',0, '2','1','8',0, '2','1','9',0, - '2','2','0',0, '2','2','1',0, '2','2','2',0, '2','2','3',0, '2','2','4',0, - '2','2','5',0, '2','2','6',0, '2','2','7',0, '2','2','8',0, '2','2','9',0, - '2','3','0',0, '2','3','1',0, '2','3','2',0, '2','3','3',0, '2','3','4',0, - '2','3','5',0, '2','3','6',0, '2','3','7',0, '2','3','8',0, '2','3','9',0, - '2','4','0',0, '2','4','1',0, '2','4','2',0, '2','4','3',0, '2','4','4',0, - '2','4','5',0, '2','4','6',0, '2','4','7',0, '2','4','8',0, '2','4','9',0, - '2','5','0',0, '2','5','1',0, '2','5','2',0, '2','5','3',0, '2','5','4',0, - '2','5','5',0, '2','5','6',0, '2','5','7',0, '2','5','8',0, '2','5','9',0, - '2','6','0',0, '2','6','1',0, '2','6','2',0, '2','6','3',0, '2','6','4',0, - '2','6','5',0, '2','6','6',0, '2','6','7',0, '2','6','8',0, '2','6','9',0, - '2','7','0',0, '2','7','1',0, '2','7','2',0, '2','7','3',0, '2','7','4',0, - '2','7','5',0, '2','7','6',0, '2','7','7',0, '2','7','8',0, '2','7','9',0, - '2','8','0',0, '2','8','1',0, '2','8','2',0, '2','8','3',0, '2','8','4',0, - '2','8','5',0, '2','8','6',0, '2','8','7',0, '2','8','8',0, '2','8','9',0, - '2','9','0',0, '2','9','1',0, '2','9','2',0, '2','9','3',0, '2','9','4',0, - '2','9','5',0, '2','9','6',0, '2','9','7',0, '2','9','8',0, '2','9','9',0, - '3','0','0',0, '3','0','1',0, '3','0','2',0, '3','0','3',0, '3','0','4',0, - '3','0','5',0, '3','0','6',0, '3','0','7',0, '3','0','8',0, '3','0','9',0, - '3','1','0',0, '3','1','1',0, '3','1','2',0, '3','1','3',0, '3','1','4',0, - '3','1','5',0, '3','1','6',0, '3','1','7',0, '3','1','8',0, '3','1','9',0, - '3','2','0',0, '3','2','1',0, '3','2','2',0, '3','2','3',0, '3','2','4',0, - '3','2','5',0, '3','2','6',0, '3','2','7',0, '3','2','8',0, '3','2','9',0, - '3','3','0',0, '3','3','1',0, '3','3','2',0, '3','3','3',0, '3','3','4',0, - '3','3','5',0, '3','3','6',0, '3','3','7',0, '3','3','8',0, '3','3','9',0, - '3','4','0',0, '3','4','1',0, '3','4','2',0, '3','4','3',0, '3','4','4',0, - '3','4','5',0, '3','4','6',0, '3','4','7',0, '3','4','8',0, '3','4','9',0, - '3','5','0',0, '3','5','1',0, '3','5','2',0, '3','5','3',0, '3','5','4',0, - '3','5','5',0, '3','5','6',0, '3','5','7',0, '3','5','8',0, '3','5','9',0, - '3','6','0',0, '3','6','1',0, '3','6','2',0, '3','6','3',0, '3','6','4',0, - '3','6','5',0, '3','6','6',0, '3','6','7',0, '3','6','8',0, '3','6','9',0, - '3','7','0',0, '3','7','1',0, '3','7','2',0, '3','7','3',0, '3','7','4',0, - '3','7','5',0, '3','7','6',0, '3','7','7',0, '3','7','8',0, '3','7','9',0, - '3','8','0',0, '3','8','1',0, '3','8','2',0, '3','8','3',0, '3','8','4',0, - '3','8','5',0, '3','8','6',0, '3','8','7',0, '3','8','8',0, '3','8','9',0, - '3','9','0',0, '3','9','1',0, '3','9','2',0, '3','9','3',0, '3','9','4',0, - '3','9','5',0, '3','9','6',0, '3','9','7',0, '3','9','8',0, '3','9','9',0, - '4','0','0',0, '4','0','1',0, '4','0','2',0, '4','0','3',0, '4','0','4',0, - '4','0','5',0, '4','0','6',0, '4','0','7',0, '4','0','8',0, '4','0','9',0, - '4','1','0',0, '4','1','1',0, '4','1','2',0, '4','1','3',0, '4','1','4',0, - '4','1','5',0, '4','1','6',0, '4','1','7',0, '4','1','8',0, '4','1','9',0, - '4','2','0',0, '4','2','1',0, '4','2','2',0, '4','2','3',0, '4','2','4',0, - '4','2','5',0, '4','2','6',0, '4','2','7',0, '4','2','8',0, '4','2','9',0, - '4','3','0',0, '4','3','1',0, '4','3','2',0, '4','3','3',0, '4','3','4',0, - '4','3','5',0, '4','3','6',0, '4','3','7',0, '4','3','8',0, '4','3','9',0, - '4','4','0',0, '4','4','1',0, '4','4','2',0, '4','4','3',0, '4','4','4',0, - '4','4','5',0, '4','4','6',0, '4','4','7',0, '4','4','8',0, '4','4','9',0, - '4','5','0',0, '4','5','1',0, '4','5','2',0, '4','5','3',0, '4','5','4',0, - '4','5','5',0, '4','5','6',0, '4','5','7',0, '4','5','8',0, '4','5','9',0, - '4','6','0',0, '4','6','1',0, '4','6','2',0, '4','6','3',0, '4','6','4',0, - '4','6','5',0, '4','6','6',0, '4','6','7',0, '4','6','8',0, '4','6','9',0, - '4','7','0',0, '4','7','1',0, '4','7','2',0, '4','7','3',0, '4','7','4',0, - '4','7','5',0, '4','7','6',0, '4','7','7',0, '4','7','8',0, '4','7','9',0, - '4','8','0',0, '4','8','1',0, '4','8','2',0, '4','8','3',0, '4','8','4',0, - '4','8','5',0, '4','8','6',0, '4','8','7',0, '4','8','8',0, '4','8','9',0, - '4','9','0',0, '4','9','1',0, '4','9','2',0, '4','9','3',0, '4','9','4',0, - '4','9','5',0, '4','9','6',0, '4','9','7',0, '4','9','8',0, '4','9','9',0, - '5','0','0',0, '5','0','1',0, '5','0','2',0, '5','0','3',0, '5','0','4',0, - '5','0','5',0, '5','0','6',0, '5','0','7',0, '5','0','8',0, '5','0','9',0, - '5','1','0',0, '5','1','1',0, '5','1','2',0, '5','1','3',0, '5','1','4',0, - '5','1','5',0, '5','1','6',0, '5','1','7',0, '5','1','8',0, '5','1','9',0, - '5','2','0',0, '5','2','1',0, '5','2','2',0, '5','2','3',0, '5','2','4',0, - '5','2','5',0, '5','2','6',0, '5','2','7',0, '5','2','8',0, '5','2','9',0, - '5','3','0',0, '5','3','1',0, '5','3','2',0, '5','3','3',0, '5','3','4',0, - '5','3','5',0, '5','3','6',0, '5','3','7',0, '5','3','8',0, '5','3','9',0, - '5','4','0',0, '5','4','1',0, '5','4','2',0, '5','4','3',0, '5','4','4',0, - '5','4','5',0, '5','4','6',0, '5','4','7',0, '5','4','8',0, '5','4','9',0, - '5','5','0',0, '5','5','1',0, '5','5','2',0, '5','5','3',0, '5','5','4',0, - '5','5','5',0, '5','5','6',0, '5','5','7',0, '5','5','8',0, '5','5','9',0, - '5','6','0',0, '5','6','1',0, '5','6','2',0, '5','6','3',0, '5','6','4',0, - '5','6','5',0, '5','6','6',0, '5','6','7',0, '5','6','8',0, '5','6','9',0, - '5','7','0',0, '5','7','1',0, '5','7','2',0, '5','7','3',0, '5','7','4',0, - '5','7','5',0, '5','7','6',0, '5','7','7',0, '5','7','8',0, '5','7','9',0, - '5','8','0',0, '5','8','1',0, '5','8','2',0, '5','8','3',0, '5','8','4',0, - '5','8','5',0, '5','8','6',0, '5','8','7',0, '5','8','8',0, '5','8','9',0, - '5','9','0',0, '5','9','1',0, '5','9','2',0, '5','9','3',0, '5','9','4',0, - '5','9','5',0, '5','9','6',0, '5','9','7',0, '5','9','8',0, '5','9','9',0, - '6','0','0',0, '6','0','1',0, '6','0','2',0, '6','0','3',0, '6','0','4',0, - '6','0','5',0, '6','0','6',0, '6','0','7',0, '6','0','8',0, '6','0','9',0, - '6','1','0',0, '6','1','1',0, '6','1','2',0, '6','1','3',0, '6','1','4',0, - '6','1','5',0, '6','1','6',0, '6','1','7',0, '6','1','8',0, '6','1','9',0, - '6','2','0',0, '6','2','1',0, '6','2','2',0, '6','2','3',0, '6','2','4',0, - '6','2','5',0, '6','2','6',0, '6','2','7',0, '6','2','8',0, '6','2','9',0, - '6','3','0',0, '6','3','1',0, '6','3','2',0, '6','3','3',0, '6','3','4',0, - '6','3','5',0, '6','3','6',0, '6','3','7',0, '6','3','8',0, '6','3','9',0, - '6','4','0',0, '6','4','1',0, '6','4','2',0, '6','4','3',0, '6','4','4',0, - '6','4','5',0, '6','4','6',0, '6','4','7',0, '6','4','8',0, '6','4','9',0, - '6','5','0',0, '6','5','1',0, '6','5','2',0, '6','5','3',0, '6','5','4',0, - '6','5','5',0, '6','5','6',0, '6','5','7',0, '6','5','8',0, '6','5','9',0, - '6','6','0',0, '6','6','1',0, '6','6','2',0, '6','6','3',0, '6','6','4',0, - '6','6','5',0, '6','6','6',0, '6','6','7',0, '6','6','8',0, '6','6','9',0, - '6','7','0',0, '6','7','1',0, '6','7','2',0, '6','7','3',0, '6','7','4',0, - '6','7','5',0, '6','7','6',0, '6','7','7',0, '6','7','8',0, '6','7','9',0, - '6','8','0',0, '6','8','1',0, '6','8','2',0, '6','8','3',0, '6','8','4',0, - '6','8','5',0, '6','8','6',0, '6','8','7',0, '6','8','8',0, '6','8','9',0, - '6','9','0',0, '6','9','1',0, '6','9','2',0, '6','9','3',0, '6','9','4',0, - '6','9','5',0, '6','9','6',0, '6','9','7',0, '6','9','8',0, '6','9','9',0, - '7','0','0',0, '7','0','1',0, '7','0','2',0, '7','0','3',0, '7','0','4',0, - '7','0','5',0, '7','0','6',0, '7','0','7',0, '7','0','8',0, '7','0','9',0, - '7','1','0',0, '7','1','1',0, '7','1','2',0, '7','1','3',0, '7','1','4',0, - '7','1','5',0, '7','1','6',0, '7','1','7',0, '7','1','8',0, '7','1','9',0, - '7','2','0',0, '7','2','1',0, '7','2','2',0, '7','2','3',0, '7','2','4',0, - '7','2','5',0, '7','2','6',0, '7','2','7',0, '7','2','8',0, '7','2','9',0, - '7','3','0',0, '7','3','1',0, '7','3','2',0, '7','3','3',0, '7','3','4',0, - '7','3','5',0, '7','3','6',0, '7','3','7',0, '7','3','8',0, '7','3','9',0, - '7','4','0',0, '7','4','1',0, '7','4','2',0, '7','4','3',0, '7','4','4',0, - '7','4','5',0, '7','4','6',0, '7','4','7',0, '7','4','8',0, '7','4','9',0, - '7','5','0',0, '7','5','1',0, '7','5','2',0, '7','5','3',0, '7','5','4',0, - '7','5','5',0, '7','5','6',0, '7','5','7',0, '7','5','8',0, '7','5','9',0, - '7','6','0',0, '7','6','1',0, '7','6','2',0, '7','6','3',0, '7','6','4',0, - '7','6','5',0, '7','6','6',0, '7','6','7',0, '7','6','8',0, '7','6','9',0, - '7','7','0',0, '7','7','1',0, '7','7','2',0, '7','7','3',0, '7','7','4',0, - '7','7','5',0, '7','7','6',0, '7','7','7',0, '7','7','8',0, '7','7','9',0, - '7','8','0',0, '7','8','1',0, '7','8','2',0, '7','8','3',0, '7','8','4',0, - '7','8','5',0, '7','8','6',0, '7','8','7',0, '7','8','8',0, '7','8','9',0, - '7','9','0',0, '7','9','1',0, '7','9','2',0, '7','9','3',0, '7','9','4',0, - '7','9','5',0, '7','9','6',0, '7','9','7',0, '7','9','8',0, '7','9','9',0, - '8','0','0',0, '8','0','1',0, '8','0','2',0, '8','0','3',0, '8','0','4',0, - '8','0','5',0, '8','0','6',0, '8','0','7',0, '8','0','8',0, '8','0','9',0, - '8','1','0',0, '8','1','1',0, '8','1','2',0, '8','1','3',0, '8','1','4',0, - '8','1','5',0, '8','1','6',0, '8','1','7',0, '8','1','8',0, '8','1','9',0, - '8','2','0',0, '8','2','1',0, '8','2','2',0, '8','2','3',0, '8','2','4',0, - '8','2','5',0, '8','2','6',0, '8','2','7',0, '8','2','8',0, '8','2','9',0, - '8','3','0',0, '8','3','1',0, '8','3','2',0, '8','3','3',0, '8','3','4',0, - '8','3','5',0, '8','3','6',0, '8','3','7',0, '8','3','8',0, '8','3','9',0, - '8','4','0',0, '8','4','1',0, '8','4','2',0, '8','4','3',0, '8','4','4',0, - '8','4','5',0, '8','4','6',0, '8','4','7',0, '8','4','8',0, '8','4','9',0, - '8','5','0',0, '8','5','1',0, '8','5','2',0, '8','5','3',0, '8','5','4',0, - '8','5','5',0, '8','5','6',0, '8','5','7',0, '8','5','8',0, '8','5','9',0, - '8','6','0',0, '8','6','1',0, '8','6','2',0, '8','6','3',0, '8','6','4',0, - '8','6','5',0, '8','6','6',0, '8','6','7',0, '8','6','8',0, '8','6','9',0, - '8','7','0',0, '8','7','1',0, '8','7','2',0, '8','7','3',0, '8','7','4',0, - '8','7','5',0, '8','7','6',0, '8','7','7',0, '8','7','8',0, '8','7','9',0, - '8','8','0',0, '8','8','1',0, '8','8','2',0, '8','8','3',0, '8','8','4',0, - '8','8','5',0, '8','8','6',0, '8','8','7',0, '8','8','8',0, '8','8','9',0, - '8','9','0',0, '8','9','1',0, '8','9','2',0, '8','9','3',0, '8','9','4',0, - '8','9','5',0, '8','9','6',0, '8','9','7',0, '8','9','8',0, '8','9','9',0, - '9','0','0',0, '9','0','1',0, '9','0','2',0, '9','0','3',0, '9','0','4',0, - '9','0','5',0, '9','0','6',0, '9','0','7',0, '9','0','8',0, '9','0','9',0, - '9','1','0',0, '9','1','1',0, '9','1','2',0, '9','1','3',0, '9','1','4',0, - '9','1','5',0, '9','1','6',0, '9','1','7',0, '9','1','8',0, '9','1','9',0, - '9','2','0',0, '9','2','1',0, '9','2','2',0, '9','2','3',0, '9','2','4',0, - '9','2','5',0, '9','2','6',0, '9','2','7',0, '9','2','8',0, '9','2','9',0, - '9','3','0',0, '9','3','1',0, '9','3','2',0, '9','3','3',0, '9','3','4',0, - '9','3','5',0, '9','3','6',0, '9','3','7',0, '9','3','8',0, '9','3','9',0, - '9','4','0',0, '9','4','1',0, '9','4','2',0, '9','4','3',0, '9','4','4',0, - '9','4','5',0, '9','4','6',0, '9','4','7',0, '9','4','8',0, '9','4','9',0, - '9','5','0',0, '9','5','1',0, '9','5','2',0, '9','5','3',0, '9','5','4',0, - '9','5','5',0, '9','5','6',0, '9','5','7',0, '9','5','8',0, '9','5','9',0, - '9','6','0',0, '9','6','1',0, '9','6','2',0, '9','6','3',0, '9','6','4',0, - '9','6','5',0, '9','6','6',0, '9','6','7',0, '9','6','8',0, '9','6','9',0, - '9','7','0',0, '9','7','1',0, '9','7','2',0, '9','7','3',0, '9','7','4',0, - '9','7','5',0, '9','7','6',0, '9','7','7',0, '9','7','8',0, '9','7','9',0, - '9','8','0',0, '9','8','1',0, '9','8','2',0, '9','8','3',0, '9','8','4',0, - '9','8','5',0, '9','8','6',0, '9','8','7',0, '9','8','8',0, '9','8','9',0, - '9','9','0',0, '9','9','1',0, '9','9','2',0, '9','9','3',0, '9','9','4',0, - '9','9','5',0, '9','9','6',0, '9','9','7',0, '9','9','8',0, '9','9','9',0 }; - -/* *INDENT-ON* */ - -static char scratch_buffer[32]; - -/* - * sprintf_irc - * - * sprintf_irc is optimized for the formats: %c, %s, %lu, %d and %u. - * Where %lu actually equals %l09u (for printing time_t timestamps). - * - * sprintf_irc is NOT optimized for any other format and resorts to using - * the normal sprintf when it encounters a format it doesn't understand - * (including padding, width, precision etc). - * - * The following benchmark was measured on a PPro200 with linux 2.0.30, - * libc 5.4.28, compiled with gcc-2.7.2.1 with -O3. - * - * Format sprintf sprintf_irc Speed up factor - * - * "12345678901234567890" 3.385 us 0.859 us 3.94 - * "%s", buffer (20 chars) 3.780 us 0.547 us 6.91 - * "%c%c%c", c1, c2, c3 3.640 us 0.376 us 9.68 - * "%lu", (time_t)t 5.851 us 0.842 us 6.95 - * - * Less important: - * "%d", 31337 4.487 us 0.852 us 5.27 - * "%u.%u.%u.%u", 9.069 us 2.431 us 3.73 - * - * Not used: - * "%03d", 401 4.348 us - * "%N" 0.216 us 20.13 - * - * --Run - */ -char *vsprintf_irc(char *str, const char *format, va_list vl) -{ - char c; - - while ((c = *format++)) - { - if (c == '%') - { - c = *format++; /* May never be '\0' ! */ - if (c == 'c') - { - *str++ = (char)va_arg(vl, int); - continue; - } - if (c == 's') - { - const char *p1 = va_arg(vl, const char *); - if ((*str = *p1)) - while ((*++str = *++p1)); - continue; - } - if (c == 'l' && *format == 'u') /* Prints time_t value in interval - [ 100000000 , 4294967295 ] - Actually prints like "%09lu" */ - { - unsigned long v1; - unsigned long v2; - const char *ap; - ++format; - v1 = va_arg(vl, unsigned long); - if (v1 > 999999999L) - { - v2 = v1 / 1000000000; - v1 -= v2 * 1000000000; - *str++ = '0' + v2; - } - v2 = v1 / 1000000; - v1 -= v2 * 1000000; - ap = atoi_tab + (v2 << 2); - *str++ = *ap++; - *str++ = *ap++; - *str++ = *ap; - v2 = v1 / 1000; - v1 -= v2 * 1000; - ap = atoi_tab + (v2 << 2); - *str++ = *ap++; - *str++ = *ap++; - *str++ = *ap; - ap = atoi_tab + (v1 << 2); - *str++ = *ap++; - *str++ = *ap++; - *str++ = *ap; - continue; - } -#if 0 /* Not used */ - if (c == 'N') /* Prints "%03u" a numeric value in the - range [ 0, 999 ], padded with zero's */ - { - unsigned int v1; - const char *ap; - v1 = va_arg(vl, unsigned int); - ap = atoi_tab + (v1 << 2); - *str++ = *ap++; - *str++ = *ap++; - *str++ = *ap; - continue; - } -#endif - if (c == 'd') - { - unsigned int v1, v2; - const char *ap; - char *s = &scratch_buffer[sizeof(scratch_buffer) - 2]; - v1 = va_arg(vl, int); - if ((int)v1 <= 0) - { - if (v1 == 0) - { - *str++ = '0'; - continue; - } - *str++ = '-'; - v1 = -v1; - } - do - { - v2 = v1 / 1000; - ap = atoi_tab + 2 + ((v1 - 1000 * v2) << 2); - *s-- = *ap--; - *s-- = *ap--; - *s-- = *ap; - } - while ((v1 = v2) > 0); - while ('0' == *++s); - *str = *s; - while ((*++str = *++s)); - continue; - } - if (c == 'u') - { - unsigned int v1, v2; - const char *ap; - char *s = &scratch_buffer[sizeof(scratch_buffer) - 2]; - v1 = va_arg(vl, unsigned int); - if (v1 == 0) - { - *str++ = '0'; - continue; - } - do - { - v2 = v1 / 1000; - ap = atoi_tab + 2 + ((v1 - 1000 * v2) << 2); - *s-- = *ap--; - *s-- = *ap--; - *s-- = *ap; - } - while ((v1 = v2) > 0); - while ('0' == *++s); - *str = *s; - while ((*++str = *++s)); - continue; - } - if (c != '%') - { - format -= 2; - str += vsprintf(str, format, vl); - break; - } - } - *str++ = c; - } - *str = 0; - return str; -} - -char *sprintf_irc(char *str, const char *format, ...) -{ - va_list vl; - char *ret; - va_start(vl, format); - ret = vsprintf_irc(str, format, vl); - va_end(vl); - return ret; -} diff --git a/ircd/support.c b/ircd/support.c index d05395f..dae19e0 100644 --- a/ircd/support.c +++ b/ircd/support.c @@ -28,7 +28,6 @@ #include "s_bsd.h" #include "s_debug.h" #include "send.h" -#include "sprintf_irc.h" #include "sys.h" #include /* kill */ diff --git a/ircd/whocmds.c b/ircd/whocmds.c index 39a9bc7..25f3545 100644 --- a/ircd/whocmds.c +++ b/ircd/whocmds.c @@ -45,7 +45,6 @@ #include "s_misc.h" #include "s_user.h" #include "send.h" -#include "sprintf_irc.h" #include "struct.h" #include "support.h" #include "sys.h" @@ -201,7 +200,8 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, strcat(p1, sptr == acptr ? "0" : "3"); p1++; #else - p1 = sprintf_irc(p1, "%d", cli_hopcount(acptr)); + /* three digit hopcount maximum */ + p1 += ircd_snprintf(0, p1, 3, "%d", cli_hopcount(acptr)); #endif } @@ -209,7 +209,8 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, { *p1++ = ' '; if (MyUser(acptr)) { - p1 = sprintf_irc(p1, "%d", CurrentTime - cli_user(acptr)->last); + p1 += ircd_snprintf(0, p1, 11, "%d", + CurrentTime - cli_user(acptr)->last); } else { *p1++ = '0';