From c5b03f35e14f4b7e8ee0c2d1b946033d41d84560 Mon Sep 17 00:00:00 2001 From: joonicks Date: Wed, 4 Apr 2018 06:04:58 +0200 Subject: [PATCH] reorganizing --- .gitignore | 1 + Makefile | 15 +- README | 6 +- config/md5.h | 2 +- config/md5_internal.c | 2 +- config/sha1.h | 2 +- config/sha_internal.c | 2 +- configure | 19 +- src/Makefile.in | 49 +- src/alias.c | 12 +- src/auth.c | 32 +- src/bounce.c | 16 +- src/chanban.c | 4 +- src/channel.c | 68 +-- src/config.h.in | 21 + src/core.c | 58 +- src/ctcp.c | 251 +-------- src/debug.c | 12 +- src/defines.h | 3 + src/dns.c | 36 +- src/dynamode.c | 88 --- src/function.c | 471 ++++------------ src/gencmd.c | 1 + src/greet.c | 2 +- src/h.h | 1253 +++++++++++++++++++---------------------- src/help.c | 26 +- src/hostinfo.c | 99 ++-- src/irc.c | 8 +- src/kicksay.c | 18 +- src/lib/sha.c | 27 - src/lib/sha1.c | 69 +-- src/lib/string.c | 18 +- src/lib/string.o | Bin 19040 -> 18160 bytes src/main.c | 16 +- src/md5/md5.c | 400 ------------- src/md5/md5.h | 27 - src/mega.c | 2 +- src/net.c | 74 +-- src/net_chan.c | 12 +- src/note.c | 15 +- src/notify.c | 37 +- src/ons.c | 49 +- src/parse.c | 28 +- src/partyline.c | 240 +++++++- src/perl.c | 4 +- src/prot.c | 75 ++- src/python.c | 20 +- src/redirect.c | 8 +- src/reset.c | 6 +- src/seen.c | 17 +- src/sha/sha.c | 27 - src/sha/sha1.c | 296 ---------- src/sha/sha1.h | 44 -- src/shit.c | 18 +- src/socket.c | 10 +- src/spy.c | 16 +- src/stats.c | 8 +- src/structs.h | 6 +- src/tcl.c | 18 +- src/toybox.c | 30 +- src/trivia.c | 34 +- src/uptime.c | 6 +- src/urlcap.c | 32 +- src/user.c | 81 +-- src/vars.c | 49 +- src/web.c | 16 +- 66 files changed, 1670 insertions(+), 2742 deletions(-) delete mode 100644 src/dynamode.c delete mode 100644 src/lib/sha.c delete mode 100644 src/md5/md5.c delete mode 100644 src/md5/md5.h delete mode 100644 src/sha/sha.c delete mode 100644 src/sha/sha1.c delete mode 100644 src/sha/sha1.h diff --git a/.gitignore b/.gitignore index 8ec3019..b6bfb93 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ trivia/*.index energymech src/energymech src/*.o +src/lib/*.o src/gencmd src/aliastest src/safepathtest diff --git a/Makefile b/Makefile index 256abd7..7920886 100644 --- a/Makefile +++ b/Makefile @@ -55,15 +55,12 @@ TESTFILES = config/cc.c config/endian.c config/inet_addr.c config/inet_aton.c co TRIVFILES = trivia/mkindex.c -SRCFILES = src/alias.c src/auth.c src/bounce.c src/chanban.c src/channel.c \ - src/core.c src/ctcp.c src/debug.c src/dns.c src/dynamode.c \ - src/function.c src/gencmd.c src/greet.c src/help.c src/hostinfo.c src/irc.c \ - src/kicksay.c src/main.c src/mega.c src/net.c src/net_chan.c \ - src/note.c src/notify.c src/ons.c src/parse.c src/perl.c \ - src/prot.c src/python.c src/redirect.c src/reset.c src/seen.c \ - src/shit.c src/socket.c src/spy.c src/stats.c src/tcl.c \ - src/telnet.c src/toybox.c src/trivia.c src/uptime.c src/urlcap.c src/user.c \ - src/vars.c src/web.c src/md5/md5.c src/md5/md5.h +SRCFILES = src/alias.c src/auth.c src/bounce.c src/chanban.c src/channel.c src/core.c src/ctcp.c src/debug.c src/dns.c \ + src/function.c src/gencmd.c src/greet.c src/help.c src/hostinfo.c src/irc.c src/kicksay.c src/main.c src/mega.c \ + src/net.c src/net_chan.c src/note.c src/notify.c src/ons.c src/parse.c src/partyline.c src/perl.c src/prot.c \ + src/python.c src/redirect.c src/reset.c src/seen.c src/shit.c src/socket.c src/spy.c src/stats.c src/tcl.c \ + src/toybox.c src/trivia.c src/uptime.c src/urlcap.c src/user.c src/vars.c src/web.c \ + src/lib/md5.c src/lib/md5.h src/lib/string.c HDRFILES = src/defines.h src/global.h src/h.h src/settings.h src/structs.h src/text.h src/usage.h diff --git a/README b/README index f30a69b..7d3262a 100644 --- a/README +++ b/README @@ -102,6 +102,10 @@ The main distribution site for the EnergyMech is: https://github.com/MadCamel/energymech +Extra files for users of EnergyMech can be found at: + + https://github.com/joonicks/energymech-extra + Files, documentation and tips can be found at: http://www.energymech.net @@ -113,4 +117,4 @@ IT COMES TO CONFIGURING AND USING IT. ---*--- -proton, March 13th, 2018. +proton, April 3rd, 2018. diff --git a/config/md5.h b/config/md5.h index 7fc84a2..33cbf4c 120000 --- a/config/md5.h +++ b/config/md5.h @@ -1 +1 @@ -../src/md5/md5.h \ No newline at end of file +../src/lib/md5.h \ No newline at end of file diff --git a/config/md5_internal.c b/config/md5_internal.c index b97ef28..11fb4e7 120000 --- a/config/md5_internal.c +++ b/config/md5_internal.c @@ -1 +1 @@ -../src/md5/md5.c \ No newline at end of file +../src/lib/md5.c \ No newline at end of file diff --git a/config/sha1.h b/config/sha1.h index 02a9c1f..d54e834 120000 --- a/config/sha1.h +++ b/config/sha1.h @@ -1 +1 @@ -../src/sha/sha1.h \ No newline at end of file +../src/lib/sha1.h \ No newline at end of file diff --git a/config/sha_internal.c b/config/sha_internal.c index 301ee92..842d15c 120000 --- a/config/sha_internal.c +++ b/config/sha_internal.c @@ -1 +1 @@ -../src/sha/sha1.c \ No newline at end of file +../src/lib/sha1.c \ No newline at end of file diff --git a/configure b/configure index c4bc628..9c374b2 100755 --- a/configure +++ b/configure @@ -103,6 +103,7 @@ do hostinfo ) ft_hostinfo=$yesno ;; idwrap ) ft_idwrap=$yesno ;; ircd_ext ) ft_ircd_ext=$yesno ;; + libmusl ) try_libmusl=$yesno ;; md5 ) ft_md5=$yesno ;; newbie ) ft_newbie=$yesno ;; note ) ft_note=$yesno ;; @@ -205,6 +206,8 @@ do idwrap_no ) ft_idwrap=no ;; ircd_ext_yes | ircd_ext_ ) ft_ircd_ext=yes ;; ircd_ext_no ) ft_ircd_ext=no ;; + libmusl_yes | libmusl_ ) try_libmusl=/usr/local/musl/bin/musl-gcc ;; + libmusl_no ) try_libmusl=no ;; md5_yes | md5_ ) ft_md5=yes ;; md5_no ) ft_md5=no ;; newbie_yes | newbie_ ) ft_newbie=yes ;; @@ -225,7 +228,7 @@ do seen_no ) ft_seen=no ;; session_yes | session_ ) ft_session=yes ;; session_no ) ft_session=no ;; - sha_yes | sha_ ) ft_seen=yes ;; + sha_yes | sha_ ) ft_sha=yes ;; sha_no ) ft_sha=no ;; stats_yes | stats_ ) ft_stats=yes ;; stats_no ) ft_stats=no ;; @@ -256,7 +259,7 @@ do alias ) ft_alias=no ;; botnet ) ft_botnet=no ;; bounce ) ft_bounce=no ;; - chanban ) ft_chanban=yes ;; + chanban ) ft_chanban=no ;; ctcp ) ft_ctcp=no ;; dccfile ) ft_dccfile=no ;; debug ) ft_debug=no ;; @@ -266,6 +269,7 @@ do hostinfo ) ft_hostinfo=no ;; idwrap ) ft_idwrap=no ;; ircd_ext ) ft_ircd_ext=no ;; + libmusl ) try_libmusl=no ;; md5 ) ft_md5=no ;; newbie ) ft_newbie=no ;; note ) ft_note=no ;; @@ -277,7 +281,7 @@ do redirect ) ft_redirect=no ;; seen ) ft_seen=no ;; session ) ft_session=no ;; - sha ) ft_sha=yes ;; + sha ) ft_sha=no ;; stats ) ft_stats=no ;; suppress ) ft_suppress=no ;; tcl ) ft_tcl=no ;; @@ -292,7 +296,6 @@ do ;; --compile) compile=yes ;; --install) install=yes ;; - --with-libmusl) try_libmusl=/usr/local/musl/bin/musl-gcc ;; --silence=options) silentopt=yes ;; --md5=internal) ft_md5=internal ;; --sha=internal) ft_sha=internal ;; @@ -1039,14 +1042,18 @@ fi objcomment= [ "$OBJCOPY" = "not found" ] && objcomment='#' +MD5_C= MD5_O= if [ "$ft_md5" = internal ]; then - MD5_O=md5/md5.o + MD5_C=lib/md5.c + MD5_O=lib/md5.o fi +SHA_C= SHA_O= if [ "$ft_sha" = internal ]; then - SHA_O=sha/sha.o + SHA_C=lib/sha1.c + SHA_O=lib/sha.o fi out=echo diff --git a/src/Makefile.in b/src/Makefile.in index 5d1f89f..7fa77ad 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -42,23 +42,20 @@ MV = mv -f RM = rm -f CHMOD = chmod -INCS = config.h defines.h global.h h.h mcmd.h structs.h text.h usercombo.h +BASEINCLUDES = config.h defines.h structs.h global.h h.h +INCS = $(BASEINCLUDES) mcmd.h text.h usercombo.h TESTFILES = aliastest safepathtest -OFILES = alias.o auth.o bounce.o chanban.o channel.o core.o \ - ctcp.o debug.o dns.o dynamode.o function.o greet.o help.o hostinfo.o irc.o \ - kicksay.o main.o net.o net_chan.o note.o notify.o ons.o parse.o \ - perl.o prot.o python.o redirect.o reset.o seen.o shit.o socket.o \ - spy.o stats.o tcl.o telnet.o toybox.o trivia.o uptime.o urlcap.o \ - user.o vars.o web.o @MD5_O@ @SHA_O@ +OFILES = alias.o auth.o bounce.o chanban.o channel.o core.o ctcp.o debug.o dns.o function.o greet.o \ + help.o hostinfo.o irc.o kicksay.o main.o net.o net_chan.o note.o notify.o ons.o parse.o partyline.o \ + perl.o prot.o python.o redirect.o reset.o seen.o shit.o socket.o spy.o stats.o tcl.o toybox.o \ + trivia.o uptime.o urlcap.o user.o vars.o web.o lib/string.o @MD5_O@ @SHA_O@ -SRCFILES = alias.c auth.c bounce.c chanban.c channel.c core.c \ - ctcp.c debug.c dns.c dynamode.c function.c greet.c help.c hostinfo.c irc.c \ - kicksay.c main.c net.c net_chan.c note.c notify.c ons.c parse.c \ - perl.c prot.c python.c redirect.c reset.c seen.c shit.c socket.c \ - spy.c stats.c tcl.c telnet.c toybox.c trivia.c uptime.c urlcap.c \ - user.c vars.c web.c +SRCFILES = alias.c auth.c bounce.c chanban.c channel.c core.c ctcp.c debug.c dns.c function.c greet.c \ + help.c hostinfo.c irc.c kicksay.c main.c net.c net_chan.c note.c notify.c ons.c parse.c partyline.c \ + perl.c prot.c python.c redirect.c reset.c seen.c shit.c socket.c spy.c stats.c tcl.c toybox.c \ + trivia.c uptime.c urlcap.c user.c vars.c web.c lib/string.c @MD5_C@ @SHA_C@ .PHONY: all clean mega-install mega mega-static test commands @@ -137,6 +134,15 @@ commands: # # +lib/md5.o: lib/md5.c $(INCS) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Ilib $(CPROF) + +lib/sha1.o: lib/sha1.c $(INCS) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Ilib $(CPROF) + +lib/string.o: lib/string.c $(BASEINCLUDES) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -I. $(CPROF) + alias.o: alias.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) @@ -164,9 +170,6 @@ debug.o: debug.c $(INCS) settings.h dns.o: dns.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) -dynamode.o: dynamode.c $(INCS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) - function.o: function.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) @@ -206,8 +209,11 @@ ons.o: ons.c $(INCS) parse.o: parse.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) +partyline.o: partyline.c $(INCS) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) + perl.o: perl.c $(INCS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) $(I_PERL) -c $< $(CPROF) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) $(I_PERL) prot.o: prot.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) @@ -239,9 +245,6 @@ stats.o: stats.c $(INCS) tcl.o: tcl.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) $(TCLINCLUDE) -telnet.o: telnet.c $(INCS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) - toybox.o: toybox.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) @@ -263,9 +266,3 @@ vars.o: vars.c $(INCS) settings.h web.o: web.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) -md5/md5.o: md5/md5.c $(INCS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Imd5 $(CPROF) - -sha/sha1.o: sha/sha1.c $(INCS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Isha1 $(CPROF) - diff --git a/src/alias.c b/src/alias.c index 22d3bd9..7085ebc 100644 --- a/src/alias.c +++ b/src/alias.c @@ -231,7 +231,7 @@ void do_alias(COMMAND_ARGS) to_user(from,TEXT_NOALIASES); else { - if (dcc_only_command(from)) + if (partyline_only_command(from)) return; to_user(from,"\037Alias\037 \037Format\037"); for(alias=aliaslist;alias;alias=alias->next) @@ -250,11 +250,11 @@ void do_alias(COMMAND_ARGS) } for(alias=aliaslist;alias;alias=alias->next) { - if (!Strcasecmp(alias->alias,cmd)) + if (!stringcasecmp(alias->alias,cmd)) { Free(&alias->format); set_mallocdoer(do_alias); - alias->format = Strdup(rest); + alias->format = stringdup(rest); to_user(from,"Replaced alias: %s --> %s",cmd,rest); #ifdef DEBUG debug("(do_alias) Replaced alias: %s --> %s\n",cmd,rest); @@ -264,9 +264,9 @@ void do_alias(COMMAND_ARGS) } set_mallocdoer(do_alias); alias = (Alias*)Calloc(sizeof(Alias)+strlen(cmd)); - Strcpy(alias->alias,cmd); + stringcpy(alias->alias,cmd); set_mallocdoer(do_alias); - alias->format = Strdup(rest); + alias->format = stringdup(rest); alias->next = aliaslist; aliaslist = alias; to_user(from,"Added alias: %s --> %s",cmd,rest); @@ -295,7 +295,7 @@ void do_unalias(COMMAND_ARGS) for(ap=&aliaslist;*ap;ap=&(*ap)->next) { - if (!Strcasecmp(rest,(*ap)->alias)) + if (!stringcasecmp(rest,(*ap)->alias)) { alias = *ap; *ap = alias->next; diff --git a/src/auth.c b/src/auth.c index 141bc40..7d5cdd8 100644 --- a/src/auth.c +++ b/src/auth.c @@ -112,7 +112,7 @@ char *makepass(char *plain) int passmatch(char *plain, char *encoded) { - return(!Strcmp(cipher(plain),encoded)); + return(!stringcmp(cipher(plain),encoded)); } #endif /* not SHACRYPT */ @@ -141,7 +141,7 @@ int passmatch(char *plain, char *encoded) if (matches("$6$????$*",encoded)) return(FALSE); enc = CRYPT_FUNC(plain,encoded); - return(!Strcmp(enc,encoded)); + return(!stringcmp(enc,encoded)); } #endif /* SHACRYPT */ @@ -170,7 +170,7 @@ int passmatch(char *plain, char *encoded) if (matches("$1$????$*",encoded)) return(FALSE); enc = CRYPT_FUNC(plain,encoded); - return(!Strcmp(enc,encoded)); + return(!stringcmp(enc,encoded)); } #endif /* MD5CRYPT */ @@ -185,7 +185,7 @@ void delete_auth(char *userhost) pp = ¤t->authlist; while(*pp) { - if (!Strcasecmp(userhost,(*pp)->nuh)) + if (!stringcasecmp(userhost,(*pp)->nuh)) { auth = *pp; *pp = auth->next; @@ -238,10 +238,10 @@ void change_authnick(char *nuh, char *newnuh) if ((n1 - nuh) >= (n2 - newnuh)) { #ifdef DEBUG - debug("(change_authnick) auth->nuh = `%s'; was `%s' (Strcpy) (L1 = %i, L2 = %i)\n", + debug("(change_authnick) auth->nuh = `%s'; was `%s' (stringcpy) (L1 = %i, L2 = %i)\n", newnuh,nuh,(int)(n1 - nuh),(int)(n2 - newnuh)); #endif /* DEBUG */ - Strcpy(auth->nuh,newnuh); + stringcpy(auth->nuh,newnuh); } else { @@ -260,7 +260,7 @@ void change_authnick(char *nuh, char *newnuh) auth->active = now; auth->next = current->authlist; current->authlist = auth; - Strcpy(auth->nuh,newnuh); + stringcpy(auth->nuh,newnuh); Free((char**)&oldauth); } return; @@ -270,8 +270,8 @@ void change_authnick(char *nuh, char *newnuh) } LS User *au_user; -LS char *au_userhost; -LS char *au_channel; +LS const char *au_userhost; +LS const char *au_channel; LS int au_access; void aucheck(User *user) @@ -282,7 +282,7 @@ void aucheck(User *user) { for(ump=user->chan;ump;ump=ump->next) { - if (*ump->p == '*' || !Strcasecmp(au_channel,ump->p)) + if (*ump->p == '*' || !stringcasecmp(au_channel,ump->p)) break; } if (!ump) @@ -303,7 +303,7 @@ void aucheck(User *user) } } -User *get_authuser(char *userhost, char *channel) +User *get_authuser(const char *userhost, const char *channel) { User *user; Auth *auth; @@ -320,7 +320,7 @@ User *get_authuser(char *userhost, char *channel) { if (au_access < auth->user->x.x.access) { - if (!Strcasecmp(userhost,auth->nuh)) + if (!stringcasecmp(userhost,auth->nuh)) { aucheck(auth->user); } @@ -341,7 +341,7 @@ User *get_authuser(char *userhost, char *channel) return(au_user); } -int get_authaccess(char *userhost, char *channel) +int get_authaccess(const char *userhost, const char *channel) { User *user; Strp *ump; @@ -355,7 +355,7 @@ int get_authaccess(char *userhost, char *channel) return(user->x.x.access); for(ump=user->chan;ump;ump=ump->next) { - if (*ump->p == '*' || !Strcasecmp(ump->p,channel)) + if (*ump->p == '*' || !stringcasecmp(ump->p,channel)) return(user->x.x.access); } return(0); @@ -375,7 +375,7 @@ int make_auth(const char *userhost, const User *user) for(auth=current->authlist;auth;auth=auth->next) { - if ((auth->user == user) && !Strcasecmp(auth->nuh,userhost)) + if ((auth->user == user) && !stringcasecmp(auth->nuh,userhost)) return(TRUE); } @@ -389,7 +389,7 @@ int make_auth(const char *userhost, const User *user) auth = (Auth*)Calloc(sizeof(Auth) + strlen(userhost)); auth->user = (User*)user; auth->active = now; - Strcpy(auth->nuh,userhost); + stringcpy(auth->nuh,userhost); auth->next = current->authlist; current->authlist = auth; diff --git a/src/bounce.c b/src/bounce.c index b19a534..de2f651 100644 --- a/src/bounce.c +++ b/src/bounce.c @@ -65,27 +65,27 @@ void bounce_parse(ircLink *irc, char *message) if (irc->status == BNC_LOGIN) { cmd = chop(&message); - if (!Strcasecmp(cmd,"USER")) + if (!stringcasecmp(cmd,"USER")) { if (irc->userLine) return; set_mallocdoer(bounce_parse); - irc->userLine = Strdup(message); + irc->userLine = stringdup(message); } else - if (!Strcasecmp(cmd,"NICK")) + if (!stringcasecmp(cmd,"NICK")) { if (irc->nickLine) return; set_mallocdoer(bounce_parse); - irc->nickLine = Strdup(message); + irc->nickLine = stringdup(message); if ((cmd = chop(&message)) == NULL) { irc->status = BNC_DEAD; return; } set_mallocdoer(bounce_parse); - irc->nick = Strdup(cmd); + irc->nick = stringdup(cmd); } if (irc->userLine && irc->nickLine) { @@ -103,7 +103,7 @@ void bounce_parse(ircLink *irc, char *message) server = chop(&message); cmd = chop(&message); - if (!cmd || Strcasecmp(server,"PRIVMSG") || nickcmp(cmd,INTERNAL_NICK) + if (!cmd || stringcasecmp(server,"PRIVMSG") || nickcmp(cmd,INTERNAL_NICK) || (*message != ':')) { irc->status = BNC_DEAD; @@ -119,7 +119,7 @@ void bounce_parse(ircLink *irc, char *message) if ((user = find_handle(message))) { set_mallocdoer(bounce_parse); - irc->handle = Strdup(user->name); + irc->handle = stringdup(user->name); break; } } @@ -164,7 +164,7 @@ void bounce_parse(ircLink *irc, char *message) iport = 6667; if (aport) { - iport = a2i(aport); + iport = asc2int(aport); if (errno || (iport < 1) || (iport > 65536)) return; } diff --git a/src/chanban.c b/src/chanban.c index 5ffbd11..6c459ac 100644 --- a/src/chanban.c +++ b/src/chanban.c @@ -117,7 +117,7 @@ void chanban_action(char *nick, char *channel, Shit *shit) // check all current channels for(CurrentChan=current->chanlist;CurrentChan;CurrentChan=CurrentChan->next) { - if (!Strcasecmp(channel,CurrentChan->name)) // if the bot is on the channel, skip it + if (!stringcasecmp(channel,CurrentChan->name)) // if the bot is on the channel, skip it { #ifdef DEBUG debug("(chanban_action) skipping %s: bot is on channel\n",channel); @@ -125,7 +125,7 @@ void chanban_action(char *nick, char *channel, Shit *shit) return; } // is the shit for this channel? - if (!Strcasecmp(shit->chan,CurrentChan->name)) + if (!stringcasecmp(shit->chan,CurrentChan->name)) { // if chanban is turned on && if bot is op (pretty pointless otherwise) if (CurrentChan->setting[TOG_CHANBAN].int_var && CurrentChan->bot_is_op) diff --git a/src/channel.c b/src/channel.c index 178b9ce..653b338 100644 --- a/src/channel.c +++ b/src/channel.c @@ -71,7 +71,7 @@ Chan *find_channel(const char *name, int anychannel) continue; if (ni != tolowertab[(uchar)(chan->name[1])]) continue; - if (!Strcasecmp(name,chan->name)) + if (!stringcasecmp(name,chan->name)) return(chan); } return(NULL); @@ -123,11 +123,11 @@ void join_channel(char *name, char *key) set_mallocdoer(join_channel); chan = (Chan*)Calloc(sizeof(Chan)); set_mallocdoer(join_channel); - chan->name = Strdup(name); + chan->name = stringdup(name); if (key) { set_mallocdoer(join_channel); - chan->key = Strdup(key); + chan->key = stringdup(key); } copy_vars(chan->setting,current->setting); chan->next = current->chanlist; @@ -151,7 +151,7 @@ void join_channel(char *name, char *key) { Free(&chan->key); set_mallocdoer(join_channel); - chan->key = Strdup(key); + chan->key = stringdup(key); } if (chan->active) { @@ -175,14 +175,14 @@ void reverse_topic(Chan *chan, char *from, char *topic) if ((chan->setting[TOG_TOP].int_var) && (get_useraccess(from,chan->name) < ASSTLEVEL)) { - if (chan->topic && Strcasecmp(chan->topic,topic)) + if (chan->topic && stringcasecmp(chan->topic,topic)) to_server("TOPIC %s :%s\n",chan->name,chan->topic); return; } Free((char**)&chan->topic); set_mallocdoer(reverse_topic); - chan->topic = Strdup(topic); + chan->topic = stringdup(topic); } void cycle_channel(Chan *chan) @@ -228,7 +228,7 @@ int reverse_mode(char *from, Chan *chan, int m, int s) { buffer[0] = mode; buffer[1] = 0; - Strcat(buffer,ptr); + stringcat(buffer,ptr); } set_str_varc(chan,STR_ENFMODES,buffer); return(FALSE); @@ -263,8 +263,8 @@ void chan_modestr(Chan *chan, char *dest) } if (chan->keymode) { - Strcat(dest," "); - Strcat(dest,(chan->key) ? chan->key : "???"); + stringcat(dest," "); + stringcat(dest,(chan->key) ? chan->key : "???"); } } @@ -288,7 +288,7 @@ Ban *make_ban(Ban **banlist, char *from, char *banmask, time_t when) for(new=*banlist;new;new=new->next) { - if (!Strcasecmp(new->banstring,banmask)) + if (!stringcasecmp(new->banstring,banmask)) return(NULL); } @@ -297,8 +297,8 @@ Ban *make_ban(Ban **banlist, char *from, char *banmask, time_t when) set_mallocdoer(make_ban); new = (Ban*)Calloc(sz); - new->bannedby = Strcpy(new->banstring,banmask) + 1; - Strcpy(new->bannedby,from); + new->bannedby = stringcpy(new->banstring,banmask) + 1; + stringcpy(new->bannedby,from); new->time = when; new->next = *banlist; @@ -314,7 +314,7 @@ void delete_ban(Chan *chan, char *banmask) while(*pp) { ban = *pp; - if (!Strcasecmp(ban->banstring,banmask)) + if (!stringcasecmp(ban->banstring,banmask)) { *pp = ban->next; Free((char**)&ban); @@ -337,7 +337,7 @@ void delete_modemask(Chan *chan, char *mask, int mode) if ((mode == 'I' && ban->imode == TRUE) || (mode == 'e' && ban->emode == TRUE)) { - if (!Strcasecmp(ban->banstring,mask)) + if (!stringcasecmp(ban->banstring,mask)) { *pp = ban->next; Free((char**)&ban); @@ -364,7 +364,7 @@ void purge_banlist(Chan *chan) chan->banlist = NULL; } -void channel_massmode(Chan *chan, char *pattern, int filtmode, char mode, char typechar) +void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar) { ChanUser *cu; char *pat,*uh,burst[MSGLEN],deopstring[MSGLEN]; @@ -458,8 +458,8 @@ void channel_massmode(Chan *chan, char *pattern, int filtmode, char mode, char t #endif /* DEBUG */ if (willdo && ((cu->flags & CU_MASSTMP) == 0)) { - Strcat(deopstring," "); - Strcat(deopstring,cu->nick); + stringcat(deopstring," "); + stringcat(deopstring,cu->nick); cu->flags |= CU_MASSTMP; i++; } @@ -482,8 +482,8 @@ void channel_massmode(Chan *chan, char *pattern, int filtmode, char mode, char t #endif /* DEBUG */ *burst = 0; } - Strcat(burst,deopstring); - Strcat(burst,"\n"); + stringcat(burst,deopstring); + stringcat(burst,"\n"); } } @@ -580,7 +580,7 @@ void remove_chanuser(Chan *chan, char *nick) uchar ni; /* - * avoid calling Strcasecmp if first char doesnt match + * avoid calling stringcasecmp if first char doesnt match */ ni = nickcmptab[(uchar)(*nick)]; nick++; @@ -635,13 +635,13 @@ void make_chanuser(char *nick, char *userhost) new->idletime = now; new->next = CurrentChan->users; CurrentChan->users = new; - Strcpy(new->userhost,userhost); + stringcpy(new->userhost,userhost); /* * nick can change without anything else changing with it */ set_mallocdoer(make_chanuser); - new->nick = Strdup(nick); + new->nick = stringdup(nick); } void purge_chanusers(Chan *chan) @@ -789,9 +789,9 @@ void do_channels(COMMAND_ARGS) table_buffer("\037channel\037\t \037@\037\t\037users\037\t\037ops\037\t\037voiced\037\t\037modes\037"); for(chan=current->chanlist;chan;chan=chan->next) { - p = Strcpy(text,chan->name); + p = stringcpy(text,chan->name); if (chan == current->activechan) - p = Strcat(p," (current)"); + p = stringcat(p," (current)"); if (chan->active) { u = o = v = 0; @@ -902,17 +902,17 @@ void do_names(COMMAND_ARGS) { ChanUser *cu; Chan *chan; - char names[MSGLEN]; - char *p; + char *p,names[MSGLEN]; + const char *tochan; - p = get_channel(to,&rest); - if ((chan = find_channel_ny(p)) == NULL) + tochan = get_channel(to,&rest); + if ((chan = find_channel_ny(tochan)) == NULL) { - to_user(from,ERR_CHAN,p); + to_user(from,ERR_CHAN,tochan); return; } - to_user(from,"Names on %s%s:",p,(chan->active) ? "" : " (from memory)"); + to_user(from,"Names on %s%s:",tochan,(chan->active) ? "" : " (from memory)"); for(cu=chan->users;cu;) { p = names; @@ -928,7 +928,7 @@ void do_names(COMMAND_ARGS) if ((cu->flags) & CU_VOICE) *(p++) = '+'; - p = Strcpy(p,cu->nick); + p = stringcpy(p,cu->nick); cu = cu->next; } @@ -1067,10 +1067,10 @@ void do_who(COMMAND_ARGS) if (nuh) { - if (!Strcasecmp(nuh,"-ops")) + if (!stringcasecmp(nuh,"-ops")) flags = 1; else - if (!Strcasecmp(nuh,"-nonops")) + if (!stringcasecmp(nuh,"-nonops")) flags = 2; else { @@ -1166,7 +1166,7 @@ void do_showidle(COMMAND_ARGS) n = 10; if (*rest) { - n = a2i(chop(&rest)); + n = asc2int(chop(&rest)); if (errno) { usage(from); /* usage for CurrentCmd->name */ diff --git a/src/config.h.in b/src/config.h.in index 3fc0234..4b56510 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -504,6 +504,13 @@ const char __mx_opts[] = "" #undef OPT_COREONLY #endif /* NEWBIE */ +#ifdef PERL + OPT_COMMA "perl" +#undef OPT_COMMA +#define OPT_COMMA ", " +#undef OPT_COREONLY +#endif /* PERL */ + #ifdef PYTHON OPT_COMMA "python" #undef OPT_COMMA @@ -546,6 +553,20 @@ const char __mx_opts[] = "" #undef OPT_COREONLY #endif /* TELNET */ +#ifdef TOYBOX + OPT_COMMA "toybox" +#undef OPT_COMMA +#define OPT_COMMA ", " +#undef OPT_COREONLY +#endif /* TOYBOX */ + +#ifdef TRIVIA + OPT_COMMA "trivia" +#undef OPT_COMMA +#define OPT_COMMA ", " +#undef OPT_COREONLY +#endif /* TRIVIA */ + #ifdef WINGATES OPT_COMMA "wingate" #undef OPT_COMMA diff --git a/src/core.c b/src/core.c index 49bb26b..f6e1034 100644 --- a/src/core.c +++ b/src/core.c @@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define COMBOT_C +#define CORE_C #include "config.h" #include "defines.h" @@ -66,7 +66,7 @@ void readcfgfile(void) in = -1; #ifdef SESSION - if (!Strcmp(CFGFILE,configfile)) + if (!stringcmp(CFGFILE,configfile)) { if ((in = open(SESSIONFILE,O_RDONLY)) >= 0) { @@ -193,7 +193,7 @@ int write_session(void) #endif /* WEB */ #ifdef UPTIME - if (uptimehost && Strcasecmp(uptimehost,defaultuptimehost)) + if (uptimehost && stringcasecmp(uptimehost,defaultuptimehost)) to_file(sf,"set uphost %s\n",uptimehost); if (uptimeport) to_file(sf,"set upport %i\n",uptimeport); @@ -325,12 +325,12 @@ void setbotnick(Mech *bot, char *nick) /* * if its exactly the same we dont need to change it */ - if (!Strcmp(bot->nick,nick)) + if (!stringcmp(bot->nick,nick)) return; Free((char**)&bot->nick); set_mallocdoer(setbotnick); - bot->nick = Strdup(nick); + bot->nick = stringdup(nick); #ifdef BOTNET botnet_refreshbotinfo(); #endif /* BOTNET */ @@ -346,9 +346,9 @@ Mech *add_bot(int guid, char *nick) bot->sock = -1; bot->guid = guid; set_mallocdoer(add_bot); - bot->nick = Strdup(nick); + bot->nick = stringdup(nick); set_mallocdoer(add_bot); - bot->wantnick = Strdup(nick); + bot->wantnick = stringdup(nick); set_binarydefault(bot->setting); bot->next = botlist; botlist = bot; @@ -511,16 +511,16 @@ Server *add_server(char *host, int port, char *pass) while(*pp) { sp = *pp; - if ((!port || sp->port == port) && (!Strcasecmp(host,sp->name) || !Strcasecmp(host,sp->realname))) + if ((!port || sp->port == port) && (!stringcasecmp(host,sp->name) || !stringcasecmp(host,sp->realname))) return(sp); pp = &sp->next; } set_mallocdoer(add_server); *pp = sp = (Server*)Calloc(sizeof(Server)); sp->ident = serverident++; - Strncpy(sp->name,host,NAMELEN); + stringcpy_n(sp->name,host,NAMELEN); if (pass && *pass) - Strncpy(sp->pass,pass,PASSLEN); + stringcpy_n(sp->pass,pass,PASSLEN); sp->port = (port) ? port : DEFAULT_IRC_PORT; if (currentservergroup) sp->servergroup = currentservergroup->servergroup; @@ -533,7 +533,7 @@ ServerGroup *getservergroup(const char *name) for(sg=servergrouplist;sg;sg=sg->next) { - if (!strcasecmp(sg->name,name)) + if (!stringcasecmp(sg->name,name)) return(sg); } return(NULL); @@ -584,7 +584,7 @@ int try_server(Server *sp, char *hostname) #ifdef DEBUG debug("(try_server) rawdns: %s ==> %s\n",sp->name,host); #endif /* DEBUG */ - Strcpy(temphost,host); + stringcpy(temphost,host); hostname = temphost; } else @@ -794,8 +794,8 @@ int sub_compile_timer(int limit, ulong *flags1, ulong *flags2, char *args) if (!*dash) return -1; - lo = a2i(s); - hi = a2i(dash); + lo = asc2int(s); + hi = asc2int(dash); if (lo < 0 || lo > limit || hi < 0 || hi > limit) return -1; @@ -817,7 +817,7 @@ int sub_compile_timer(int limit, ulong *flags1, ulong *flags2, char *args) } else { - n = a2i(s); + n = asc2int(s); if (n < 0 || n > limit) return -1; if (n >= 30) @@ -910,7 +910,7 @@ int compile_timer(HookTimer *timer, char *rest) char backup[strlen(rest)+1]; char *sec,*min,*hour,*day; - Strcpy(backup,rest); + stringcpy(backup,rest); rest = backup; #ifdef DEBUG debug("(compile_timer) rest = %s\n",nullstr(rest)); @@ -1020,7 +1020,7 @@ void update(SequenceTime *this) if ((now - current->lastreset) > RESETINTERVAL) { current->lastreset = now; - if (Strcmp(current->nick,current->wantnick)) + if (stringcmp(current->nick,current->wantnick)) to_server("NICK %s\n",current->wantnick); check_idlekick(); if ((x = current->setting[INT_AAWAY].int_var) && current->away == FALSE) @@ -1244,7 +1244,7 @@ void do_core(COMMAND_ARGS) bu++; } - i = Strcmp(current->nick,current->wantnick); + i = stringcmp(current->nick,current->wantnick); if (i) table_buffer(TEXT_CURRNICKWANT,current->nick,current->wantnick,current->guid); else @@ -1266,12 +1266,12 @@ void do_core(COMMAND_ARGS) if (chan == current->activechan) { *(pt++) = '\037'; - pt = Strcpy(pt,chan->name); + pt = stringcpy(pt,chan->name); *(pt++) = '\037'; } else { - pt = Strcpy(pt,chan->name); + pt = stringcpy(pt,chan->name); } if (chan->next) *(pt++) = ' '; @@ -1341,9 +1341,9 @@ void do_die(COMMAND_ARGS) } set_mallocdoer(do_die); - current->signoff = Strdup(reason); + current->signoff = stringdup(reason); set_mallocdoer(do_die); - current->from = Strdup(from); + current->from = stringdup(from); current->connect = CN_BOTDIE; } @@ -1394,7 +1394,7 @@ void do_servergroup(COMMAND_ARGS) new = (ServerGroup*)Calloc(sizeof(ServerGroup) + strlen(name)); servergroupid++; new->servergroup = servergroupid; - strcpy(new->name,name); + stringcpy(new->name,name); sgp = &servergrouplist; while(*sgp) sgp = &(*sgp)->next; @@ -1437,7 +1437,7 @@ void do_server(COMMAND_ARGS) */ if (!server) { - if (dcc_only_command(from)) + if (partyline_only_command(from)) return; if (servergrouplist->next) table_buffer(str_underline("server") "\t" str_underline("last connect") "\t" str_underline("group")); @@ -1515,7 +1515,7 @@ void do_server(COMMAND_ARGS) aport = chop(&rest); pass = chop(&rest); - iport = a2i(aport); + iport = asc2int(aport); if (aport && *aport == COMMENT_CHAR) { @@ -1548,7 +1548,7 @@ void do_server(COMMAND_ARGS) dp = NULL; for(sp=serverlist;sp;sp=sp->next) { - if ((!Strcasecmp(server,sp->name)) || (!Strcasecmp(server,sp->realname))) + if ((!stringcasecmp(server,sp->name)) || (!stringcasecmp(server,sp->realname))) { if (!iport || (iport && sp->port == iport)) { @@ -1653,7 +1653,7 @@ void do_nick(COMMAND_ARGS) usage(from); /* usage for CurrentCmd->name */ return; } - guid = a2i(nick); + guid = asc2int(nick); backup = current; if (!errno) { @@ -1689,12 +1689,12 @@ void do_nick(COMMAND_ARGS) { Free((char**)¤t->nick); set_mallocdoer(do_nick); - current->nick = Strdup(nick); + current->nick = stringdup(nick); current->guid = guid; } Free((char**)¤t->wantnick); set_mallocdoer(do_nick); - current->wantnick = Strdup(nick); + current->wantnick = stringdup(nick); to_server("NICK %s\n",current->wantnick); } current = backup; diff --git a/src/ctcp.c b/src/ctcp.c index 10d0851..f6fa817 100644 --- a/src/ctcp.c +++ b/src/ctcp.c @@ -1,7 +1,7 @@ /* EnergyMech, IRC bot software - Parts Copyright (c) 1997-2004 proton + Parts Copyright (c) 1997-2018 proton 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 @@ -28,19 +28,6 @@ #include "text.h" #include "mcmd.h" -int dcc_only_command(char *from) -{ -#ifdef REDIRECT - if (!redirect.to) -#endif /* REDIRECT */ - if (!CurrentDCC) - { - to_user(from,TEXT_DCC_ONLY,CurrentCmd->name); - return(TRUE); - } - return(FALSE); -} - Client *find_client(const char *nick) { Client *client; @@ -50,7 +37,7 @@ Client *find_client(const char *nick) for(client=current->clientlist;client;client=client->next) { - if (((client->flags & DCC_SEND) == 0) && !Strcasecmp(nick,client->user->name)) + if (((client->flags & DCC_SEND) == 0) && !stringcasecmp(nick,client->user->name)) return(client); } return(NULL); @@ -106,49 +93,6 @@ void delete_client(Client *client) Free((char **)&client); } -void partyline_broadcast(Client *from, char *format, char *rest) -{ - Client *client; - Mech *bot; - - for(bot=botlist;bot;bot=bot->next) - { - for(client=bot->clientlist;client;client=client->next) - { - if (0 == (client->flags & (DCC_ACTIVE|DCC_TELNET))) - continue; - if (client == from && client->user->x.x.echo == FALSE) - continue; - to_file(client->sock,format,CurrentNick,rest); - } - } -} - -void dcc_banner(Client *client) -{ - char tmp[MSGLEN]; - - client->flags = DCC_ACTIVE; - client->lasttime = now; - - sprintf(tmp,"[%s] %s[%i] has connected", - current->nick,client->user->name,(int)client->user->x.x.access); - - if ((to_file(client->sock,"[%s] %s\n",time2medium(now),tmp)) < 0) - { - client->flags = DCC_DELETE; - return; - } - send_global(SPYSTR_STATUS,tmp); - if (client->user->x.x.access == OWNERLEVEL) - { - CurrentDCC = client; - Strcpy(tmp,SPYSTR_STATUS); - do_spy(client->user->name,current->nick,tmp,0); - CurrentDCC = NULL; - } -} - #ifdef DCC_FILE int dcc_sendfile(char *target, char *filename) @@ -158,8 +102,8 @@ int dcc_sendfile(char *target, char *filename) int s,f,sz; char tempfile[strlen(filename)+strlen(DCC_PUBLICFILES)+2]; // strlen(DCC_PUBLICFILES) evaluates at compile time to a constant. - Strcpy(tempfile,DCC_PUBLICFILES); - Strcat(tempfile,filename); + stringcpy(tempfile,DCC_PUBLICFILES); + stringcat(tempfile,filename); #ifdef DEBUG debug("(dcc_sendfile) opening %s for transfer\n",tempfile); @@ -184,8 +128,8 @@ int dcc_sendfile(char *target, char *filename) client->user = NULL; client->flags = DCC_WAIT|DCC_ASYNC|DCC_SEND; client->lasttime = now; - client->whom = Strcpy(client->filename,filename) + 1; - Strcpy(client->whom,target); + client->whom = stringcpy(client->filename,filename) + 1; + stringcpy(client->whom,target); client->next = current->clientlist; current->clientlist = client; @@ -265,7 +209,7 @@ void parse_dcc(Client *client) /* * tell them how much we love them */ - dcc_banner(client); + partyline_banner(client); } #ifdef DCC_FILE else @@ -392,7 +336,7 @@ void parse_dcc(Client *client) client->lasttime = now; CurrentDCC = client; CurrentUser = client->user; - Strcpy(CurrentNick,CurrentUser->name); + stringcpy(CurrentNick,CurrentUser->name); if (*ptr == 1) { @@ -438,7 +382,7 @@ void process_dcc(void) #ifdef DEBUG debug("(process_dcc) chat connected [ASYNC]\n"); #endif /* DEBUG */ - dcc_banner(client); + partyline_banner(client); } else if ((client->flags & DCC_WAIT) && ((now - client->lasttime) >= WAITTIMEOUT)) @@ -471,51 +415,6 @@ void process_dcc(void) } } -void dcc_chat(char *from) -{ - struct sockaddr_in sai; - Client *client; - User *user; - int sock,sz; - - if ((user = get_authuser(from,NULL)) == NULL) - return; - if (find_client(user->name)) - return; - - if ((sock = SockListener(0)) < 0) - return; - - sz = sizeof(sai); - if (getsockname(sock,(struct sockaddr *)&sai,&sz) < 0) - { - close(sock); - return; - } - - set_mallocdoer(dcc_chat); - client = (Client*)Calloc(sizeof(Client)); -#ifdef DCC_FILE - client->fileno = -1; -#endif /* DCC_FILE */ - client->user = user; - client->sock = sock; - client->flags = DCC_WAIT; - client->lasttime = now; - - client->next = current->clientlist; - current->clientlist = client; - - to_server("PRIVMSG %s :\001DCC CHAT CHAT %u %u\001\n", - CurrentNick,htonl(current->ip.s_addr),ntohs(sai.sin_port)); -} - -/* - * - * CTCP things... - * - */ - void ctcp_dcc(char *from, char *to, char *rest) { struct in_addr ia; @@ -545,7 +444,7 @@ void ctcp_dcc(char *from, char *to, char *rest) send_spy(SPYSTR_STATUS,"[DCC] :%s[%i]: Requested DCC %s [%s]",CurrentNick,x,port,nullstr(rest)); #ifdef DCC_FILE - if (!Strcasecmp(port,"SEND")) + if (!stringcasecmp(port,"SEND")) { #ifdef DEBUG debug("(ctcp_dcc) rest: `%s'\n",nullstr(rest)); @@ -566,7 +465,7 @@ void ctcp_dcc(char *from, char *to, char *rest) { char tempmask[strlen(addr)+1]; - Strcpy(tempmask,addr); + stringcpy(tempmask,addr); do { port = chop(&addr); @@ -591,9 +490,9 @@ void ctcp_dcc(char *from, char *to, char *rest) addr = chop(&rest); port = chop(&rest); - portnum = a2i(port); + portnum = asc2int(port); x = errno; - filesz = a2i(rest); + filesz = asc2int(rest); if (errno || x || portnum < 1024 || portnum > 63353 || filesz <= 0) return; @@ -604,13 +503,13 @@ void ctcp_dcc(char *from, char *to, char *rest) addr++; } ia.s_addr = ntohl(longip); - Strcpy(ip_addr,inet_ntoa(ia)); + stringcpy(ip_addr,inet_ntoa(ia)); if (1) { char tempname[strlen(filename)+strlen(DCC_PUBLICINCOMING)+1]; // strlen(DCC_PUBLICINCOMING) evaluates to a constant during compile. - Strcpy(Strcpy(tempname,DCC_PUBLICINCOMING),filename); + stringcpy(stringcpy(tempname,DCC_PUBLICINCOMING),filename); if ((f = open(tempname,O_RDWR|O_CREAT|O_EXCL,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) return; @@ -626,8 +525,8 @@ void ctcp_dcc(char *from, char *to, char *rest) client->sock = s; client->flags = DCC_WAIT|DCC_SEND|DCC_RECV; client->lasttime = client->start = now; - client->whom = Strcpy(client->filename,filename) + 1; - Strcpy(client->whom,from); + client->whom = stringcpy(client->filename,filename) + 1; + stringcpy(client->whom,from); client->next = current->clientlist; current->clientlist = client; @@ -635,7 +534,7 @@ void ctcp_dcc(char *from, char *to, char *rest) } else #endif /* DCC_FILE */ - if (x && (x < BOTLEVEL) && !Strcasecmp(port,"CHAT")) + if (x && (x < BOTLEVEL) && !stringcasecmp(port,"CHAT")) { if ((user = get_authuser(from,NULL)) == NULL) { @@ -652,7 +551,7 @@ void ctcp_dcc(char *from, char *to, char *rest) if (!port || !*port) return; - x = a2i(port); + x = asc2int(port); if (errno || (x < 1024) || (x > 65535)) return; @@ -667,7 +566,7 @@ void ctcp_dcc(char *from, char *to, char *rest) addr++; } ia.s_addr = ntohl(longip); - Strcpy(ip_addr,inet_ntoa(ia)); + stringcpy(ip_addr,inet_ntoa(ia)); #ifdef DEBUG debug("(ctcp_dcc) %s [%s,%s]\n",from,ip_addr,port); @@ -821,7 +720,7 @@ void on_ctcp(char *from, char *to, char *rest) } for(i=0;ctcp_commands[i].name;i++) { - if (!Strcasecmp(ctcp_commands[i].name,command)) + if (!stringcasecmp(ctcp_commands[i].name,command)) { #ifdef CTCP if (ctcp_commands[i].need_slot) @@ -861,21 +760,6 @@ void on_ctcp(char *from, char *to, char *rest) * */ -void do_chat(COMMAND_ARGS) -{ - User *user; - - user = get_authuser(from,NULL); - if (!user) - return; - if (find_client(user->name)) - { - to_user(from,"You are already DCC chatting me"); - return; - } - dcc_chat(from); -} - #ifdef CTCP void do_ping_ctcp(COMMAND_ARGS) @@ -887,7 +771,7 @@ void do_ping_ctcp(COMMAND_ARGS) if ((target = chop(&rest))) { - if (CurrentCmd->name == C_PING || !Strcasecmp(rest,"PING")) + if (CurrentCmd->name == C_PING || !stringcasecmp(rest,"PING")) { to_server("PRIVMSG %s :\001PING %lu\001\n",target,now); return; @@ -903,97 +787,6 @@ void do_ping_ctcp(COMMAND_ARGS) #endif /* CTCP */ -#ifdef BOTNET - -void whom_printbot(char *from, BotInfo *binfo, char *stt) -{ - char *us; - int uaccess; - - us = ""; - if (binfo->nuh) - { - uaccess = get_maxaccess(binfo->nuh); - if (uaccess == BOTLEVEL) - us = "b200"; - else - if (uaccess) - sprintf((us = stt),"u%i",uaccess); - } - uaccess = get_authaccess(from,MATCH_ALL); - table_buffer((uaccess >= ASSTLEVEL) ? TEXT_WHOMBOTGUID : TEXT_WHOMBOTLINE,(binfo->nuh) ? nickcpy(NULL,binfo->nuh) : "???",us, - (binfo->server) ? binfo->server : "???",(binfo->version) ? binfo->version : "???",binfo->guid); -} - -#endif /* BOTNET */ - -void do_whom(COMMAND_ARGS) -{ -#ifdef BOTNET - BotNet *bn; - BotInfo *binfo; -#endif /* BOTNET */ - Server *sp; - char stt[NUHLEN]; - Client *client; - Mech *bot; - int m,s; - - if (dcc_only_command(from)) - return; - - for(bot=botlist;bot;bot=bot->next) - { - if (bot->connect == CN_ONLINE) - { - sp = find_server(bot->server); - if (sp) - { - sprintf(stt,"%s:%i",(*sp->realname) ? sp->realname : sp->name,sp->port); - } - else - { - Strcpy(stt,TEXT_NOTINSERVLIST); - } - } - else - { - Strcpy(stt,TEXT_NOTCONNECTED); - } - table_buffer(TEXT_WHOMSELFLINE,bot->nick,(bot == current) ? "(me)" : "b200",stt); - for(client=bot->clientlist;client;client=client->next) - { - m = (now - client->lasttime) / 60; - s = (now - client->lasttime) % 60; - table_buffer(TEXT_WHOMUSERLINE, -#ifdef TELNET - client->user->name,client->user->x.x.access,(client->flags & DCC_TELNET) ? "telnet" : "DCC",m,s); -#else - client->user->name,client->user->x.x.access,"DCC",m,s); -#endif /* TELNET */ - } - } -#ifdef BOTNET - for(bn=botnetlist;bn;bn=bn->next) - { - if (bn->status != BN_LINKED) - continue; - for(binfo=bn->botinfo;binfo;binfo=binfo->next) - whom_printbot(from,binfo,stt); - } -#endif /* BOTNET */ - table_send(from,3); -} - -void do_bye(COMMAND_ARGS) -{ - if (CurrentDCC) - { - to_user(from,TEXT_DCC_GOODBYE); - CurrentDCC->flags = DCC_DELETE; - } -} - #ifdef DCC_FILE void do_send(COMMAND_ARGS) diff --git a/src/debug.c b/src/debug.c index b2c296b..5d82f71 100644 --- a/src/debug.c +++ b/src/debug.c @@ -347,8 +347,8 @@ void strflags(char *dst, const DEFstruct *flagsstruct, int flags) if (flagsstruct[i].v.id & flags) { if (*dst) - Strcat(dst,"|"); - Strcat(dst,flagsstruct[i].idstr); + stringcat(dst,"|"); + stringcat(dst,flagsstruct[i].idstr); } } } @@ -608,7 +608,7 @@ void debug_memory(void) funcname = (char*)proc_lookup(mea->mme[i].doer,mea->mme[i].size); if (funcname) { - Strcpy(t,funcname); + stringcpy(t,funcname); } else { @@ -635,14 +635,14 @@ void debug_memory(void) while(n > 0) { n = n - 8; - Strcat(t,"\t"); + stringcat(t,"\t"); } - Strcat(t,ProcList[i].name); + stringcat(t,ProcList[i].name); n = 32 - strlen(ProcList[i].name); while(n > 0) { n = n - 8; - Strcat(t,"\t"); + stringcat(t,"\t"); } debug("%s%i\t\t%i\t\t%i\n",t,ProcList[i].num,ProcList[i].size,ProcList[i].mall_size); diff --git a/src/defines.h b/src/defines.h index 6d44f78..b34a04f 100644 --- a/src/defines.h +++ b/src/defines.h @@ -82,6 +82,9 @@ #define MAXSHITLEVELSTRING "4" #define MAXSHITLEVELCHAR '4' +#define __STR_ON "on" +#define __STR_OFF "off" + /* * channel modequeues */ diff --git a/src/dns.c b/src/dns.c index 5de5f55..eb58442 100644 --- a/src/dns.c +++ b/src/dns.c @@ -97,7 +97,7 @@ struct in_addr dnsroot_lookup(const char *hostname) for(da=dnsroot;da;da=da->next) { - if (!Strcasecmp(hostname,da->hostname)) + if (!stringcasecmp(hostname,da->hostname)) { #ifdef DEBUG debug("(dnsroot_lookup) %s = %s\n",hostname,inet_ntoa(da->ip)); @@ -208,7 +208,7 @@ void dns_hook(char *host, char * resolved) backbot = current; for(hook=hooklist;hook;hook=hook->next) { - if (hook->flags == HOOK_DNS && !Strcasecmp(host,hook->type.host)) + if (hook->flags == HOOK_DNS && !stringcasecmp(host,hook->type.host)) { for(current=botlist;current;current=current->next) { @@ -294,7 +294,7 @@ void parse_query(int psz, dnsQuery *query) Free((char**)&dns->cname); dns->when = now + 30; set_mallocdoer(parse_query); - dns->cname = Strdup(token2); + dns->cname = stringdup(token2); } if ((unpack_ushort(&rtyp[0]) == DNS_TYPE_A) && @@ -302,7 +302,7 @@ void parse_query(int psz, dnsQuery *query) (unpack_ushort(&rtyp[8]) == 4)) { ip = get_stored_ip(src); - if (dns->auth && !Strcasecmp(dns->auth->hostname,token)) + if (dns->auth && !stringcasecmp(dns->auth->hostname,token)) { dns->auth->ip.s_addr = ip->s_addr; dns->when = now + 60; @@ -311,7 +311,7 @@ void parse_query(int psz, dnsQuery *query) #endif /* DEBUG */ } else - if (!Strcasecmp(dns->host,token) || (dns->cname && !Strcasecmp(dns->cname,token))) + if (!stringcasecmp(dns->host,token) || (dns->cname && !stringcasecmp(dns->cname,token))) { dns->ip.s_addr = ip->s_addr; dns->when = now + 3600; @@ -359,7 +359,7 @@ void parse_query(int psz, dnsQuery *query) set_mallocdoer(parse_query); da = dns->auth = (dnsAuthority*)Calloc(sizeof(dnsAuthority) + strlen(token2)); /* Calloc sets to zero da->ip.s_addr = 0; */ - Strcpy(da->hostname,token2); + stringcpy(da->hostname,token2); } else if (dns->findauth == 1) @@ -370,7 +370,7 @@ void parse_query(int psz, dnsQuery *query) set_mallocdoer(parse_query); da = dns->auth2 = (dnsAuthority*)Calloc(sizeof(dnsAuthority) + strlen(token2)); /* Calloc sets to zero da->ip.s_addr = 0; */ - Strcpy(da->hostname,token2); + stringcpy(da->hostname,token2); #ifdef DEBUG debug("(parse_query) 2nd auth set: %s\n",token2); #endif /* DEBUG */ @@ -407,9 +407,9 @@ void parse_query(int psz, dnsQuery *query) (unpack_ushort(&rtyp[8]) == 4)) { ip = get_stored_ip(src); - if (dns->auth && !Strcasecmp(dns->auth->hostname,token)) + if (dns->auth && !stringcasecmp(dns->auth->hostname,token)) dns->auth->ip.s_addr = ip->s_addr; - if (dns->auth2 && !Strcasecmp(dns->auth2->hostname,token)) + if (dns->auth2 && !stringcasecmp(dns->auth2->hostname,token)) dns->auth2->ip.s_addr = ip->s_addr; #ifdef DEBUG debug("(parse_query) resources: %s = %s\n",token,inet_ntoa(*ip)); @@ -569,7 +569,7 @@ void rawdns(const char *hostname) set_mallocdoer(rawdns); item = (dnsList*)Calloc(sizeof(dnsList) + strlen(hostname)); - Strcpy(item->host,hostname); + stringcpy(item->host,hostname); item->id = ntohs(query->qid); item->when = now + 30; item->next = dnslist; @@ -664,7 +664,7 @@ char *poll_rawdns(char *hostname) for(dns=dnslist;dns;dns=dns->next) { - if (dns->ip.s_addr && !Strcasecmp(dns->host,hostname)) + if (dns->ip.s_addr && !stringcasecmp(dns->host,hostname)) { #ifdef DEBUG debug("(poll_rawdns) a: %s ==> %s\n",hostname,inet_ntoa(dns->ip)); @@ -685,11 +685,11 @@ int read_dnsroot(char *line) name = chop(&line); a = chop(&line); /* TTL is optional */ - if (a && Strcmp(a,"A")) + if (a && stringcmp(a,"A")) a = chop(&line); ip = chop(&line); - if (a && !Strcmp(a,"A") && ip && inet_aton(ip,&ia) != 0) + if (a && !stringcmp(a,"A") && ip && inet_aton(ip,&ia) != 0) { /* remove trailing dot */ for(src=name;*src;) @@ -701,7 +701,7 @@ int read_dnsroot(char *line) } set_mallocdoer(read_dnsroot); da = (dnsAuthority*)Calloc(sizeof(dnsAuthority) + strlen(name)); - Strcpy(da->hostname,name); + stringcpy(da->hostname,name); da->ip.s_addr = ia.s_addr; da->next = dnsroot; dnsroot = da; @@ -747,7 +747,7 @@ void do_dnsroot(COMMAND_ARGS) p = (Strp*)Calloc(strlen(rest)+1); p->next = dnsrootfiles; - Strcpy(p->p,rest); + stringcpy(p->p,rest); dnsrootfiles = p; #endif /* SESSION */ #ifdef DEBUG @@ -785,14 +785,14 @@ void do_dnsserver(COMMAND_ARGS) } else { - p = Strcpy(p,inet_ntoa(ia_ns[i])); + p = stringcpy(p,inet_ntoa(ia_ns[i])); *(p++) = ' '; *p = 0; } } } if (*tempservers == 0) - Strcpy(tempservers,"\037127.0.0.1\037"); + stringcpy(tempservers,"\037127.0.0.1\037"); to_user(from,"Current DNS Servers: %s",tempservers); return; } @@ -900,7 +900,7 @@ flipstep: *dst++ = '.'; goto flipstep; } - Strcpy(Strcpy(dst,host),".in-addr.arpa"); + stringcpy(stringcpy(dst,host),".in-addr.arpa"); #ifdef DEBUG debug("(do_dns) host flipped to %s\n",gsockdata); #endif /* DEBUG */ diff --git a/src/dynamode.c b/src/dynamode.c deleted file mode 100644 index 9727d87..0000000 --- a/src/dynamode.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - - EnergyMech, IRC bot software - Copyright (c) 2001-2004 proton - - 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 of the License, 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. - -*/ -#define DYNAMODE_C -#include "config.h" - -#ifdef DYNAMODE - -#include "defines.h" -#include "structs.h" -#include "global.h" -#include "h.h" - -void check_dynamode(Chan *chan) -{ - ChanUser *cu; - char tempconf[strlen(chan->setting[STR_DYNLIMIT].str_var)+2]; - char ascnum[11]; - char *src,*num,*end; - int n = 0,wind,v[3]; - - /* - * parse `delay:window:minwin' - */ - end = Strcpy(tempconf,chan->setting[STR_DYNLIMIT].str_var); - num = src = tempconf; - for(;(src<=end) && (n<3);src++) - { - if (*src == 0 || *src == ':') - { - *src = 0; - v[n] = a2i(num); - if (errno) - { - v[0] = 90; /* delay */ - v[1] = 10; /* window */ - v[2] = 4; /* minwin */ - break; - } - num = src+1; - n++; - } - } - v[0] = (v[0] < 20) ? 20 : (v[0] > 600) ? 600 : v[0]; - if ((now - chan->lastlimit) < v[0]) - return; - v[1] = (v[1] < 5) ? 5 : (v[1] > 50) ? 50 : v[1]; - v[2] = (v[2] < 1) ? 1 : (v[2] > 50) ? 50 : v[2]; - - chan->lastlimit = now; - - n = 0; - for(cu=chan->users;cu;cu=cu->next) - n++; - - wind = n / v[1]; - if (wind < v[2]) - wind = v[2]; - - wind += n; - - n = wind - chan->limit; - - if (!chan->limitmode || (n < -2) || (n > 1)) - { - sprintf(ascnum,"%i",wind); - send_mode(chan,160,QM_RAWMODE,'+','l',ascnum); - } -} - -#endif /* DYNAMODE */ diff --git a/src/function.c b/src/function.c index 0d95ef4..683d8f2 100644 --- a/src/function.c +++ b/src/function.c @@ -171,7 +171,7 @@ Strp *make_strp(Strp **pp, const char *string) { set_mallocdoer(make_strp); *pp = (Strp*)Calloc(sizeof(Strp) + strlen(string)); - Strcpy((*pp)->p,string); + stringcpy((*pp)->p,string); return(*pp); } @@ -193,6 +193,9 @@ Strp *prepend_strp(Strp **pp, const char *string) return(sp); } +/* + * Free() a chain of Strp's + */ void purge_strplist(Strp *sp) { Strp *nxt; @@ -218,54 +221,94 @@ void dupe_strp(Strp *sp, Strp **pp) } } -const int StrlenX(const char *first, ...) +Strp *e_table = NULL; + +void table_buffer(const char *format, ...) { - const char *s,*o; - int n; - va_list vlist; + Strp **sp; + va_list msg; + int sz; - va_start(vlist,first); + va_start(msg,format); + sz = sizeof(Strp) + vsprintf(gsockdata,format,msg); + va_end(msg); - n = 0; - o = s = first; - do + for(sp=&e_table;*sp;sp=&(*sp)->next) + ; + + set_mallocdoer(table_buffer); + *sp = (Strp*)Calloc(sz); + /* Calloc sets to zero (*sp)->next = NULL; */ + stringcpy((*sp)->p,gsockdata); +} + +void table_send(const char *from, const int space) +{ + char message[MAXLEN]; + Strp *sp,*next; + char *src,*o,*end; + int i,u,g,x,z[6]; + + z[0] = z[1] = z[2] = z[3] = z[4] = z[5] = 0; + for(sp=e_table;sp;sp=sp->next) { - while(*s) - s++; - n += (s - o); - s = o = va_arg(vlist,const char *); + u = i = 0; + src = o = sp->p; + while(*src) + { + if (*src == '\037' || *src == '\002') + u++; + if (*src == '\t' || *src == '\r') + { + x = (src - o) - u; + if (x > z[i]) + z[i] = x; + i++; + o = src+1; + u = 0; + } + src++; + } } - while(s); - va_end(vlist); - return(n); -} + for(sp=e_table;sp;sp=next) + { + next = sp->next; -const int Strlen2(const char *one, const char *two) -{ - const char *s1,*s2; + o = message; + src = sp->p; + g = x = i = 0; + while(*src) + { + if (g) + { + end = src; + while(*end && *end != '\t' && *end != '\r') + end++; + g -= (end - src); + while(g-- > 0) + *(o++) = ' '; + } + if (*src == '\037' || *src == '\002') + x++; + if (*src == '\t' || *src == '\r') + { + if (*src == '\r') + g = z[i+1]; + src++; + x += (z[i++] + space); + while(o < (message + x)) + *(o++) = ' '; + } + else + *(o++) = *(src++); + } + *o = 0; + to_user(from,FMT_PLAIN,message); - if (one) - for(s1=one;*s1;s1++); - if (two) - for(s2=two;*s2;s2++); - - return((s1 - one) + (s2 - two)); -} - -char *nickcpy(char *dest, const char *nuh) -{ - char *ret; - - if (!dest) - dest = nick_buf; - ret = dest; - - while(*nuh && (*nuh != '!')) - *(dest++) = *(nuh++); - *dest = 0; - - return(ret); + Free((char**)&sp); + } + e_table = NULL; } char *getuh(char *nuh) @@ -451,9 +494,9 @@ char *idle2str(time_t when, int small) return(idlestr); } -char *get_channel(char *to, char **rest) +const char *get_channel(const char *to, char **rest) { - char *channel; + const char *channel; if (*rest && ischannel(*rest)) { @@ -469,9 +512,9 @@ char *get_channel(char *to, char **rest) return(channel); } -char *get_channel2(char *to, char **rest) +const char *get_channel2(const char *to, char **rest) { - char *channel; + const char *channel; if (*rest && (**rest == '*' || ischannel(*rest))) { @@ -528,7 +571,7 @@ char *cluster(char *hostname) } *(p++) = *(host++); } - Strcpy(p,".*.*"); + stringcpy(p,".*.*"); } else { @@ -546,9 +589,9 @@ char *cluster(char *hostname) break; host++; } - Strcpy(p,host); + stringcpy(p,host); } - Strcpy(hostname,mask); + stringcpy(hostname,mask); return(hostname); } @@ -566,7 +609,7 @@ char *format_uh(char *userhost, int type) if (STRCHR(userhost,'*')) return(userhost); - Strcpy(tmpmask,userhost); + stringcpy(tmpmask,userhost); h = tmpmask; get_token(&h,"!"); /* discard nickname */ @@ -594,7 +637,7 @@ char *nick2uh(char *from, char *userhost) { if (STRCHR(userhost,'!') && STRCHR(userhost,'@')) { - Strcpy(nuh_buf,userhost); + stringcpy(nuh_buf,userhost); } else if (!STRCHR(userhost,'!') && !STRCHR(userhost,'@')) @@ -609,10 +652,10 @@ char *nick2uh(char *from, char *userhost) } else { - Strcpy(nuh_buf,"*!"); + stringcpy(nuh_buf,"*!"); if (!STRCHR(userhost,'@')) - Strcat(nuh_buf,"*@"); - Strcat(nuh_buf,userhost); + stringcat(nuh_buf,"*@"); + stringcat(nuh_buf,userhost); } return(nuh_buf); } @@ -684,26 +727,7 @@ int is_nick(const char *nick) return(TRUE); } -int capslevel(char *text) -{ - int sz,upper; - - if (!*text) - return(0); - - sz = upper = 0; - while(*text) - { - if ((*text >= 'A' && *text <= 'Z') || (*text == '!')) - upper++; - sz++; - text++; - } - sz = sz / 2; - return(upper >= sz); -} - -int a2i(char *anum) +int asc2int(const char *anum) { int res = 0,neg; @@ -760,146 +784,7 @@ void fix_config_line(char *text) *space = 0; } -/* - * returns NULL or non-zero length string - */ -char *chop(char **src) -{ - char *tok,*cut = *src; - - while(*cut && *cut == ' ') - cut++; - - if (*cut) - { - tok = cut; - while(*cut && *cut != ' ') - cut++; - *src = cut; - while(*cut && *cut == ' ') - cut++; - **src = 0; - *src = cut; - } - else - { - tok = NULL; - } - return(tok); -} - -/* - * remove all '\0' in an array bounded by two pointers - */ -void unchop(char *orig, char *rest) -{ - for(;orignext) - ; - - set_mallocdoer(table_buffer); - *sp = (Strp*)Calloc(sz); - /* Calloc sets to zero (*sp)->next = NULL; */ - Strcpy((*sp)->p,gsockdata); -} - -void table_send(const char *from, const int space) -{ - char message[MAXLEN]; - Strp *sp,*next; - char *src,*o,*end; - int i,u,g,x,z[6]; - - z[0] = z[1] = z[2] = z[3] = z[4] = z[5] = 0; - for(sp=e_table;sp;sp=sp->next) - { - u = i = 0; - src = o = sp->p; - while(*src) - { - if (*src == '\037' || *src == '\002') - u++; - if (*src == '\t' || *src == '\r') - { - x = (src - o) - u; - if (x > z[i]) - z[i] = x; - i++; - o = src+1; - u = 0; - } - src++; - } - } - - for(sp=e_table;sp;sp=next) - { - next = sp->next; - - o = message; - src = sp->p; - g = x = i = 0; - while(*src) - { - if (g) - { - end = src; - while(*end && *end != '\t' && *end != '\r') - end++; - g -= (end - src); - while(g-- > 0) - *(o++) = ' '; - } - if (*src == '\037' || *src == '\002') - x++; - if (*src == '\t' || *src == '\r') - { - if (*src == '\r') - g = z[i+1]; - src++; - x += (z[i++] + space); - while(o < (message + x)) - *(o++) = ' '; - } - else - *(o++) = *(src++); - } - *o = 0; - to_user(from,FMT_PLAIN,message); - - Free((char**)&sp); - } - e_table = NULL; -} - -#ifdef OLDCODE - -int is_safepath(const char *path) -{ - struct stat st; - ino_t ino; - char tmp[PATH_MAX]; - const char *src; - char *dst; - - int path_token_check(void) - { - *dst = 0; - lstat(tmp,&st); - if (!(S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))) - return(FALSE); - if (st.st_ino == parent_inode) - return(FALSE); - return(S_ISDIR(st.st_mode) ? 2 : 1); - } - - if (*(src = path) == '/') - return(FALSE); - - dst = tmp; - while(*src) - { - if (*src == '/' && !path_token_check()) - return(FALSE); - if (dst == tmp + PATH_MAX-1) - return(FALSE); - *dst++ = *src++; - } - return(path_token_check() == 1 ? TRUE : FALSE); -} - -#endif - -#endif /* ifndef TEST at the beginning of file */ - -#define FILE_MUST_EXIST 1 -#define FILE_MAY_EXIST 2 -#define FILE_MUST_NOTEXIST 3 - int is_safepath(const char *path, int filemustexist) { struct stat st; @@ -1210,6 +961,31 @@ void testcase(const char *str, int expected, int filemustexist) } } +const char teststr[] = "dingchat"; + +void teststring(void) +{ + char str[100]; + + stringcpy(str,teststr); + if (stringcmp(str,teststr)) + debug("teststring FAIL: stringcpy(str,%s) != %s (%s)\n",teststr,teststr,str); + else + debug("teststring SUCCESS: stringcpy(str,%s) == %s\n",teststr,teststr); + + stringcpy_n(str+4,"xoom",2); + if (stringcmp(str,"dingxo")) + debug("teststring FAIL: stringcpy_n(str+4,%s,2) != %s (%s)\n","xoom","dingxo",str); + else + debug("teststring SUCCESS: stringcpy_n(str+4,%s,2) == %s\n","xoom","dingxo"); + + stringcat(str,"free"); + if (stringcmp(str,"dingxofree")) + debug("teststring FAIL: stringcat(str,%s) != %s (%s)\n","free","dingxofree",str); + else + debug("teststring SUCCESS: stringcat(str,%s) == %s\n","free","dingxofree"); +} + int main(int argc, char **argv) { struct stat st; @@ -1235,6 +1011,7 @@ int main(int argc, char **argv) testcase("./nosuchfile",1,FILE_MUST_NOTEXIST); testcase("../../nosuchfile",-5,FILE_MUST_NOTEXIST); testcase(P2,-6,FILE_MAY_EXIST); + teststring(); exit(0); } diff --git a/src/gencmd.c b/src/gencmd.c index 2b1673b..dfc92a8 100644 --- a/src/gencmd.c +++ b/src/gencmd.c @@ -193,6 +193,7 @@ struct * Level 80 == ASSTLEVEL */ { 0, "AWAY", "do_away", 80 | CCPW | GAXS }, + { 0, "BOOT", "do_boot", 80 | CCPW | GAXS | CARGS }, #if defined(BOTNET) && defined(REDIRECT) { 0, "CMD", "do_cmd", 80 | CCPW | CARGS }, #endif /* BOTNET && REDIRECT */ diff --git a/src/greet.c b/src/greet.c index bdd23f7..a035323 100644 --- a/src/greet.c +++ b/src/greet.c @@ -138,7 +138,7 @@ void do_greet(COMMAND_ARGS) user->x.x.randline = (isfile == '%') ? TRUE : FALSE; set_mallocdoer(do_greet); - user->greet = Strdup(rest); + user->greet = stringdup(rest); to_user(from,"greeting for user %s has been set to: %s%s",user->name,user->greet, (isfile == '@') ? " (file)" : ((isfile == '%') ? " (random line from file)" : "")); diff --git a/src/h.h b/src/h.h index 2a5a0bc..6a8e9fd 100644 --- a/src/h.h +++ b/src/h.h @@ -28,9 +28,9 @@ #define chkhigh(x) if (x > hisock) { hisock = x; } -#define COMMAND_ARGS char *from, char *to, char *rest, int cmdaccess +#define COMMAND_ARGS char *from, const char *to, char *rest, const int cmdaccess -#define STRCHR strchr +#define STRCHR stringchr #define STREND(x) STRCHR(x,0) /* @@ -54,13 +54,12 @@ #else #define __sect(x) /* nothing */ #endif -#ifdef __GNUC__ +#ifdef __GNUC__ #define __vattr(x) __attribute__ (( x )) #define __page(x) __attribute__ (( __sect(x) )) #define __attr(x,y) __attribute__ (( __sect(x), y )) #define __att2(x,y,z) __attribute__ (( __sect(x), y, z )) - #else #define __vattr(x) /* nothing */ #define __page(x) /* nothing */ @@ -68,12 +67,14 @@ #define __att2(x,y,z) /* nothing */ #endif +// __x86_64__ automatically compiles for regparm optimization #if !defined(__profiling__) && defined(__i386__) -# define __regparm(x) regparm (x) +# define __regparm(x) regparm(x) #else # define __regparm(x) #endif + #define CORE_SEG ".text.a" #define CFG1_SEG ".text.b" #define CMD1_SEG ".text.c" @@ -107,767 +108,689 @@ #endif /* DEBUG */ -/* - 170540 1728 3104 175372 2ad0c energymech-mega -*/ - /* alias.c */ LS void afmt(char *, const char *, const char *) __page(CORE_SEG); -void do_alias(COMMAND_ARGS) __page(CMD1_SEG); -void do_unalias(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_alias(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_unalias(COMMAND_ARGS) __page(CMD1_SEG); /* auth.c */ + +LS char *cipher(char *); +LS char *makepass(char *); +LS int passmatch(char *, char *); +LS void delete_auth(char *); +LS void remove_auth(Auth *); +LS void change_authnick(char *, char *); +LS void aucheck(User *); +LS User *get_authuser(const char *, const char *) __page(CORE_SEG); +LS int get_authaccess(const char *, const char *) __page(CORE_SEG); +LS int make_auth(const char *, const User *); +LS void do_auth(COMMAND_ARGS) __page(CMD1_SEG); + /* bounce.c */ + +void bounce_parse(ircLink *, char *); +void bounce_cleanup(void); +void new_port_bounce(const struct Setting *); +void select_bounce(void); +void process_bounce(void); + /* chanban.c */ + +void process_chanbans(void); +void chanban_action(char *, char *, Shit *); + /* channel.c */ +void check_idlekick(void); LS Chan *find_channel(const char *, int) __attr(CORE_SEG, __regparm(2)); LS Chan *find_channel_ac(const char *) __attr(CORE_SEG, __regparm(1)); LS Chan *find_channel_ny(const char *) __attr(CORE_SEG, __regparm(1)); +void remove_chan(Chan *); +void join_channel(char *, char *); +void reverse_topic(Chan *, char *, char *); +void cycle_channel(Chan *); +int reverse_mode(char *, Chan *, int, int); +void chan_modestr(Chan *, char *); +char *find_nuh(char *); +Ban *make_ban(Ban **, char *, char *, time_t); +void delete_ban(Chan *, char *); +void delete_modemask(Chan *, char *, int); +void purge_banlist(Chan *); +void channel_massmode(const Chan *, char *, int, char, char); +void channel_massunban(Chan *, char *, time_t); +ChanUser *find_chanuser(Chan *, const char *); +void remove_chanuser(Chan *, char *); +void make_chanuser(char *, char *); +void purge_chanusers(Chan *); +char *get_nuh(ChanUser *); +void do_join(COMMAND_ARGS) __page(CMD1_SEG); +void do_part(COMMAND_ARGS) __page(CMD1_SEG); +void do_cycle(COMMAND_ARGS) __page(CMD1_SEG); +void do_forget(COMMAND_ARGS) __page(CMD1_SEG); +void do_channels(COMMAND_ARGS) __page(CMD1_SEG); +void do_wall(COMMAND_ARGS) __page(CMD1_SEG); +void do_mode(COMMAND_ARGS) __page(CMD1_SEG); +void do_names(COMMAND_ARGS) __page(CMD1_SEG); +void do_cchan(COMMAND_ARGS) __page(CMD1_SEG); +void do_invite(COMMAND_ARGS) __page(CMD1_SEG); +void do_sayme(COMMAND_ARGS) __page(CMD1_SEG); +void do_who(COMMAND_ARGS) __page(CMD1_SEG); +void do_topic(COMMAND_ARGS) __page(CMD1_SEG); +void do_showidle(COMMAND_ARGS) __page(CMD1_SEG); +void do_idle(COMMAND_ARGS) __page(CMD1_SEG); /* core.c */ + +void unlink_identfile(void); +int conf_callback(char *line); +void readcfgfile(void); +int write_session(void); +void setbotnick(Mech *bot, char *nick); +Mech *add_bot(int guid, char *nick); +void signoff(char *from, char *reason); +void kill_all_bots(char *reason) __attr(RARE_SEG, __noreturn__);; +Server *add_server(char *host, int port, char *pass); +ServerGroup *getservergroup(const char *name); +ServerGroup *getservergroupid(int id); +Server *find_server(int id); +int try_server(Server *sp, char *hostname); +void connect_to_server(void); +void register_with_server(void); +int sub_compile_timer(int limit, ulong *flags1, ulong *flags2, char *args); +int compile_timer(HookTimer *timer, char *rest); +void update(SequenceTime *this); +void parse_server_input(void); +void do_version(COMMAND_ARGS) __page(CMD1_SEG); +void do_core(COMMAND_ARGS) __page(CMD1_SEG); +void do_die(COMMAND_ARGS) __page(RARE_SEG); +void do_shutdown(COMMAND_ARGS) __page(RARE_SEG); +void do_servergroup(COMMAND_ARGS) __page(CMD1_SEG); +void do_server(COMMAND_ARGS) __page(CMD1_SEG); +void do_cserv(COMMAND_ARGS) __page(CMD1_SEG); +void do_away(COMMAND_ARGS) __page(CMD1_SEG); +void do_do(COMMAND_ARGS) __page(CMD1_SEG); +void do_nick(COMMAND_ARGS) __page(CMD1_SEG); +void do_time(COMMAND_ARGS) __page(CMD1_SEG); +void do_upontime(COMMAND_ARGS) __page(CMD1_SEG); +void do_msg(COMMAND_ARGS) __page(CMD1_SEG); + /* ctcp.c */ + +Client *find_client(const char *nick); +void delete_client(Client *client); +int dcc_sendfile(char *target, char *filename); +void dcc_pushfile(Client *client, off_t where); +int dcc_freeslots(int uaccess); +void parse_dcc(Client *client); +void process_dcc(void); +void ctcp_dcc(char *from, char *to, char *rest); +void ctcp_finger(char *from, char *to, char *rest); +void ctcp_ping(char *from, char *to, char *rest); +void ctcp_version(char *from, char *to, char *rest); +void on_ctcp(char *from, char *to, char *rest); +void do_ping_ctcp(COMMAND_ARGS) __page(CMD1_SEG); +void do_send(COMMAND_ARGS) __page(CMD1_SEG); + /* debug.c */ +void strflags(char *dst, const DEFstruct *flagsstruct, int flags); +const char *strdef(const DEFstruct *dtab, int num); +const char *funcdef(const DEFstruct *dtab, void *func); +void memreset(void); +void memtouch(void *addr); +const char *proc_lookup(void *addr, int size); +char *atime(time_t when); +void debug_server(Server *sp, char *pad); +void debug_settings(UniVar *setting, int type); +void debug_memory(void); +void debug_botinfo(BotInfo *binfo); +void debug_botnet(void); +void debug_core(void); +void debug_rawdns(void); +char *ulong2bin(int limit, ulong x); +void debug_scripthook(void); +void run_debug(void); +int wrap_debug(void); +void do_debug(COMMAND_ARGS) __page(CMD1_SEG); void do_crash(COMMAND_ARGS) __page(RARE_SEG); +void debug(char *format, ...); /* dns.c */ + +void init_rawdns(void); +struct in_addr dnsroot_lookup(const char *hostname); +const char *get_dns_token(const char *src, const char *packet, char *dst, int sz); +int make_query(char *packet, const char *hostname); +struct in_addr *get_stored_ip(const char *ipdata); +void dns_hook(char *host, char * resolved); +void parse_query(int psz, dnsQuery *query); +void rawdns(const char *hostname); +void select_rawdns(void); +void process_rawdns(void); +char *poll_rawdns(char *hostname); +int read_dnsroot(char *line); +ulong rawdns_get_ip(const char *host); +void do_dnsroot(COMMAND_ARGS) __page(CMD1_SEG); +void do_dnsserver(COMMAND_ARGS) __page(CMD1_SEG); +void do_dns(COMMAND_ARGS) __page(CMD1_SEG); + /* dynamode.c */ /* function.c */ LS void *Calloc(int) __attr(CORE_SEG, __regparm(1)); LS void Free(char **) __attr(CORE_SEG, __regparm(1)); - LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS void purge_strplist(Strp *) __attr(CORE_SEG, __regparm(1)); LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2)); - LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1)); LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS char *getuh(char *) __page(CORE_SEG); +LS char *get_token(char **, const char *) __page(CORE_SEG); +LS char *logtime(time_t) __page(CORE_SEG); +LS char *time2str(time_t) __page(CORE_SEG); +LS char *time2away(time_t) __page(CORE_SEG); +LS char *time2medium(time_t) __page(CORE_SEG); +LS char *time2small(time_t) __page(CORE_SEG); +LS char *idle2str(time_t, int) __page(CORE_SEG); +LS const char *get_channel(const char *, char **) __page(CORE_SEG); +LS const char *get_channel2(const char *, char **) __page(CORE_SEG); +LS char *cluster(char *) __page(CORE_SEG); +LS char *format_uh(char *, int) __page(CORE_SEG); +LS char *nick2uh(char *, char *) __page(CORE_SEG); +LS void deop_ban(Chan *, ChanUser *, char *) __page(CORE_SEG); +LS void deop_siteban(Chan *, ChanUser *) __page(CORE_SEG); +LS void screwban_format(char *) __page(CORE_SEG); +LS void deop_screwban(Chan *, ChanUser *) __page(CORE_SEG); +LS int is_nick(const char *) __attr(CORE_SEG, __regparm(1)); +LS int asc2int(const char *) __attr(CORE_SEG, __regparm(1)); +LS int get_number(const char *) __attr(CORE_SEG, __regparm(1)); +LS void fix_config_line(char *) __page(CFG1_SEG); LS int matches(const char *, const char *) __attr(CORE_SEG, __regparm(2)); LS int num_matches(const char *, const char *) __attr(CORE_SEG, __regparm(2)); -LS int a2i(char *) __attr(CORE_SEG, __regparm(1)); +LS void table_buffer(const char *, ...) __page(CMD1_SEG); +LS void table_send(const char *, const int) __page(CMD1_SEG); LS int is_safepath(const char *, int) __attr(CORE_SEG, __regparm(2)); /* greet.c */ + +void greet(void); +void do_greet(COMMAND_ARGS) __page(CMD1_SEG); + /* help.c */ + +void print_help(char *from, char *line, int len); +int do_help_callback(char *line); +void usage_command(char *to, const char *arg); +void usage(char *to); +void do_help(COMMAND_ARGS) __page(CMD1_SEG); +void do_usage(COMMAND_ARGS) __page(CMD1_SEG); + /* hostinfo.c */ + +int parse_proc_status(char *line) __page(CMD1_SEG); +int parse_proc_cpuinfo(char *line) __page(CMD1_SEG); +void do_hostinfo(COMMAND_ARGS) __page(CMD1_SEG); +void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG); +void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG); + /* irc.c */ + +LS void make_ireq(int, const char *, const char *) __page(CMD1_SEG); +void send_pa(int type, const char *nick, const char *format, ...); +void do_irclusers(COMMAND_ARGS) __page(CMD1_SEG); +void do_ircstats(COMMAND_ARGS) __page(CMD1_SEG); +void do_ircwhois(COMMAND_ARGS) __page(CMD1_SEG); + /* kicksay.c */ + +KickSay *find_kicksay(char *text, char *channel); +void check_kicksay(Chan *chan, ChanUser *doer, char *text); +void remove_kicksay(KickSay *kick); +void purge_kicklist(void); +void do_kicksay(COMMAND_ARGS) __page(CMD1_SEG); +void do_rkicksay(COMMAND_ARGS) __page(CMD1_SEG); + +/* lib/string.c */ + +LS char *chop(char **) __attr(CORE_SEG, __regparm(1)); +LS void unchop(char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS int stringcasecmp(const char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS int stringcmp(const char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS int nickcmp(const char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS char *nickcpy(char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS void stringcpy_n(char *, const char *, int) __attr(CORE_SEG, __regparm(3)); +LS char *stringcpy(char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS char *stringcpy2(char *, const char *, const char *) __attr(CORE_SEG, __regparm(3)); +LS char *stringchr(const char *, int) __attr(CORE_SEG, __regparm(2)); +LS char *stringdup(const char *) __attr(CORE_SEG, __regparm(1)); +LS char *stringcat(char *, const char *) __attr(CORE_SEG, __regparm(2)); +LS char *tolowercat(char *, const char *) __attr(CORE_SEG, __regparm(2)); + /* main.c */ +void mech_exec(void); +int randstring_count(char *line); +int randstring_getline(char *line); +LS char *randstring(const char *) __page(CORE_SEG); LS int sig_hup_callback(char *) __page(RARE_SEG); /* rare */ LS void do_sighup(void) __page(CMD1_SEG); -LS void do_sigint(void) __page(RARE_SEG); /* rare */ -LS void do_sigusr1(void) __page(CMD1_SEG); -LS void sig_alrm(int) __page(RARE_SEG); /* rare */ -LS void sig_child(int) __page(RARE_SEG); /* rare */ -LS void sig_bus(int) __page(CMD1_SEG); LS void sig_hup(int) __page(RARE_SEG); /* rare */ -LS void sig_int(int) __page(RARE_SEG); /* rare */ +LS void sig_child(int) __page(RARE_SEG); /* rare */ +LS void sig_alrm(int) __page(RARE_SEG); /* rare */ LS void sig_pipe(int) __page(CORE_SEG); -LS void sig_ill(int) __page(RARE_SEG); -LS void sig_abrt(int) __page(RARE_SEG); -LS void sig_segv(int, siginfo_t *, void *) __page(RARE_SEG); -//LS void sig_segv(int) __page(RARE_SEG); /* rare */ -LS void sig_term(int) __page(RARE_SEG); /* rare */ +LS void do_sigusr1(void) __page(CMD1_SEG); LS void sig_usr1(int) __page(CMD1_SEG); LS void sig_usr2(int) __page(DBUG_SEG); /* DEBUG */ LS void sig_suicide() __attr(RARE_SEG, __noreturn__); /* rare */ +LS void do_sigint(void) __page(RARE_SEG); /* rare */ +LS void sig_int(int) __page(RARE_SEG); /* rare */ +LS void sig_ill(int) __page(RARE_SEG); +LS void sig_abrt(int) __page(RARE_SEG); +LS void sig_bus(int) __page(CMD1_SEG); +LS void sig_segv(int, siginfo_t *, void *) __attr(RARE_SEG, __noreturn__); +LS void sig_term(int) __attr(RARE_SEG, __noreturn__); /* rare */ +LS void doit(void); +LS int main(int argc, char **argv, char **envp); /* net.c */ + +Mech *get_netbot(void); +void reset_linkable(int guid); +void botnet_deaduplink(BotNet *bn); +NetCfg *find_netcfg(int guid); +BotInfo *make_botinfo(int guid, int hops, char *nuh, char *server, char *version); +void botnet_relay(BotNet *source, char *format, ...); +void botnet_refreshbotinfo(void); +void botnet_binfo_relay(BotNet *source, BotInfo *binfo); +void botnet_binfo_tofile(int sock, BotInfo *binfo); +void botnet_dumplinklist(BotNet *bn); +int connect_to_bot(NetCfg *cfg); +void basicAuth(BotNet *bn, char *rest); +void basicAuthOK(BotNet *bn, char *rest); +void basicBanner(BotNet *bn, char *rest); +void basicLink(BotNet *bn, char *version); +void basicQuit(BotNet *bn, char *rest); +void partyAuth(BotNet *bn, char *rest); +int commandlocal(int dg, int sg, char *from, char *command); +void partyCommand(BotNet *bn, char *rest); +void partyMessage(BotNet *bn, char *rest); +void ushareUser(BotNet *bn, char *rest); +void ushareTick(BotNet *bn, char *rest); +void ushareDelete(BotNet *bn, char *rest); +void botnet_parse(BotNet *bn, char *rest); +void botnet_newsock(void); +void select_botnet(void); +void process_botnet(void); +void do_link(COMMAND_ARGS) __page(CMD1_SEG); +void do_cmd(COMMAND_ARGS) __page(CMD1_SEG); + /* net_chan.c */ LS int makecrc(const char *) __page(CORE_SEG); LS void send_suppress(const char *, const char *) __page(CORE_SEG); +ChanUser *find_chanbot(Chan *chan, char *nick); +void check_botjoin(Chan *chan, ChanUser *cu); +void check_botinfo(BotInfo *binfo, const char *channel); +void netchanNeedop(BotNet *source, char *rest); LS void netchanSuppress(BotNet *, char *) __page(CORE_SEG); /* note.c */ + +int catch_note(char *from, char *to, char *rest); +void do_note(COMMAND_ARGS) __page(CMD1_SEG); +void do_read(COMMAND_ARGS) __page(CMD1_SEG); + /* notify.c */ + +void purge_notify(void); +int mask_check(Notify *nf, char *userhost); +void send_ison(void); +void catch_ison(char *rest); +void catch_whois(char *nick, char *userhost, char *realname); +int notifylog_callback(char *rest); +void read_notifylog(void); +void write_notifylog(void); +int notify_callback(char *rest); +int read_notify(char *filename); +void nfshow_brief(Notify *nf); +void nfshow_full(Notify *nf); +void sub_notifynick(char *from, char *rest); +void do_notify(COMMAND_ARGS) __page(CMD1_SEG); + /* ons.c */ + +void on_kick(char *from, char *rest); +void on_join(Chan *chan, char *from); +void on_nick(char *from, char *newnick); +void on_msg(char *from, char *to, char *rest); +void on_mode(char *from, char *channel, char *rest); +void common_public(Chan *chan, char *from, char *spyformat, char *rest); +void on_action(char *from, char *to, char *rest); +int access_needed(char *name); +void do_chaccess(COMMAND_ARGS) __page(CMD1_SEG); +void do_last(COMMAND_ARGS) __page(CMD1_SEG); + /* parse.c */ + +void parse_error(char *from, char *rest); +void parse_invite(char *from, char *rest); +void parse_join(char *from, char *rest); +void parse_mode(char *from, char *rest); +void parse_notice(char *from, char *rest); +void parse_part(char *from, char *rest); +void parse_ping(char *from, char *rest); +void parse_pong(char *from, char *rest); +void parse_privmsg(char *from, char *rest); +void parse_quit(char *from, char *rest); +void parse_topic(char *from, char *rest); +void parse_wallops(char *from, char *rest); +void parse_213(char *from, char *rest); +void parse_219(char *from, char *rest); +void parse_251(char *from, char *rest); +void parse_252(char *from, char *rest); +void parse_253(char *from, char *rest); +void parse_254(char *from, char *rest); +void parse_255(char *from, char *rest); +void parse_301(char *from, char *rest); +void parse_303(char *from, char *rest); +void parse_311(char *from, char *rest); +void parse_312(char *from, char *rest); +void parse_313(char *from, char *rest); +void parse_315(char *from, char *rest); +void parse_317(char *from, char *rest); +void parse_318(char *from, char *rest); +void parse_319(char *from, char *rest); +void parse_324(char *from, char *rest); +void parse_352(char *from, char *rest); +void parse_367(char *from, char *rest); +void parse_376(char *from, char *rest); +void parse_401(char *from, char *rest); +void parse_433(char *from, char *rest); +void parse_451(char *from, char *rest); +void parse_471(char *from, char *rest); +void parse_473(char *from, char *rest); +void parse_346(char *from, char *rest); +void parse_348(char *from, char *rest); +void parse_368(char *from, char *rest); +void parse_005(char *from, char *rest); +ulong stringhash(char *s); +void parseline(char *rest); + +/* partyline.c */ + +LS int check_telnet(int, char *) __page(CMD1_SEG); +LS void check_telnet_pass(Client *, char *) __page(CMD1_SEG); +LS int partyline_only_command(const char *) __page(CMD1_SEG); +LS void partyline_broadcast(const Client *, const char *, const char *) __page(CMD1_SEG); +LS void partyline_banner(Client *) __page(CMD1_SEG); +LS void dcc_chat(char *) __page(CMD1_SEG); +LS void whom_printbot(char *, BotInfo *, char *) __page(CMD1_SEG); +LS void do_whom(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_chat(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_bye(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_boot(COMMAND_ARGS) __page(CMD1_SEG); + /* perl.c */ -LS void do_perl(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_perlscript(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_perl(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_perlscript(COMMAND_ARGS) __page(CMD1_SEG); /* prot.c */ + +void send_kick(Chan *chan, const char *nick, const char *format, ...); +void push_kicks(Chan *chan); +void unmode_chanuser(Chan *chan, ChanUser *cu); +void send_mode(Chan *chan, int pri, int type, char plusminus, char modeflag, void *data); +int mode_effect(Chan *chan, qMode *mode); +void push_modes(Chan *chan, int lowpri); +void update_modes(Chan *chan); +int check_mass(Chan *chan, ChanUser *doer, int type); +void mass_action(Chan *chan, ChanUser *doer); +void prot_action(Chan *chan, char *from, ChanUser *doer, char *target, ChanUser *victim); +LS void check_dynamode(Chan *) __page(CORE_SEG); +void do_opdeopme(COMMAND_ARGS) __page(CMD1_SEG); +void do_opvoice(COMMAND_ARGS) __page(CMD1_SEG); +void do_kickban(COMMAND_ARGS) __page(CMD1_SEG); +void do_unban(COMMAND_ARGS) __page(CMD1_SEG); +void do_banlist(COMMAND_ARGS) __page(CMD1_SEG); + /* python.c */ -/* redirect.c */ -/* reset.c */ -/* seen.c */ -/* shit.c */ -/* socket.c */ - -LS ulong get_ip(const char *) __page(CORE_SEG); -LS int SockAccept(int) __page(CORE_SEG); -LS int SockConnect(char *, int, int) __page(CORE_SEG); -LS void SockFlags(int) __page(CORE_SEG); -LS int SockListener(int) __page(CORE_SEG); -LS int SockOpts(void) __page(CORE_SEG); -LS void do_clearqueue(COMMAND_ARGS) __page(CMD1_SEG); - -/* spy.c */ -/* stats.c */ -/* tcl.c */ -/* telnet.c */ -/* toybox.c */ - -LS void do_ascii(COMMAND_ARGS) __page(CMD1_SEG); - -/* trivia.c */ -/* uptime.c */ -/* urlcap.c */ - -LS void urlcapture(const char *) __page(CORE_SEG); -LS void do_urlhist(COMMAND_ARGS) __page(CMD1_SEG); - -/* user.c */ - -LS void cfg_chan(char *) __page(CFG1_SEG); -LS void cfg_greet(char *) __page(CFG1_SEG); -LS void cfg_mask(char *) __page(CFG1_SEG); -LS void cfg_note(char *) __page(CFG1_SEG); -LS void cfg_opt(char *) __page(CFG1_SEG); -LS void cfg_pass(char *) __page(CFG1_SEG); -LS void cfg_shit(char *) __page(CFG1_SEG); -LS void cfg_user(char *) __page(CFG1_SEG); -void mirror_user(User *) __page(CORE_SEG); -void mirror_userlist(void) __page(CORE_SEG); -LS void addtouser(Strp **, const char *, int) __attr(CORE_SEG, __regparm(3)); -LS int remfromuser(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); - -/* vars.c */ -/* web.c */ - -/* ---------------------- */ - - -LS ChanUser *find_chanuser(Chan *, const char *) __attr(CORE_SEG, __regparm(2)); -LS Client *find_client(const char *) __page(CORE_SEG); -LS Mech *add_bot(int, char *) __page(CORE_SEG); -LS KickSay *find_kicksay(char *, char *) __page(CORE_SEG); -LS Server *add_server(char *, int, char *) __page(CFG1_SEG); -LS Server *find_server(int) __page(CORE_SEG); -LS ServerGroup *getservergroupid(int) __page(CMD1_SEG); -LS Shit *add_shit(char *, char *, char *, char *, int, int) __page(CMD1_SEG); -LS Shit *find_shit(const char *, const char *) __page(CORE_SEG); -LS Shit *get_shituser(char *, char *) __page(CORE_SEG); -LS User *add_user(char *, char *, int) __page(CFG1_SEG); -LS User *find_handle(const char *) __page(CORE_SEG); -LS User *get_authuser(char *, char *) __page(CORE_SEG); -LS User *get_user(const char *, const char *) __page(CORE_SEG); -LS int get_authaccess(char *, char *) __page(CORE_SEG); -LS int get_protaction(Chan *, char *) __page(CORE_SEG); -LS int get_shitaction(const char *, const char *) __page(CORE_SEG); -LS int get_useraccess(const char *, const char *) __page(CORE_SEG); -LS int get_maxaccess(const char *) __page(CORE_SEG); - -LS int Strcasecmp(const char *, const char *) __attr(CORE_SEG, __regparm(2)); -LS int Strcmp(const char *, const char *) __attr(CORE_SEG, __regparm(2)); -LS char *Strcat(char *, const char *) __attr(CORE_SEG, __regparm(2)); -LS char *Strchr(const char *, int) __attr(CORE_SEG, __regparm(2)); -LS char *Strcpy(char *, const char *) __attr(CORE_SEG, __regparm(2)); -LS char *Strdup(const char *) __attr(CORE_SEG, __regparm(1)); -LS void Strncpy(char *, const char *, int) __attr(CORE_SEG, __regparm(3)); -LS char *chop(char **) __attr(CORE_SEG, __regparm(1)); -LS int get_number(const char *) __page(CORE_SEG); -LS int nickcmp(const char *, const char *) __attr(CORE_SEG, __regparm(2)); -LS char *nickcpy(char *, const char *) __attr(CORE_SEG, __regparm(2)); - -LS char *cipher(char *) __page(CMD1_SEG); -LS char *cluster(char *) __page(CMD1_SEG); -LS char *find_nuh(char *) __page(CORE_SEG); -LS char *format_uh(char *, int) __page(CMD1_SEG); -LS char *get_channel(char *, char **) __attr(CMD1_SEG, __regparm(2)); -LS char *get_channel2(char *, char **) __page(CMD1_SEG); -LS char *get_nuh(ChanUser *) __page(CORE_SEG); -LS char *get_token(char **, const char *) __page(CORE_SEG); -LS char *getuh(char *) __page(CORE_SEG); -LS char *idle2str(time_t, int) __page(CORE_SEG); -LS char *makepass(char *) __page(CMD1_SEG); -LS char *nick2uh(char *, char *) __page(CMD1_SEG); -LS char *randstring(char *) __page(CORE_SEG); -LS char *sockread(int, char *, char *) __page(CORE_SEG); -LS char *logtime(time_t) __page(CORE_SEG); -LS void table_buffer(const char *, ...) __attr(CMD1_SEG, format(printf, 1, 2)); -LS void table_send(const char *, const int) __attr(CMD1_SEG, __regparm(2)); -LS char *time2away(time_t) __page(CORE_SEG); -LS char *time2medium(time_t) __page(CORE_SEG); -LS char *time2small(time_t) __page(CMD1_SEG); -LS char *time2str(time_t) __page(CMD1_SEG); -LS char *tolowercat(char *dest, const char *src) __attr(CMD1_SEG, __regparm(2)); -LS int capslevel(char *) __page(CORE_SEG); -LS int check_mass(Chan *, ChanUser *, int) __page(CORE_SEG); -LS int compile_timer(HookTimer *, char *) __page(CORE_SEG); /* SCRIPTING */ -LS int conf_callback(char *) __page(INIT_SEG); /* INIT */ -LS int do_help_callback(char *) __page(CMD1_SEG); -LS int find_setting(char *) __page(CMD1_SEG); -LS int is_bot(const char *) __page(CORE_SEG); -LS int is_nick(const char *) __page(CORE_SEG); -LS int killsock(int) __page(CORE_SEG); -LS int access_needed(char *) __page(CMD1_SEG); -LS int mode_effect(Chan *, qMode *) __page(CORE_SEG); -LS int passmatch(char *, char *) __page(CMD1_SEG); -LS int randstring_count(char *) __page(CORE_SEG); -LS int randstring_getline(char *) __page(CORE_SEG); -LS int read_seenlist(void) __page(CFG1_SEG); -LS int read_seenlist_callback(char *) __page(CFG1_SEG); -LS int read_userlist(char *) __page(CFG1_SEG); -LS int read_userlist_callback(char *) __page(CFG1_SEG); -LS int reverse_mode(char *, Chan *, int, int) __page(CORE_SEG); -LS int to_file(int, const char *, ...) __attr(CORE_SEG, format(printf, 2, 3)); -LS int try_server(Server *, char *) __page(CORE_SEG); -LS int usercanmodify(const char *, const User *) __attr(CORE_SEG, __regparm(2)); -LS int write_seenlist(void) __page(CORE_SEG); -LS int write_session(void) __page(CORE_SEG); -LS int write_userlist(char *) __page(CORE_SEG); -LS void var_resolve_host(const struct Setting *) __page(CFG1_SEG); - -LS ulong stringhash(char *) __page(CORE_SEG); - -/* - * function.c - */ - -LS void aucheck(User *) __attr(CORE_SEG, __regparm(1)); -LS void change_authnick(char *, char *) __page(CORE_SEG); -LS void change_pass(User *, char *) __page(CMD1_SEG); -LS void chan_modestr(Chan *, char *) __page(CMD1_SEG); -LS void channel_massmode(Chan *, char *, int, char, char) __page(CMD1_SEG); -LS void channel_massunban(Chan *, char *, time_t) __page(CMD1_SEG); -LS void check_idlekick(void) __page(CORE_SEG); -LS void check_kicksay(Chan *, ChanUser *, char *) __page(CORE_SEG); -LS void check_shit(void) __page(CORE_SEG); -LS void common_public(Chan *, char *, char *, char *) __page(CORE_SEG); -LS void connect_to_server(void) __page(CORE_SEG); -LS void copy_vars(UniVar *, UniVar *) __page(CMD1_SEG); -LS void ctcp_dcc(char *, char *, char *) __page(CORE_SEG); -LS void cycle_channel(Chan *) __page(CORE_SEG); -LS void dcc_banner(Client *) __page(CORE_SEG); -LS void dcc_chat(char *) __page(CMD1_SEG); -LS int dcc_only_command(char *) __page(CMD1_SEG); -LS void debug(char *, ...) __attr(CORE_SEG, format(printf, 1, 2)); -LS void delete_auth(char *) __page(RARE_SEG); /* rare */ -LS void delete_ban(Chan *, char *) __page(CORE_SEG); -LS void delete_modemask(Chan *, char *, int) __page(CORE_SEG); -LS void delete_client(Client *) __page(CORE_SEG); -LS void delete_vars(UniVar *, int) __page(CMD1_SEG); -LS void deop_ban(Chan *, ChanUser *, char *) __page(CMD1_SEG); -LS void deop_screwban(Chan *, ChanUser *) __page(CMD1_SEG); -LS void deop_siteban(Chan *, ChanUser *) __page(CMD1_SEG); - -LS void do_8ball(COMMAND_ARGS) __page(CMD1_SEG); /* TOYBOX */ -LS void do_access(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_auth(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_away(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_banlist(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_bigsay(COMMAND_ARGS) __page(CMD1_SEG); /* TOYBOX */ -LS void do_bye(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_cchan(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_chaccess(COMMAND_ARGS) __page(CMD1_SEG); /* DYNCMDACCESS */ -LS void do_channels(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_chat(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_clearshit(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_cmd(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_core(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_cserv(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_cycle(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_debug(COMMAND_ARGS) __page(DBUG_SEG); /* DEBUG */ -LS void do_die(COMMAND_ARGS) __page(RARE_SEG); /* rare */ -LS void do_do(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_echo(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_esay(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_forget(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_greet(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_help(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_idle(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_invite(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_irclusers(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_ircstats(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_ircuserhost(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_ircwhois(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_join(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_kick(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_kickban(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_kicksay(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_last(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_link(COMMAND_ARGS) __page(CMD1_SEG); /* BOTNET */ -LS void do_load(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_mode(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_msg(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_names(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_nick(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_note(COMMAND_ARGS) __page(CMD1_SEG); /* NOTE */ -LS void do_notify(COMMAND_ARGS) __page(CMD1_SEG); /* NOTIFY */ -LS void do_opdeopme(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_opvoice(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_part(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_passwd(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_ping_ctcp(COMMAND_ARGS) __page(CMD1_SEG); /* CTCP */ -LS void do_random_msg(COMMAND_ARGS) __page(CMD1_SEG); /* TOYBOX */ -LS void do_randtopic(COMMAND_ARGS) __page(CMD1_SEG); /* TOYBOX */ -LS void do_read(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_reset(COMMAND_ARGS) __page(RARE_SEG); /* rare */ -LS void do_rkicksay(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_rshit(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_rspy(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_save(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_sayme(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_seen(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_server(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_servergroup(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_set(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_setpass(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_shit(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_shitlist(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_showidle(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_who(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_shutdown(COMMAND_ARGS) __page(RARE_SEG); /* rare */ -LS void do_siteban(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_spy(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_time(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_topic(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_trivia(COMMAND_ARGS) __page(CMD1_SEG); /* TRIVIA */ -LS void do_unban(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_upsend(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_upontime(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_usage(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_user(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_userlist(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_version(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_wall(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_whom(COMMAND_ARGS) __page(CMD1_SEG); -/* - * end of commands - */ -LS void fix_config_line(char *) __attr(CORE_SEG, __regparm(1)); -LS void greet(void) __page(CMD1_SEG); -LS void join_channel(char *, char *) __page(CORE_SEG); -LS void kill_all_bots(char *) __attr(RARE_SEG, __noreturn__); /* rare */ -LS int make_auth(const char *, const User *) __page(CORE_SEG); -LS Ban *make_ban(Ban **, char *, char *, time_t) __page(CORE_SEG); -LS void make_chanuser(char *, char *) __attr(CORE_SEG, __regparm(2)); -LS void make_ireq(int, char *, char *) __page(CMD1_SEG); -LS void mass_action(Chan *, ChanUser *) __page(CORE_SEG); -LS void mech_exec(void) __attr(RARE_SEG, __noreturn__); /* rare */ -LS void on_action(char *, char *, char *) __page(CORE_SEG); -LS void on_ctcp(char *, char *, char *) __page(CORE_SEG); -LS void on_join(Chan *, char *) __page(CORE_SEG); -LS void on_kick(char *, char *) __page(CORE_SEG); -LS void on_mode(char *, char *, char *) __page(CORE_SEG); -LS void on_msg(char *, char *, char *) __page(CORE_SEG); -LS void on_nick(char *, char *) __page(CORE_SEG); -LS void parse_213(char *, char *) __page(CMD1_SEG); /* stats C */ -LS void parse_219(char *, char *) __page(CMD1_SEG); /* end of stats */ -LS void parse_251(char *, char *) __page(CORE_SEG); -LS void parse_252(char *, char *) __page(CORE_SEG); -LS void parse_253(char *, char *) __page(CORE_SEG); -LS void parse_254(char *, char *) __page(CORE_SEG); -LS void parse_255(char *, char *) __page(CORE_SEG); -LS void parse_301(char *, char *) __page(CORE_SEG); -LS void parse_311(char *, char *) __page(CORE_SEG); -LS void parse_312(char *, char *) __page(CORE_SEG); -LS void parse_313(char *, char *) __page(CORE_SEG); -LS void parse_315(char *, char *) __page(CORE_SEG); -LS void parse_317(char *, char *) __page(CORE_SEG); -LS void parse_318(char *, char *) __page(CORE_SEG); -LS void parse_319(char *, char *) __page(CORE_SEG); -LS void parse_324(char *, char *) __page(CORE_SEG); -LS void parse_352(char *, char *) __page(CORE_SEG); -LS void parse_367(char *, char *) __page(CORE_SEG); -LS void parse_376(char *, char *) __page(CORE_SEG); -LS void parse_401(char *, char *) __page(CMD1_SEG); /* no such nick/channel */ -LS void parse_433(char *, char *) __page(CORE_SEG); -LS void parse_451(char *, char *) __page(CORE_SEG); -LS void parse_471(char *, char *) __page(CORE_SEG); -LS void parse_473(char *, char *) __page(CORE_SEG); -LS void parse_dcc(Client *) __page(CORE_SEG); -LS void parse_error(char *, char *) __page(CORE_SEG); -LS void parse_invite(char *, char *) __page(CMD1_SEG); -LS void parse_join(char *, char *) __page(CORE_SEG); -LS void parse_mode(char *, char *) __page(CORE_SEG); -LS void parse_notice(char *, char *) __page(CORE_SEG); -LS void parse_part(char *, char *) __page(CORE_SEG); -LS void parse_ping(char *, char *) __page(CORE_SEG); -LS void parse_privmsg(char *, char *) __page(CORE_SEG); -LS void parse_quit(char *, char *) __page(CORE_SEG); -LS void parse_topic(char *, char *) __page(CMD1_SEG); -LS void parse_wallops(char *, char *) __page(CORE_SEG); -LS void parse_server_input(void) __page(CORE_SEG); -LS void parseline(char *) __page(CORE_SEG); -LS void partyline_broadcast(Client *, char *, char *) __page(CORE_SEG); -LS void print_help(char *, char *, int) __page(CMD1_SEG); -LS void process_dcc(void) __page(CORE_SEG); -LS void prot_action(Chan *, char *, ChanUser *, char *, ChanUser *) __page(CORE_SEG); -LS void purge_banlist(Chan *) __page(CORE_SEG); -LS void purge_chanusers(Chan *) __page(CORE_SEG); -LS void purge_shitlist(void) __page(RARE_SEG); /* rare */ -LS void purge_kicklist(void) __page(RARE_SEG); /* rare */ -LS void push_kicks(Chan *) __page(CORE_SEG); -LS void push_modes(Chan *, int) __page(CORE_SEG); -LS void readcfgfile(void) __page(INIT_SEG); /* INIT */ -LS void readline(int s, int (*callback)(char *)) __page(CORE_SEG); -LS void register_with_server(void) __page(CORE_SEG); -LS void remove_auth(Auth *) __page(CORE_SEG); -LS void remove_chan(Chan *) __page(CORE_SEG); -LS void remove_chanuser(Chan *, char *) __attr(CORE_SEG, __regparm (2) ); -LS void remove_kicksay(KickSay *) __page(CMD1_SEG); -LS void remove_ks(KillSock *) __page(CORE_SEG); -LS void remove_shit(Shit *) __page(CMD1_SEG); -LS void remove_user(User *) __page(CMD1_SEG); -LS void reset_userlink(User *, User *) __page(CMD1_SEG); -LS void reverse_topic(Chan *, char *, char *) __page(CORE_SEG); -LS void screwban_format(char *) __page(CMD1_SEG); -LS void send_global(const char *, const char *, ...) __attr(CORE_SEG, format (printf, 2, 3) ); -LS void send_kick(Chan *, const char *, const char *, ...) __attr(CORE_SEG, format (printf, 3, 4) ); -LS void send_mode(Chan *, int, int, char, char, void *) __page(CORE_SEG); -LS void send_pa(int, const char *, const char *, ...) __page(CORE_SEG); -LS void send_spy(const char *, const char *, ...) __attr(CORE_SEG, format (printf, 2, 3) ); -LS void send_uptime(int) __page(CORE_SEG); -LS void set_binarydefault(UniVar *) __page(CFG1_SEG); -LS void set_str_varc(Chan *, int, char *) __page(CFG1_SEG); -LS void setbotnick(Mech *, char *) __page(CORE_SEG); -LS void shit_action(Chan *, ChanUser *) __page(CORE_SEG); -LS void signoff(char *, char *) __page(RARE_SEG); /* rare */ -LS void spy_typecount(Mech *) __page(CMD1_SEG); -LS void to_server(char *, ...) __attr(CORE_SEG, format (printf, 1, 2) ); -LS void to_user(const char *, const char *, ...) __attr(CORE_SEG, format (printf, 2, 3) ); -LS void to_user_q(const char *, const char *, ...) __attr(CORE_SEG, format (printf, 2, 3) ); -LS void unchop(char *, char *) __attr(CORE_SEG, __regparm (2) ); -LS void unmode_chanuser(Chan *, ChanUser *) __page(CORE_SEG); -LS void update(SequenceTime *) __page(CORE_SEG); -LS void update_modes(Chan *) __page(CORE_SEG); -LS void usage(char *) __attr(CMD1_SEG, __regparm (1) ); -LS void usage_command(char *, const char *) __page(CMD1_SEG); -LS void user_sync(void) __page(CFG1_SEG); -LS void whom_printbot(char *, BotInfo *, char *) __page(CMD1_SEG); - -/* - * signals - */ - -/* - * BOTNET prototypes - */ -#ifdef BOTNET - -LS BotInfo *make_botinfo(int, int, char *, char *, char *) __page(CORE_SEG); -LS ChanUser *find_chanbot(Chan *, char *) __page(CORE_SEG); -LS Mech *get_netbot(void) __page(CORE_SEG); -LS NetCfg *find_netcfg(int) __page(CORE_SEG); -LS int connect_to_bot(NetCfg *cfg) __page(CORE_SEG); -LS void basicAuth(BotNet *, char *) __page(CORE_SEG); -LS void basicAuthOK(BotNet *, char *) __page(CORE_SEG); -LS void basicBanner(BotNet *, char *) __page(CORE_SEG); -LS void basicLink(BotNet *, char *) __page(CORE_SEG); -LS void basicQuit(BotNet *, char *) __page(CORE_SEG); -LS void netchanNeedop(BotNet *, char *) __page(CORE_SEG); -LS void partyAuth(BotNet *, char *) __page(CORE_SEG); -LS void partyCommand(BotNet *, char *) __page(CORE_SEG); -LS void partyMessage(BotNet *, char *) __page(CORE_SEG); -LS void ushareDelete(BotNet *, char *) __page(CMD1_SEG); -LS void ushareTick(BotNet *, char *) __page(CORE_SEG); -LS void ushareUser(BotNet *, char *) __page(CORE_SEG); -LS void botnet_binfo_relay(BotNet *, BotInfo *) __attr(CORE_SEG, __regparm (2) ); -LS void botnet_binfo_tofile(int, BotInfo *) __attr(CORE_SEG, __regparm (2) ); -LS void botnet_deaduplink(BotNet *) __page(CORE_SEG); -LS void botnet_dumplinklist(BotNet *) __page(CORE_SEG); -LS void botnet_newsock(void) __page(CORE_SEG); -LS void botnet_parse(BotNet *, char *) __page(CORE_SEG); -LS void botnet_refreshbotinfo(void) __page(CORE_SEG); -LS void botnet_relay(BotNet *, char *, ...) __page(CORE_SEG); -LS void check_botinfo(BotInfo *, const char *) __page(CORE_SEG); -LS void check_botjoin(Chan *, ChanUser *) __page(CORE_SEG); -LS void select_botnet(void) __page(CORE_SEG); -LS void process_botnet(void) __page(CORE_SEG); -LS void reset_linkable(int) __page(CORE_SEG); - -#endif /* BOTNET */ - -/* - * bounce baby bounce! - */ -#ifdef BOUNCE - -LS void new_port_bounce(const struct Setting *) __page(RARE_SEG); -LS void bounce_cleanup(void) __page(RARE_SEG); /* rare */ -LS void bounce_parse(ircLink *, char *) __page(CORE_SEG); -LS void process_bounce(void) __page(CORE_SEG); -LS void select_bounce(void) __page(CORE_SEG); - -#endif /* BOUNCE */ - -/* - * - */ -#ifdef CHANBAN - -LS void do_chanban(COMMAND_ARGS) __page(CMD1_SEG); -LS void process_chanbans(void) __page(CORE_SEG); -LS void chanban_action(char *, char *, Shit *) __page(CORE_SEG); - -#endif /* CHANBAN */ - -/* - * - */ -#ifdef CTCP - -LS void ctcp_finger(char *, char *, char *) __page(CORE_SEG); -LS void ctcp_ping(char *, char *, char *) __page(CORE_SEG); -LS void ctcp_version(char *, char *, char *) __page(CORE_SEG); - -#endif /* CTCP */ - -/* - * - */ -#ifdef DEBUG - -LS char *atime(time_t) __page(DBUG_SEG); -LS const char *proc_lookup(void *, int) __page(DBUG_SEG); -LS const char *strdef(const DEFstruct *, int) __page(DBUG_SEG); -LS void run_debug(void) __page(DBUG_SEG); -LS int wrap_debug(void) __page(DBUG_SEG); -LS void debug_botinfo(BotInfo *) __page(DBUG_SEG); -LS void debug_botnet(void) __page(DBUG_SEG); -LS void debug_core(void) __page(DBUG_SEG); -LS void debug_memory(void) __page(DBUG_SEG); -LS void debug_server(Server *, char *) __page(DBUG_SEG); -LS void debug_settings(UniVar *, int) __page(DBUG_SEG); -LS void memreset(void) __page(DBUG_SEG); -LS void memtouch(void *) __page(DBUG_SEG); -LS char *ulong2bin(int, ulong) __page(DBUG_SEG); - -#endif /* DEBUG */ - -#ifdef DCC_FILE - -LS int dcc_sendfile(char *, char *) __page(CMD1_SEG); -LS void do_send(COMMAND_ARGS) __page(CMD1_SEG); - -#endif /* DCC_FILE */ - -/* - * - */ -#ifdef DYNAMODE - -LS void check_dynamode(Chan *) __page(CORE_SEG); - -#endif /* DYNAMODE */ - -#ifdef HOSTINFO - -LS void do_hostinfo(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG); - -#endif /* HOSTINFO */ -/* - * - */ -#ifdef IDWRAP - -LS void unlink_identfile(void) __page(CORE_SEG); - -#endif /* IDWRAP */ - -/* - * - */ -#ifdef NOTE - -LS int catch_note(char *, char *, char *) __page(CMD1_SEG); - -#endif /* NOTE */ - -/* - * - */ -#ifdef NOTIFY - -LS int mask_check(Notify *, char *) __page(CORE_SEG); -LS int notify_callback(char *) __page(CMD1_SEG); -LS int notifylog_callback(char *) __page(CFG1_SEG); -LS int read_notify(char *) __page(CFG1_SEG); -LS void catch_ison(char *) __page(CORE_SEG); -LS void catch_whois(char *, char *, char *) __page(CORE_SEG); -LS void nfshow_brief(Notify *) __page(CMD1_SEG); -LS void nfshow_full(Notify *) __page(CMD1_SEG); -LS void parse_303(char *, char *) __page(CORE_SEG); -LS void purge_notify(void) __page(CFG1_SEG); -LS void read_notifylog(void) __page(CFG1_SEG); -LS void send_ison(void) __page(CORE_SEG); -LS void write_notifylog(void) __page(CORE_SEG); - -#endif /* NOTIFY */ - -/* - * Python - */ #ifdef PYTHON -#if defined(DEBUG_C) || defined(MAIN_C) || defined(PYTHON_C) -LS void do_python(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_pythonscript(COMMAND_ARGS) __page(CMD1_SEG); -LS int python_parse_jump(char *, char *, Hook *) __page(CORE_SEG); -LS int python_timer_jump(Hook *) __page(CORE_SEG); -LS void python_dcc_complete(Client *, int) __page(CORE_SEG); -LS PyObject *python_hook(PyObject *, PyObject *, PyObject *) __page(CMD1_SEG); -LS PyObject *python_unhook(PyObject *, PyObject *, PyObject *) __page(CMD1_SEG); -LS PyObject *python_to_server(PyObject *, PyObject *, PyObject *) __page(CORE_SEG); -LS PyObject *python_to_file(PyObject *, PyObject *, PyObject *) __page(CORE_SEG); -LS PyObject *python_userlevel(PyObject *, PyObject *, PyObject *) __page(CORE_SEG); -LS PyObject *python_debug(PyObject *, PyObject *) __page(DBUG_SEG); -LS void init_python(void) __page(CFG1_SEG); -LS void free_python(void) __page(CFG1_SEG); +char *python_unicode2char(PyUnicodeObject *obj); +PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds); +PyObject *python_unhook(PyObject *self, PyObject *args, PyObject *keywds); +int python_timer_jump(Hook *hook); +void python_dcc_complete(Client *client, int cps); +PyObject *python_userlevel(PyObject *self, PyObject *args, PyObject *keywds); +PyObject *python_to_server(PyObject *self, PyObject *args, PyObject *keywds); +PyObject *python_to_file(PyObject *self, PyObject *args, PyObject *keywds); +static PyObject *python_dcc_sendfile(PyObject *self, PyObject *args, PyObject *keywds); +PyObject *python_debug(PyObject *self, PyObject *args); +int python_dns_jump(char *host, char *resolved, Hook *hook); +PyMODINIT_FUNC pythonInit(void); +void init_python(void); +void free_python(void); +void do_python(COMMAND_ARGS) __page(CMD1_SEG); +void do_pythonscript(COMMAND_ARGS) __page(CMD1_SEG); -#endif /* defined */ #endif /* PYTHON */ -/* - * - */ -#ifdef RAWDNS +/* redirect.c */ -LS void do_dns(COMMAND_ARGS) __page(CMD1_SEG); -LS void init_rawdns(void) __page(INIT_SEG); /* INIT */ -LS void process_rawdns(void) __page(CORE_SEG); -LS void rawdns(const char *) __page(CORE_SEG); -LS void select_rawdns(void) __page(CORE_SEG); -LS char *poll_rawdns(char *) __page(CORE_SEG); -LS void parse_query(int, dnsQuery *) __page(CORE_SEG); -LS void do_dnsserver(COMMAND_ARGS) __page(CMD1_SEG); -LS void do_dnsroot(COMMAND_ARGS) __page(CMD1_SEG); -LS int read_dnsroot(char *) __page(CFG1_SEG); -LS ulong rawdns_get_ip(const char *) __page(CORE_SEG); +int begin_redirect(char *, char *); +void send_redirect(char *); +void end_redirect(void); -#endif /* RAWDNS */ +/* reset.c */ +// ; -/* - * fun with pipes (aka, REDIRECTS) - */ -#ifdef REDIRECT +char *recover_client(char *env); +char *recover_debug(char *env); +char *recover_server(char *env); +void recover_reset(void); +void do_reset(COMMAND_ARGS) __page(RARE_SEG); -LS int begin_redirect(char *, char *) __page(CORE_SEG); -LS void send_redirect(char *) __page(CMD1_SEG); -LS void end_redirect(void) __page(CORE_SEG); +/* seen.c */ -#endif /* REDIRECT */ +int write_seenlist(void); +int read_seenlist_callback(char *rest); +int read_seenlist(void); +void make_seen(char *nick, char *userhost, char *pa, char *pb, time_t when, int t); +void do_seen(COMMAND_ARGS); -/* - * RESET recover is not a defined feature? - */ -LS char *recover_client(char *) __page(INIT_SEG); /* INIT */ -LS char *recover_debug(char *) __page(INIT_SEG); /* INIT */ -LS char *recover_server(char *) __page(INIT_SEG); /* INIT */ -LS void recover_reset(void) __page(INIT_SEG); /* INIT */ +/* shit.c */ -/* - * - */ -#ifdef SEEN +void shit_action(Chan *chan, ChanUser *cu); +void check_shit(void); +void remove_shit(Shit *shit); +void purge_shitlist(void); +Shit *add_shit(char *from, char *chan, char *mask, char *reason, int axs, int expire); +Shit *find_shit(const char *userhost, const char *channel); +Shit *get_shituser(char *userhost, char *channel); +int get_shitaction(const char *userhost, const char *chan); +void do_shit(COMMAND_ARGS) __page(CMD1_SEG); +void do_rshit(COMMAND_ARGS) __page(CMD1_SEG); +void do_shitlist(COMMAND_ARGS) __page(CMD1_SEG); +void do_clearshit(COMMAND_ARGS) __page(CMD1_SEG); -LS void make_seen(char *, char *, char *, char *, time_t, int) __page(CORE_SEG); /* SEEN */ +/* socket.c */ -#endif /* SEEN */ +LS ulong get_ip(const char *) __page(CORE_SEG); +LS void SockFlags(int) __page(CORE_SEG); +LS int SockOpts(void) __page(CORE_SEG); +LS int SockListener(int) __page(CORE_SEG); +LS int SockConnect(char *, int, int) __page(CORE_SEG); +LS int SockAccept(int) __page(CORE_SEG); +int to_file(int sock, const char *format, ...); +void to_server(char *format, ...); +void to_user_q(const char *, const char *, ...); +void to_user(const char *, const char *, ...); +char *sockread(int, char *, char *); +void readline(int, int (*)(char *)); +void remove_ks(KillSock *); +int killsock(int); +LS void do_clearqueue(COMMAND_ARGS) __page(CMD1_SEG); -/* - * - */ -#ifdef STATS +/* spy.c */ -LS void stats_loghour(Chan *, char *, int) __page(CORE_SEG); -LS void stats_plusminususer(Chan *, int) __page(CORE_SEG); -LS void do_info(COMMAND_ARGS) __page(CMD1_SEG); +void send_spy(const char *src, const char *format, ...); +void send_global(const char *src, const char *format, ...); +void spy_typecount(Mech *bot); +int spy_source(char *from, int *t_src, const char **src); +void do_spy(COMMAND_ARGS) __page(CMD1_SEG); +void do_rspy(COMMAND_ARGS) __page(CMD1_SEG); -#endif /* STATS */ +/* stats.c */ -/* - * Scripts-R-Us - */ +void stats_loghour(Chan *chan, char *filename, int hour); +void stats_plusminususer(Chan *chan, int plusminus); +void do_info(COMMAND_ARGS) __page(CMD1_SEG); + +/* tcl.c */ #ifdef TCL -LS void do_tcl(COMMAND_ARGS) __page(CMD1_SEG); /* TCL + PLEASE_HACK_MY_SHELL */ -LS char *tcl_var_read() __page(CORE_SEG); -LS char *tcl_var_write() __page(CORE_SEG); -LS int tcl_parse_jump() __page(CORE_SEG); -LS int tcl_timer_jump() __page(CORE_SEG); -LS void tcl_dcc_complete(Client *, int) __page(CORE_SEG); -LS int tcl_hook() __page(CMD1_SEG); -LS int tcl_unhook() __page(CMD1_SEG); -LS int tcl_to_server() __page(CORE_SEG); -LS int tcl_to_file() __page(CORE_SEG); -LS int tcl_userlevel() __page(CORE_SEG); -LS int tcl_debug() __page(DBUG_SEG); -LS void init_tcl(void) __page(CFG1_SEG); +char *tcl_var_read(Tcl_TVInfo *vinfo, Tcl_Interp *I, char *n1, char *n2, int flags); +char *tcl_var_write(Tcl_TVInfo *vinfo, Tcl_Interp *I, char *n1, char *n2, int flags); +int tcl_timer_jump(Hook *hook); +int tcl_parse_jump(char *from, char *rest, Hook *hook); +void tcl_dcc_complete(Client *client, int cps); +int tcl_hook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_unhook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_userlevel(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_debug(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_to_server(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_to_file(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_dcc_sendfile(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +int tcl_dns_jump(char *host, char *resolved, Hook *hook); +int tcl_dns(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]); +void init_tcl(void); +void do_tcl(COMMAND_ARGS) __page(CMD1_SEG); #endif /* TCL */ -#ifdef TELNET +/* toybox.c */ -int check_telnet(int, char *) __page(CMD1_SEG); -void check_telnet_pass(Client *, char *) __page(CMD1_SEG); +int read_bigcharset_callback(char *rest); +int read_bigcharset(char *fname); +int read_ascii(char *rest); +void do_bigsay(COMMAND_ARGS) __page(CMD1_SEG); +void do_random_msg(COMMAND_ARGS) __page(CMD1_SEG); +void do_randtopic(COMMAND_ARGS) __page(CMD1_SEG); +void do_8ball(COMMAND_ARGS) __page(CMD1_SEG); +LS void do_ascii(COMMAND_ARGS) __page(CMD1_SEG); -#endif /* TELNET */ +/* trivia.c */ -#ifdef TOYBOX +void trivia_week_toppers(void); +void hint_one(void); +void hint_two(void); +void hint_three(void); +void trivia_cleanup(void); +void trivia_check(Chan *chan, char *rest); +void trivia_no_answer(void); +char *random_question(char *triv_rand); +void trivia_question(void); +void trivia_tick(void); +void write_triviascore(void); +int trivia_score_callback(char *rest); +void read_triviascore(void); +void do_trivia(COMMAND_ARGS) __page(CMD1_SEG); -LS int read_bigcharset(char *) __page(CMD1_SEG); -LS int read_bigcharset_callback(char *) __page(CMD1_SEG); +/* uptime.c */ -#endif /* TOYBOX */ +void init_uptime(void); +void send_uptime(int type); +void uptime_death(int type); +void process_uptime(void); +void do_upsend(COMMAND_ARGS) __page(CMD1_SEG); -#ifdef TRIVIA +/* urlcap.c */ -LS char *random_question(char *) __page(CORE_SEG); -LS int trivia_score_callback(char *) __page(CMD1_SEG); -LS void hint_one(void) __page(CMD1_SEG); -LS void hint_three(void) __page(CMD1_SEG); -LS void hint_two(void) __page(CMD1_SEG); -LS void read_triviascore(void) __page(CMD1_SEG); -LS void trivia_check(Chan *, char *) __page(CORE_SEG); -LS void trivia_cleanup(void) __page(CORE_SEG); -LS void trivia_no_answer(void) __page(CORE_SEG); -LS void trivia_question(void) __page(CORE_SEG); -LS void trivia_tick(void) __page(CORE_SEG); -LS void trivia_week_toppers(void) __page(CORE_SEG); -LS void write_triviascore(void) __page(CMD1_SEG); +char *urlhost(const char *); +LS void urlcapture(const char *) __page(CORE_SEG); +LS void do_urlhist(COMMAND_ARGS) __page(CMD1_SEG); -#endif /* TRIVIA */ - -/* - * UPTIME prototypes - */ -#ifdef UPTIME - -LS void init_uptime(void) __page(INIT_SEG); /* INIT */ -LS void process_uptime(void) __page(CORE_SEG); -LS void uptime_death(int) __page(RARE_SEG); /* rare */ - -#endif /* UPTIME */ +/* user.c */ -/* - * WEB prototypes - */ -#ifdef WEB +LS void cfg_user(char *) __page(CFG1_SEG); +void cfg_modcount(char *); +LS void cfg_pass(char *) __page(CFG1_SEG); +LS void cfg_mask(char *) __page(CFG1_SEG); +LS void cfg_chan(char *) __page(CFG1_SEG); +LS void cfg_opt(char *) __page(CFG1_SEG); +LS void cfg_shit(char *) __page(CFG1_SEG); +void cfg_kicksay(char *); +LS void cfg_greet(char *) __page(CFG1_SEG); +LS void cfg_note(char *) __page(CFG1_SEG); +void user_sync(void); +int read_userlist_callback(char *); +int read_userlist(char *); +int write_userlist(char *); +void rehash_chanusers(void); +LS void addtouser(Strp **, const char *, int) __attr(CORE_SEG, __regparm(3)); +LS int remfromuser(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); +void mirror_user(User *) __page(CORE_SEG); +void mirror_userlist(void) __page(CORE_SEG); +void reset_userlink(User *, User *); +void remove_user(User *); +User *add_user(char *, char *, int); +User *find_handle(const char *); +int userhaschannel(const User *, const char *); +User *get_user(const char *, const char *); +int get_useraccess(const char *, const char *); +int get_maxaccess(const char *); +int is_bot(const char *); +int get_protaction(Chan *, char *); +int usercanmodify(const char *, const User *); +void change_pass(User *, char *) __page(CMD1_SEG); +void do_access(COMMAND_ARGS) __page(CMD1_SEG); +void do_userlist(COMMAND_ARGS) __page(CMD1_SEG); +void do_user(COMMAND_ARGS) __page(CMD1_SEG); +void do_echo(COMMAND_ARGS) __page(CMD1_SEG); +void do_passwd(COMMAND_ARGS) __page(CMD1_SEG); +void do_setpass(COMMAND_ARGS) __page(CMD1_SEG); +void do_save(COMMAND_ARGS) __page(CMD1_SEG); +void do_load(COMMAND_ARGS) __page(CMD1_SEG); -LS char *webread(int, char *, char *) __page(CORE_SEG); -LS void eml_fmt(WebSock *, char *) __page(CORE_SEG); -LS void select_web(void) __page(CORE_SEG); -LS void parse(WebSock *, char *) __page(CORE_SEG); -LS void process_web(void) __page(CORE_SEG); -LS void web_404(WebSock *, char *) __page(CORE_SEG); -LS void web_raw(WebSock *, char *) __page(CORE_SEG); -LS void web_botstatus(WebSock *, char *) __page(CORE_SEG); -LS void web_debug(WebSock *, char *) __page(DBUG_SEG); +/* vars.c */ -#endif /* WEB */ +void set_str_varc(Chan *, int, char *); +int find_setting(const char *); +void copy_vars(UniVar *, UniVar *); +void set_binarydefault(UniVar *); +void delete_vars(UniVar *, int); +void var_resolve_host(const struct Setting *); +void nobo_strcpy(const char *); +void ec_access(char *, const char *); +void ec_capabilities(char *, const char *); +void ec_cc(char *, const char *); +void ec_channels(char *, const char *); +void ec_time(char *, const char *); +void ec_set(char *, const char *); +void ec_on(char *, const char *); +void ec_server(char *, const char *); +void ec_up(char *, const char *); +void ec_ver(char *, const char *); +void do_esay(COMMAND_ARGS) __page(CMD1_SEG); +void do_set(COMMAND_ARGS) __page(CMD1_SEG); + +/* web.c */ + +char *webread(int, char *, char *); +void eml_fmt(WebSock *, char *); +void web_raw(WebSock *, char *); +void web_botstatus(WebSock *, char *); +void web_debug(WebSock *, char *); +void web_404(WebSock *, char *); +void parse(WebSock *, char *); +void select_web(void); +void process_web(void); #endif /* H_H */ + diff --git a/src/help.c b/src/help.c index 9d08033..dec1f20 100644 --- a/src/help.c +++ b/src/help.c @@ -68,7 +68,7 @@ void do_help(COMMAND_ARGS) int cur,nxt,count,ci,tl; int in; - if (dcc_only_command(from)) + if (partyline_only_command(from)) return; axs = get_maxaccess(from); @@ -104,11 +104,11 @@ help_loop: if (tl != cur) continue; if (ci != count) - Strcat(line,", "); + stringcat(line,", "); print_help(from,line,strlen(mcmd[i].name)); if (*line == 0) - Strcpy(line," "); - Strcat(line,(char*)mcmd[i].name); + stringcpy(line," "); + stringcat(line,(char*)mcmd[i].name); count--; } print_help(from,line,500); @@ -119,7 +119,7 @@ help_loop: goto help_loop; } - level = a2i(rest); + level = asc2int(rest); if (!errno) { if ((level > axs) || (level < 0)) @@ -132,10 +132,10 @@ help_loop: if (acmd[i] <= level) { if (ci != 0) - Strcat(line,", "); + stringcat(line,", "); ci++; print_help(from,line,strlen(mcmd[i].name)); - Strcat(line,(char*)mcmd[i].name); + stringcat(line,(char*)mcmd[i].name); } } if (ci) @@ -155,10 +155,10 @@ help_loop: if ((!matches(rest,(char*)mcmd[i].name)) && (acmd[i] <= axs)) { if (ci != 0) - Strcat(line,", "); + stringcat(line,", "); ci++; print_help(from,line,strlen(mcmd[i].name)); - Strcat(line,(char*)mcmd[i].name); + stringcat(line,(char*)mcmd[i].name); } } if (ci) @@ -168,7 +168,7 @@ help_loop: return; } - pt = Strcpy(line,HELPDIR); + pt = stringcpy(line,HELPDIR); for(i=0;(rest[i]);i++) { if (rest[i] >= 'a' && rest[i] <= 'z') @@ -213,7 +213,7 @@ help_loop: table_buffer("Level needed: %i",level); for(i=0;ulist[i].command;i++) { - if (!Strcasecmp(rest,ulist[i].command)) + if (!stringcasecmp(rest,ulist[i].command)) { pt = (ulist[i].usage) ? ulist[i].usage : ""; table_buffer("Usage: %s %s",ulist[i].command,pt); @@ -231,7 +231,7 @@ void usage_command(char *to, const char *arg) for(i=0;ulist[i].command;i++) { - if (!Strcasecmp(arg,ulist[i].command)) + if (!stringcasecmp(arg,ulist[i].command)) { pt = ulist[i].usage; to_user_q(to,(pt) ? "Usage: %s %s" : "Usage: %s",ulist[i].command,pt); @@ -258,7 +258,7 @@ void do_usage(COMMAND_ARGS) cmd = chop(&rest); for(i=0;mcmd[i].name;i++) { - if (!Strcasecmp(cmd,mcmd[i].name)) + if (!stringcasecmp(cmd,mcmd[i].name)) { usage_command(from,mcmd[i].name); return; diff --git a/src/hostinfo.c b/src/hostinfo.c index fde166e..f3bb7aa 100644 --- a/src/hostinfo.c +++ b/src/hostinfo.c @@ -1,7 +1,7 @@ /* EnergyMech, IRC bot software - Copyright (c) 2001-2018 proton + Copyright (c) 2018 proton 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 @@ -26,25 +26,9 @@ #include "structs.h" #include "global.h" #include "h.h" -#include "text.h" -#include "mcmd.h" #include -/*---Help:HOSTINFO:(no arguments) - -Equivalent to ``uname -orm'' - -See also: meminfo, cpuinfo -*/ -void do_hostinfo(COMMAND_ARGS) -{ - struct utsname un; - - if (uname(&un) == 0) - to_user_q(from,"%s %s %s",un.sysname,un.release,un.machine); -} - char vmpeak[32]; char vmsize[32]; char vmrss[32]; @@ -102,7 +86,54 @@ int parse_proc_status(char *line) return(FALSE); } -/*---Help:MEMINFO:(no arguments) +char *cpufrom,cpuline[MSGLEN]; +int sentmodel; +int cpus; +int cores; + +/* +proton@endemic:~/energymech/src> cat /proc/loadavg +0.00 0.00 0.00 1/178 6759 +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 23 +model name : Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz +stepping : 7 +microcode : 0x705 +cpu MHz : 2024.267 +cache size : 2048 KB +physical id : 0 +siblings : 4 +core id : 0 +cpu cores : 4 +*/ + +int parse_proc_cpuinfo(char *line) +{ + char *src,*dst; + + if (strncmp(line,"model name\t:",12) == 0) + ; +} + +/* +help:HOSTINFO:(no arguments) + +Equivalent to ``uname -orm'' + +See also: meminfo, cpuinfo +*/ +void do_hostinfo(COMMAND_ARGS) +{ + struct utsname un; + + if (uname(&un) == 0) + to_user_q(from,"%s %s %s",un.sysname,un.release,un.machine); +} + +/* +help:MEMINFO:(no arguments) Will display memory usage of the energymech process. @@ -134,38 +165,8 @@ void do_meminfo(COMMAND_ARGS) vmsize,vmpeak,vmrss,vmexe,vmdata,vmlib,vmstk); } -char *cpufrom,cpuline[MSGLEN]; -int sentmodel; -int cpus; -int cores; - -int parse_proc_cpuinfo(char *line) -{ - char *src,*dst; - - if (strncmp(line,"model name\t:",12) == 0) - ; -} - /* -proton@endemic:~/energymech/src> cat /proc/loadavg -0.00 0.00 0.00 1/178 6759 -processor : 0 -vendor_id : GenuineIntel -cpu family : 6 -model : 23 -model name : Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz -stepping : 7 -microcode : 0x705 -cpu MHz : 2024.267 -cache size : 2048 KB -physical id : 0 -siblings : 4 -core id : 0 -cpu cores : 4 -*/ - -/*---Help:CPUINFO:(no arguments) +help:CPUINFO:(no arguments) See also: hostinfo, meminfo */ diff --git a/src/irc.c b/src/irc.c index 97996c5..ce90934 100644 --- a/src/irc.c +++ b/src/irc.c @@ -31,7 +31,7 @@ /* * nick can be NULL */ -void make_ireq(int t, char *from, char *nick) +void make_ireq(int t, const char *from, const char *nick) { IReq *ir; char *pt; @@ -42,11 +42,11 @@ void make_ireq(int t, char *from, char *nick) ir->t = t; ir->when = now; - pt = Strcat(ir->from,from) + 1; + pt = stringcat(ir->from,from) + 1; if (nick) { ir->nick = pt; - Strcpy(ir->nick,nick); + stringcpy(ir->nick,nick); } ir->next = current->parselist; @@ -67,7 +67,7 @@ void send_pa(int type, const char *nick, const char *format, ...) for(pp=¤t->parselist;(ir = *pp);) { #ifdef RAWDNS - if (ir->t == PA_DNS && !Strcasecmp(nick,ir->nick)) + if (ir->t == PA_DNS && !stringcasecmp(nick,ir->nick)) { #ifdef DEBUG debug("(send_pa) PA_DNS %s\n",ir->nick); diff --git a/src/kicksay.c b/src/kicksay.c index c862eba..f57231d 100644 --- a/src/kicksay.c +++ b/src/kicksay.c @@ -37,7 +37,7 @@ KickSay *find_kicksay(char *text, char *channel) best = 0; for(kick=current->kicklist;kick;kick=kick->next) { - if (!channel || *kick->chan == '*' || !Strcasecmp(channel,kick->chan)) + if (!channel || *kick->chan == '*' || !stringcasecmp(channel,kick->chan)) { num = num_matches(kick->mask,text); if (num > best) @@ -60,7 +60,7 @@ void check_kicksay(Chan *chan, ChanUser *doer, char *text) action = -1; for(kick=current->kicklist;kick;kick=kick->next) { - if (*kick->chan == '*' || !Strcasecmp(chan->name,kick->chan)) + if (*kick->chan == '*' || !stringcasecmp(chan->name,kick->chan)) { if (!matches(kick->mask,text)) { @@ -158,7 +158,7 @@ void do_kicksay(COMMAND_ARGS) return; } - if (dcc_only_command(from)) + if (partyline_only_command(from)) return; table_buffer("\037channel\037\t\037action\037\t\037string\037\t\037kick reason\037"); @@ -179,7 +179,7 @@ void do_kicksay(COMMAND_ARGS) inum = DEFAULT_KS_LEVEL; if (*rest != '"') { - inum = a2i(chop(&rest)); + inum = asc2int(chop(&rest)); if (errno || inum < 0 || inum > MAX_KS_LEVEL) return; } @@ -217,15 +217,15 @@ void do_kicksay(COMMAND_ARGS) kick->action = inum; if (!matches("\\*?*\\*",mask)) - kick->chan = Strcpy(kick->mask,mask) + 1; + kick->chan = stringcpy(kick->mask,mask) + 1; else { kick->mask[0] = '*'; - Strcpy(kick->mask+1,mask); - kick->chan = Strcat(kick->mask,MATCH_ALL) + 1; + stringcpy(kick->mask+1,mask); + kick->chan = stringcat(kick->mask,MATCH_ALL) + 1; } - kick->reason = Strcpy(kick->chan,channel) + 1; - Strcpy(kick->reason,rest); + kick->reason = stringcpy(kick->chan,channel) + 1; + stringcpy(kick->reason,rest); to_user(from,"Now kicking on \"%s\" on %s",mask,channel); current->ul_save++; diff --git a/src/lib/sha.c b/src/lib/sha.c deleted file mode 100644 index 8f999dd..0000000 --- a/src/lib/sha.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include "sha1.h" - -int main(int argc, char **argv) -{ - SHA1_CTX sha; - uint8_t results[20]; - char *buf; - int n; - - buf = "abc"; - n = strlen(buf); - SHA1Init(&sha); - SHA1Update(&sha, (uint8_t *)buf, n); - SHA1Final(results, &sha); - - /* Print the digest as one long hex value */ -printf("a9993e364706816aba3e25717850c26c9cd0d89d <-- expected result\n"); -for (n = 0; n < 20; n++) - printf("%02x", results[n]); - - putchar('\n'); - - return(0); -} diff --git a/src/lib/sha1.c b/src/lib/sha1.c index c2bf174..de7ee3e 100644 --- a/src/lib/sha1.c +++ b/src/lib/sha1.c @@ -19,27 +19,24 @@ A million repetitions of "a" #include #include - /* for uint32_t */ #include - +#include #include "sha1.h" - #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) /* blk0() and blk() perform the initial expand. */ /* I got the idea of expanding during the round function from SSLeay */ #if BYTE_ORDER == LITTLE_ENDIAN -#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ - |(rol(block->l[i],8)&0x00FF00FF)) +#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00)|(rol(block->l[i],8)&0x00FF00FF)) #elif BYTE_ORDER == BIG_ENDIAN -#define blk0(i) block->l[i] +#define blk0(i) block->l[i] #else #error "Endianness not defined!" #endif -#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) + +#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15]^block->l[(i+2)&15]^block->l[i&15],1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); @@ -51,10 +48,7 @@ A million repetitions of "a" /* Hash a single 512-bit block. This is the core of the algorithm. */ -void SHA1Transform( - uint32_t state[5], - const unsigned char buffer[64] -) +void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) { uint32_t a, b, c, d, e; @@ -176,12 +170,8 @@ void SHA1Transform( #endif } - /* SHA1Init - Initialize new context */ - -void SHA1Init( - SHA1_CTX * context -) +void SHA1Init(SHA1_CTX *context) { /* SHA1 initialization constants */ context->state[0] = 0x67452301; @@ -192,14 +182,8 @@ void SHA1Init( context->count[0] = context->count[1] = 0; } - /* Run your data through this. */ - -void SHA1Update( - SHA1_CTX * context, - const unsigned char *data, - uint32_t len -) +void SHA1Update(SHA1_CTX * context, const unsigned char *data, uint32_t len) { uint32_t i; @@ -225,13 +209,8 @@ void SHA1Update( memcpy(&context->buffer[j], &data[i], len - i); } - /* Add padding and return the message digest. */ - -void SHA1Final( - unsigned char digest[20], - SHA1_CTX * context -) +void SHA1Final(unsigned char digest[20], SHA1_CTX *context) { unsigned i; @@ -279,10 +258,7 @@ void SHA1Final( memset(&finalcount, '\0', sizeof(finalcount)); } -void SHA1( - char *hash_out, - const char *str, - int len) +void SHA1(char *hash_out, const char *str, int len) { SHA1_CTX ctx; unsigned int ii; @@ -294,3 +270,28 @@ void SHA1( hash_out[20] = '\0'; } +#ifdef TEST + +int main(int argc, char **argv) +{ + SHA1_CTX sha; + uint8_t results[20]; + char *buf; + int n; + + buf = "abc"; + n = strlen(buf); + SHA1Init(&sha); + SHA1Update(&sha, (uint8_t *)buf, n); + SHA1Final(results, &sha); + + /* Print the digest as one long hex value */ + printf("a9993e364706816aba3e25717850c26c9cd0d89d <-- expected result\n"); + for (n = 0; n < 20; n++) + printf("%02x", results[n]); + + putchar('\n'); + return(0); +} + +#endif TEST diff --git a/src/lib/string.c b/src/lib/string.c index 2642680..2f8f7f3 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -20,28 +20,12 @@ */ #define STRING_C #include "config.h" + #include "defines.h" #include "structs.h" #include "global.h" #include "h.h" -/* - * callers responsibility to make sure text is not NULL - */ -int stringiscaps(const char *text) -{ - int n,upper; - - n = upper = 0; - while(text[n]) - { - if ((text[n] >= 'A' && text[n] <= 'Z') || (text[n] == '!')) - upper += 2; - n++; - } - return(upper >= n); -} - /* * returns NULL or non-zero length string * callers responsibility that src is not NULL diff --git a/src/lib/string.o b/src/lib/string.o index 091a1cfb4ff2a58b1a7417ff5ced3b7428d796d9..072093553b898992992d74a9deff6ba2a3c0d144 100644 GIT binary patch literal 18160 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®Bm@WPuC{p~VXPX`R=mLuI zkAOdxK0f-Sz6#Qt=;g{-+hzdzvy9zWNA z1%*iScdEp+;P(zVe`DZ}`}4e}0h8A*?CB`QTq*wDmstxRYoyrGcK<}P#~Knxe|RcM V|9DPC@}HFr4Ulkr)+FcpzX2i;Y3Kj| diff --git a/src/main.c b/src/main.c index 02b7726..de027ec 100644 --- a/src/main.c +++ b/src/main.c @@ -98,13 +98,13 @@ int randstring_getline(char *line) { if (--r_ct == 0) { - Strcpy(r_str,line); + stringcpy(r_str,line); return(TRUE); } return(FALSE); } -char *randstring(char *file) +char *randstring(const char *file) { int in; @@ -549,7 +549,7 @@ mainloop: #ifdef DEBUG debug("(doit) rawdns: %s ==> %s\n",sp->name,host); #endif /* DEBUG */ - Strcpy(hosttemp,host); + stringcpy(hosttemp,host); host = hosttemp; try_server(sp,host); } @@ -838,10 +838,10 @@ int main(int argc, char **argv, char **envp) /* * Code to detect and recover after a RESET */ -/* -execve( ./energymech, argv = { ./energymech }, envp = { MECHRESET=d3 f1881:2:X12 } ) -(recover_debug) debug fd recovered -*/ + /* + execve( ./energymech, argv = { ./energymech }, + envp = { MECHRESET=d3 f1881:2:X12 } ) + */ while(*envp) { char *p1; @@ -881,7 +881,7 @@ execve( ./energymech, argv = { ./energymech }, envp if ((opt = STRCHR(*argv,' ')) != NULL) { *(opt++) = 0; - respawn = a2i(opt); + respawn = asc2int(opt); if (errno) { to_file(1,bad_exe); diff --git a/src/md5/md5.c b/src/md5/md5.c deleted file mode 100644 index 77b8454..0000000 --- a/src/md5/md5.c +++ /dev/null @@ -1,400 +0,0 @@ -/* md5.c */ -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which - * will fill a supplied 16-byte array with the digest. - */ -#ifndef MD5_CRYPT_C -#define MD5_CRYPT_C - -#include /* for memcpy() */ -#include "md5.h" - -#ifndef HIGHFIRST -#define byteReverse(buf, len) /* Nothing */ -#else -void byteReverse(unsigned char *buf, unsigned longs); - -#ifndef ASM_MD5 -/* - * Note: this code is harmless on little-endian machines. - */ -void -byteReverse(unsigned char *buf, unsigned longs) -{ - uint32 t; - do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; - } while (--longs); -} -#endif -#endif - -/* - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void -MD5Init(struct MD5Context *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; -} - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void -MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) -{ - uint32 t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy(ctx->in, buf, len); -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void -MD5Final(unsigned char digest[16], struct MD5Context *ctx) -{ - unsigned count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((uint32 *) ctx->in)[14] = ctx->bits[0]; - ((uint32 *) ctx->in)[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, (uint32 *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - -#ifndef ASM_MD5 - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ -void -MD5Transform(uint32 buf[4], uint32 const in[16]) -{ - register uint32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -#endif - -/* md5crypt.c */ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - */ -/* - * Ported from FreeBSD to Linux, only minimal changes. --marekm - */ - -static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -static void -to64(char *s, unsigned long v, int n) -{ - while (--n >= 0) { - *s++ = itoa64[v&0x3f]; - v >>= 6; - } -} - -/* - * UNIX password - * - * Use MD5 for what it is best at... - */ -char *md5_crypt(const char *pw, const char *salt) -{ - static char *magic = "$1$"; /* - * This string is magic for - * this algorithm. Having - * it this way, we can get - * get better later on - */ - static char passwd[120], *p; - static const char *sp,*ep; - unsigned char final[16]; - int sl,pl,i,j; - MD5_CTX ctx,ctx1; - unsigned long l; - - /* Refine the Salt first */ - sp = salt; - - /* If it starts with the magic string, then skip that */ - if(!strncmp(sp,magic,strlen(magic))) - sp += strlen(magic); - - /* It stops at the first '$', max 8 chars */ - for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++) - continue; - - /* get the length of the true salt */ - sl = ep - sp; - - MD5Init(&ctx); - - /* The password first, since that is what is most unknown */ - MD5Update(&ctx,pw,strlen(pw)); - - /* Then our magic string */ - MD5Update(&ctx,magic,strlen(magic)); - - /* Then the raw salt */ - MD5Update(&ctx,sp,sl); - - /* Then just as many characters of the MD5(pw,salt,pw) */ - MD5Init(&ctx1); - MD5Update(&ctx1,pw,strlen(pw)); - MD5Update(&ctx1,sp,sl); - MD5Update(&ctx1,pw,strlen(pw)); - MD5Final(final,&ctx1); - for(pl = strlen(pw); pl > 0; pl -= 16) - MD5Update(&ctx,final,pl>16 ? 16 : pl); - - /* Don't leave anything around in vm they could use. */ - memset(final,0,sizeof final); - - /* Then something really weird... */ - for (j=0,i = strlen(pw); i ; i >>= 1) - if(i&1) - MD5Update(&ctx, final+j, 1); - else - MD5Update(&ctx, pw+j, 1); - - /* Now make the output string */ - strcpy(passwd,magic); - strncat(passwd,sp,sl); - strcat(passwd,"$"); - - MD5Final(final,&ctx); - - /* - * and now, just to make sure things don't run too fast - * On a 60 Mhz Pentium this takes 34 msec, so you would - * need 30 seconds to build a 1000 entry dictionary... - */ - for(i=0;i<1000;i++) { - MD5Init(&ctx1); - if(i & 1) - MD5Update(&ctx1,pw,strlen(pw)); - else - MD5Update(&ctx1,final,16); - - if(i % 3) - MD5Update(&ctx1,sp,sl); - - if(i % 7) - MD5Update(&ctx1,pw,strlen(pw)); - - if(i & 1) - MD5Update(&ctx1,final,16); - else - MD5Update(&ctx1,pw,strlen(pw)); - MD5Final(final,&ctx1); - } - - p = passwd + strlen(passwd); - - l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4; - l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4; - l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4; - l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4; - l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4; - l = final[11] ; to64(p,l,2); p += 2; - *p = '\0'; - - /* Don't leave anything around in vm they could use. */ - memset(final,0,sizeof final); - - return passwd; -} - -#endif /* MD5_CRYPT_C */ diff --git a/src/md5/md5.h b/src/md5/md5.h deleted file mode 100644 index e264f68..0000000 --- a/src/md5/md5.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MD5_H -#define MD5_H - -#ifdef __alpha -typedef unsigned int uint32; -#else -typedef unsigned long uint32; -#endif - -struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - unsigned char in[64]; -}; - -void MD5Init(struct MD5Context *context); -void MD5Update(struct MD5Context *context, unsigned char const *buf, - unsigned len); -void MD5Final(unsigned char digest[16], struct MD5Context *context); -void MD5Transform(uint32 buf[4], uint32 const in[16]); - -/* - * This is needed to make RSAREF happy on some MS-DOS compilers. - */ -typedef struct MD5Context MD5_CTX; - -#endif /* !MD5_H */ diff --git a/src/mega.c b/src/mega.c index bee8a1a..315e8f1 100644 --- a/src/mega.c +++ b/src/mega.c @@ -34,6 +34,7 @@ #include "notify.c" #include "ons.c" #include "parse.c" +#include "partyline.c" #include "perl.c" #include "prot.c" #include "python.c" @@ -45,7 +46,6 @@ #include "spy.c" #include "stats.c" #include "tcl.c" -#include "telnet.c" #include "toybox.c" #include "trivia.c" #include "uptime.c" diff --git a/src/net.c b/src/net.c index a360905..925367d 100644 --- a/src/net.c +++ b/src/net.c @@ -164,9 +164,9 @@ BotInfo *make_botinfo(int guid, int hops, char *nuh, char *server, char *version new->guid = guid; new->hops = hops; - new->server = Strcat(new->nuh,nuh) + 1; - new->version = Strcat(new->server,server) + 1; - Strcpy(new->version,version); + new->server = stringcat(new->nuh,nuh) + 1; + new->version = stringcat(new->server,server) + 1; + stringcpy(new->version,version); return(new); } @@ -312,14 +312,14 @@ void basicAuth(BotNet *bn, char *rest) if ((pass = chop(&rest))) { - if (!Strcmp(pass,"PTA")) + if (!stringcmp(pass,"PTA")) authtype = BNAUTH_PLAINTEXT; #ifdef SHACRYPT - if (!Strcmp(pass,"SHA")) + if (!stringcmp(pass,"SHA")) authtype = BNAUTH_SHA; #endif /* SHACRYPT */ #ifdef MD5CRYPT - if (!Strcmp(pass,"MD5")) + if (!stringcmp(pass,"MD5")) authtype = BNAUTH_MD5; #endif /* MD5CRYPT */ } @@ -353,7 +353,7 @@ void basicAuth(BotNet *bn, char *rest) #ifdef DEBUG debug(">> plain text given: \"%s\" stored \"%s\"\n",pass,rest); #endif /* DEBUG */ - if (Strcmp(pass,rest)) + if (stringcmp(pass,rest)) goto badpass; break; #ifdef SHACRYPT @@ -371,7 +371,7 @@ void basicAuth(BotNet *bn, char *rest) debug("(basicAuth) their = %s, mypass = %s :: sha = %s\n", pass,linkpass,enc); #endif /* DEBUG */ - if (!Strcmp(enc,rest)) + if (!stringcmp(enc,rest)) break; } #endif /* SHACRYPT */ @@ -390,7 +390,7 @@ void basicAuth(BotNet *bn, char *rest) debug("(basicAuth) their = %s, mypass = %s :: md5 = %s\n", pass,linkpass,enc); #endif /* DEBUG */ - if (!Strcmp(enc,rest)) + if (!stringcmp(enc,rest)) break; } #endif /* MD5CRYPT */ @@ -448,7 +448,7 @@ void basicBanner(BotNet *bn, char *rest) * find out who's calling */ p = chop(&rest); - guid = a2i(p); + guid = asc2int(p); /* * bad guid received */ @@ -518,7 +518,7 @@ void basicBanner(BotNet *bn, char *rest) * get a session number */ p = chop(&rest); - bn->rsid = a2i(p); + bn->rsid = asc2int(p); if (errno) { botnet_deaduplink(bn); @@ -530,14 +530,14 @@ void basicBanner(BotNet *bn, char *rest) */ while((p = chop(&rest))) { - if (!Strcmp(p,"PTA")) + if (!stringcmp(p,"PTA")) bn->opt.pta = TRUE; #ifdef SHACRYPT - if (!Strcmp(p,"SHA")) + if (!stringcmp(p,"SHA")) bn->opt.sha = TRUE; #endif /* SHACRYPT */ #ifdef MD5CRYPT - if (!Strcmp(p,"MD5")) + if (!stringcmp(p,"MD5")) bn->opt.md5 = TRUE; #endif /* MD5CRYPT */ } @@ -693,12 +693,12 @@ void basicLink(BotNet *bn, char *version) * BL ! */ nuh = chop(&version); - guid = a2i(nuh); + guid = asc2int(nuh); if (errno) return; nuh = chop(&version); - hops = a2i(nuh); + hops = asc2int(nuh); if (errno) return; @@ -747,7 +747,7 @@ void basicQuit(BotNet *bn, char *rest) if (bn->status != BN_LINKED) return; - guid = a2i(rest); + guid = asc2int(rest); if (errno) return; @@ -837,7 +837,7 @@ int commandlocal(int dg, int sg, char *from, char *command) { for(sp=user->mask;sp;sp=sp->next) { - if (!Strcmp(sp->p,uh)) + if (!stringcmp(sp->p,uh)) break; } } @@ -851,13 +851,13 @@ int commandlocal(int dg, int sg, char *from, char *command) redirect.method = R_BOTNET; redirect.guid = sg; set_mallocdoer(commandlocal); - redirect.to = Strdup(CurrentNick); + redirect.to = stringdup(CurrentNick); p1 = tempdata; - p2 = Strcpy(p1,from); + p2 = stringcpy(p1,from); p2++; /* skip past '0' */ *p2 = current->setting[CHR_CMDCHAR].char_var; - Strcpy((*p2 == *command) ? p2 : p2+1,command); + stringcpy((*p2 == *command) ? p2 : p2+1,command); on_msg(p1,current->nick,p2); CurrentDCC = NULL; @@ -887,11 +887,11 @@ void partyCommand(BotNet *bn, char *rest) if ((userhost = chop(&rest)) == NULL || *rest == 0) return; - isguid = a2i(sguid); + isguid = asc2int(sguid); if (errno) return; - idguid = a2i(dguid); + idguid = asc2int(dguid); if (errno) /* == "*" */ { commandlocal(-1,isguid,userhost,rest); @@ -935,10 +935,10 @@ void partyMessage(BotNet *bn, char *rest) if ((src = chop(&rest)) == NULL || *rest == 0) return; - guid = a2i(dst); + guid = asc2int(dst); if (errno) /* == "*" */ { - Strncpy(CurrentNick,src,NUHLEN-1); + stringcpy_n(CurrentNick,src,NUHLEN-1); /* * partyline_broadcast() uses CurrentNick for the first %s in the format */ @@ -989,7 +989,7 @@ void ushareUser(BotNet *bn, char *rest) int i,tick,modcount,uaccess; c = *(rest++); - tick = a2i(chop(&rest)); + tick = asc2int(chop(&rest)); if (errno) return; if ((c != '-' && bn->tick >= tick) && (c != '+' && bn->tick != tick)) @@ -1007,15 +1007,15 @@ void ushareUser(BotNet *bn, char *rest) /* `UU+tick modcount access handle chan pass' */ /* UU+0 4 100 proton * $1$3484$AxMkHvZijkeqb8hA6h9AB/ */ i = 0; - modcount = a2i(chop(&rest)); + modcount = asc2int(chop(&rest)); i += errno; - uaccess = a2i(chop(&rest)); + uaccess = asc2int(chop(&rest)); i += errno; handle = chop(&rest); pass = chop(&rest); if (i == 0 && handle && pass && *pass) { - if (!Strcmp(pass,"none")) + if (!stringcmp(pass,"none")) pass = NULL; i = 0; bn->addsession = (rand() | 1); @@ -1129,7 +1129,7 @@ void ushareTick(BotNet *bn, char *rest) User *user,*senduser; int i; - i = a2i(rest); + i = asc2int(rest); if (errno) return; #ifdef DEBUG @@ -1195,7 +1195,7 @@ void ushareDelete(BotNet *bn, char *rest) int modcount; orig = rest; - modcount = a2i(chop(&rest)); + modcount = asc2int(chop(&rest)); if (errno) return; for(current=botlist;current;current=current->next) @@ -1225,7 +1225,7 @@ void botnet_parse(BotNet *bn, char *rest) #ifdef TELNET if (bn->status == BN_UNKNOWN) { - if (!Strcmp(rest,telnetprompt)) + if (!stringcmp(rest,telnetprompt)) return; if (*rest != 'B') { @@ -1535,7 +1535,7 @@ void do_link(COMMAND_ARGS) else mode = 0; - iguid = a2i(guid); + iguid = asc2int(guid); if (errno) { usage: @@ -1562,7 +1562,7 @@ usage: host = chop(&rest); port = chop(&rest); - iport = a2i(port); + iport = asc2int(port); if (!pass || (host && !port) || (port && (errno || iport < 1 || iport > 65535))) goto usage; @@ -1571,10 +1571,10 @@ usage: cfg->guid = iguid; cfg->port = iport; - cfg->host = Strcat(cfg->pass,pass) + 1; + cfg->host = stringcat(cfg->pass,pass) + 1; if (host) - Strcpy(cfg->host,host); + stringcpy(cfg->host,host); else cfg->host = NULL; @@ -1627,7 +1627,7 @@ void do_cmd(COMMAND_ARGS) int guid; target = chop(&rest); - guid = a2i(target); + guid = asc2int(target); if (errno) { unchop(orig,rest); diff --git a/src/net_chan.c b/src/net_chan.c index ae1c1df..3b958b5 100644 --- a/src/net_chan.c +++ b/src/net_chan.c @@ -100,7 +100,7 @@ void check_botjoin(Chan *chan, ChanUser *cu) for(binfo=bn->botinfo;binfo;binfo=binfo->next) { if (!nickcmp(cu->nick,binfo->nuh) && - !Strcasecmp(cu->userhost,getuh(binfo->nuh))) + !stringcasecmp(cu->userhost,getuh(binfo->nuh))) { if ((cu = find_chanbot(chan,binfo->nuh)) == NULL) return; @@ -129,11 +129,11 @@ void check_botinfo(BotInfo *binfo, const char *channel) { for(chan=current->chanlist;chan;chan=chan->next) { - if (channel && Strcasecmp(channel,chan->name)) + if (channel && stringcasecmp(channel,chan->name)) continue; if ((cu = find_chanbot(chan,binfo->nuh)) == NULL) continue; - if (!Strcasecmp(cu->userhost,userhost)) + if (!stringcasecmp(cu->userhost,userhost)) { cu->flags |= CU_NEEDOP; send_mode(chan,50,QM_CHANUSER,'+','o',(void*)cu); @@ -156,7 +156,7 @@ void netchanNeedop(BotNet *source, char *rest) char *channel; int guid; - guid = a2i(chop(&rest)); + guid = asc2int(chop(&rest)); channel = chop(&rest); if (errno || guid < 1 || !channel) return; @@ -190,7 +190,7 @@ void netchanSuppress(BotNet *source, char *rest) // convert command to const command for(i=0;mcmd[i].name;i++) { - j = Strcasecmp(mcmd[i].name,cmd); + j = stringcasecmp(mcmd[i].name,cmd); if (j < 0) continue; if (j > 0) @@ -202,7 +202,7 @@ void netchanSuppress(BotNet *source, char *rest) if (mcmd[i].name == NULL) return; - crc = a2i(rest); + crc = asc2int(rest); // to all local bots for(backup=botlist;backup;backup=backup->next) diff --git a/src/note.c b/src/note.c index a060953..9db0507 100644 --- a/src/note.c +++ b/src/note.c @@ -47,12 +47,12 @@ int catch_note(char *from, char *to, char *rest) #ifdef DEBUG debug("(catch_note) n->from = %s, n->to = %s\n",n->from,n->to); #endif /* DEBUG */ - if (!Strcasecmp(from,n->from) && !Strcasecmp(to,n->to)) + if (!stringcasecmp(from,n->from) && !stringcasecmp(to,n->to)) { #ifdef DEBUG debug("(catch_note) note to user = %s\n",n->user); #endif /* DEBUG */ - if (!Strcasecmp(rest,".")) + if (rest[0] == '.' && rest[1] == 0) { to_user(from,"Note for %s has been saved",n->user); *pp = n->next; @@ -105,12 +105,9 @@ void do_note(COMMAND_ARGS) n->next = notelist; notelist = n; - /* - * custom Strcat makes it sooooo easy - */ - n->to = Strcat(n->from,from) + 1; - n->user = Strcat(n->to,to) + 1; - Strcpy(n->user,rest); + n->to = stringcat(n->from,from) + 1; + n->user = stringcat(n->to,to) + 1; + stringcpy(n->user,rest); /* * add a note header @@ -143,7 +140,7 @@ void do_read(COMMAND_ARGS) if (rest && (opt = chop(&rest))) { - which = a2i(opt); + which = asc2int(opt); if (errno || !which) goto read_usage; diff --git a/src/notify.c b/src/notify.c index 29c676d..d368d68 100644 --- a/src/notify.c +++ b/src/notify.c @@ -195,7 +195,7 @@ void catch_ison(char *rest) { if (*whoismsg) *(dst++) = ','; *dst = 0; - dst = Strcat(dst,nf->nick); + dst = stringcat(dst,nf->nick); nf->status = NF_WHOIS; } } @@ -248,8 +248,8 @@ void catch_whois(char *nick, char *userhost, char *realname) nlog->signon = now; nlog->next = nf->log; nf->log = nlog; - nlog->realname = Strcat(nlog->userhost,userhost) + 1; - Strcpy(nlog->realname,realname); + nlog->realname = stringcat(nlog->userhost,userhost) + 1; + stringcpy(nlog->realname,realname); /* * if there is a mask, we need a match to announce the online status */ @@ -279,11 +279,11 @@ int notifylog_callback(char *rest) nick = chop(&rest); - on = a2i(chop(&rest)); + on = asc2int(chop(&rest)); if (errno) return(FALSE); - off = a2i(chop(&rest)); + off = asc2int(chop(&rest)); if (errno) return(FALSE); @@ -311,8 +311,8 @@ int notifylog_callback(char *rest) nlog->signoff = off; nlog->next = *pp; *pp = nlog; - nlog->realname = Strcat(nlog->userhost,userhost) + 1; - Strcpy(nlog->realname,rest); + nlog->realname = stringcat(nlog->userhost,userhost) + 1; + stringcpy(nlog->realname,rest); break; } } @@ -381,7 +381,6 @@ void write_notifylog(void) #endif /* DEBUG */ } - int notify_callback(char *rest) { Notify *nf; @@ -443,18 +442,18 @@ int notify_callback(char *rest) */ set_mallocdoer(notify_callback); nf = (Notify*)Calloc(sizeof(Notify) + StrlenX(nick,rest,src,NULL)); - dst = Strcat(nf->nick,nick); + dst = stringcat(nf->nick,nick); if (*rest) { nf->mask = dst + 1; - dst = Strcat(nf->mask,rest); + dst = stringcat(nf->mask,rest); if (STRCHR(nf->mask,' ')) nf->endofmask = dst; } if (src) { nf->info = dst + 1; - Strcpy(nf->info,src); + stringcpy(nf->info,src); } /* put it at the end of notifylist */ *endoflist = nf; @@ -577,11 +576,11 @@ void nfshow_full(Notify *nf) if (s[1] == ':') *(opt++) = ' '; *opt = 0; - opt = Strcat(opt,s); + opt = stringcat(opt,s); while(opt < (mem+18)) *(opt++) = ' '; *opt = 0; - opt = Strcat(opt," -- "); + opt = stringcat(opt," -- "); if (nlog->signoff) { s = time2away(nlog->signoff); @@ -593,7 +592,7 @@ void nfshow_full(Notify *nf) { s = " online now"; } - opt = Strcat(opt,s); + opt = stringcat(opt,s); while(opt < (mem+41)) *(opt++) = ' '; *opt = 0; @@ -654,7 +653,7 @@ void do_notify(COMMAND_ARGS) { while((opt = chop(&rest))) { - if (!Strcmp(opt,"+")) + if (!stringcmp(opt,"+")) { endoflist = ¤t->notifylist; while(*endoflist) @@ -662,14 +661,14 @@ void do_notify(COMMAND_ARGS) notify_callback(rest); return; } - if (!Strcmp(opt,"-")) + if (!stringcmp(opt,"-")) { sub_notifynick(from,rest); return; } for(n=0;nkickedby); set_mallocdoer(on_kick); - chan->kickedby = Strdup(from); + chan->kickedby = stringdup(from); chan->active = FALSE; chan->sync = TRUE; chan->bot_is_op = FALSE; @@ -296,13 +296,13 @@ void on_nick(char *from, char *newnick) */ if (strlen(cu->nick) >= strlen(newnick)) { - Strcpy(cu->nick,newnick); + stringcpy(cu->nick,newnick); } else { Free((char**)&cu->nick); set_mallocdoer(on_nick); - cu->nick = Strdup(newnick); + cu->nick = stringdup(newnick); } /* @@ -447,7 +447,7 @@ recheck_alias: #ifdef ALIAS for(alias=aliaslist;alias;alias=alias->next) { - if (!Strcasecmp(alias->alias,command)) + if (!stringcasecmp(alias->alias,command)) { unchop(command,rest); afmt(amem,alias->format,command); @@ -456,7 +456,7 @@ recheck_alias: #endif /* DEBUG */ rest = amem; pt = chop(&rest); - i = Strcasecmp(pt,command); + i = stringcasecmp(pt,command); command = pt; arec++; if ((arec < MAXALIASRECURSE) && (i != 0)) @@ -481,7 +481,7 @@ recheck_alias: /* * does the hook match? */ - if (hook->flags == HOOK_COMMAND && !Strcasecmp(command,hook->type.command)) + if (hook->flags == HOOK_COMMAND && !stringcasecmp(command,hook->type.command)) { if (hook->func(from,rest,hook)) /* if the hook returns non-zero, the input should not be parsed internally */ @@ -500,7 +500,7 @@ recheck_alias: continue; if (uaccess < acmd[i]) continue; - j = Strcasecmp(mcmd[i].name,command); + j = stringcasecmp(mcmd[i].name,command); if (j < 0) continue; if (j > 0) @@ -550,7 +550,7 @@ recheck_alias: /* * convert the command to uppercase */ - Strcpy(command,mcmd[i].name); + stringcpy(command,mcmd[i].name); /* * send statmsg with info on the command executed @@ -593,7 +593,7 @@ recheck_alias: if (mcmd[i].caxs) { /* get channel name; 1: msg, 2: to, 3: active channel */ - to = get_channel(to,&rest); + to = (char*)get_channel(to,&rest); if (!ischannel(to)) return; uaccess = get_authaccess(from,to); @@ -634,7 +634,7 @@ recheck_alias: { if (mcmd[i].lbuf && ischannel(orig_to)) { - redirect.to = Strdup(to); + redirect.to = stringdup(to); redirect.method = R_PRIVMSG; } else @@ -643,7 +643,7 @@ recheck_alias: } #endif /* REDIRECT */ - if (mcmd[i].dcc && dcc_only_command(from)) + if (mcmd[i].dcc && partyline_only_command(from)) return; mcmd[i].func(from,to,rest,acmd[i]); @@ -958,7 +958,7 @@ modeloop: } Free(&chan->key); set_mallocdoer(on_mode); - chan->key = Strdup((parm) ? parm : "???"); + chan->key = stringdup((parm) ? parm : "???"); } else { @@ -974,7 +974,7 @@ modeloop: if (sign == '+') { parm = chop(&rest); - chan->limit = a2i(parm); + chan->limit = asc2int(parm); if (errno) chan->limit = 0; chan->limitmode = TRUE; @@ -1007,6 +1007,7 @@ modeloop: void common_public(Chan *chan, char *from, char *spyformat, char *rest) { ChanUser *doer; + int n,upper; if (current->spy & SPYF_CHANNEL) send_spy(chan->name,spyformat,CurrentNick,rest); @@ -1016,7 +1017,17 @@ void common_public(Chan *chan, char *from, char *spyformat, char *rest) doer = find_chanuser(chan,from); - if (capslevel(rest)) + // check if more than half of rest is caps + n = upper = 0; + while(rest[n]) + { + if ((rest[n] >= 'A' && rest[n] <= 'Z') || (rest[n] == '!')) + upper += 2; + n++; + } + + // trigger caps flood action + if (upper >= n) { if (check_mass(chan,doer,INT_CKL)) send_kick(chan,CurrentNick,KICK_CAPS); @@ -1082,10 +1093,10 @@ void do_chaccess(COMMAND_ARGS) } dis = FALSE; - newaccess = a2i(axs); + newaccess = asc2int(axs); if (axs) { - if (!Strcasecmp(axs,"disable")) + if (!stringcasecmp(axs,"disable")) { dis = TRUE; newaccess = 100; @@ -1114,7 +1125,7 @@ void do_chaccess(COMMAND_ARGS) for(i=0;mcmd[i].name;i++) { - if (!Strcasecmp(mcmd[i].name,name)) + if (!stringcasecmp(mcmd[i].name,name)) { oldaccess = acmd[i]; if (dis || oldaccess > 200) @@ -1153,7 +1164,7 @@ int access_needed(char *name) for(i=0;mcmd[i].name;i++) { - if (!Strcasecmp(mcmd[i].name,name)) + if (!stringcasecmp(mcmd[i].name,name)) { return(acmd[i]); } @@ -1171,7 +1182,7 @@ void do_last(COMMAND_ARGS) else { thenum = chop(&rest); - num = a2i(thenum); + num = asc2int(thenum); } if ((num < 1) || (num > LASTCMDSIZE)) usage(from); /* usage for CurrentCmd->name */ diff --git a/src/parse.c b/src/parse.c index cc60f50..22aafc2 100644 --- a/src/parse.c +++ b/src/parse.c @@ -202,7 +202,7 @@ void parse_mode(char *from, char *rest) on_mode(from,to,rest); } else - if (!Strcasecmp(current->nick,to)) + if (!stringcasecmp(current->nick,to)) { char *dst; char sign; @@ -256,7 +256,7 @@ void parse_notice(char *from, char *rest) rest++; ctcp = get_token(&rest," \001"); /* rest cannot be NULL */ - if (!Strcasecmp(ctcp,"PING") && ((pingtime = get_number(rest)) != -1)) + if (!stringcasecmp(ctcp,"PING") && ((pingtime = get_number(rest)) != -1)) { send_spy(SPYSTR_STATUS,"[CTCP PING Reply From %s] %i second(s)", CurrentNick,(int)(now - pingtime)); @@ -298,7 +298,7 @@ void parse_part(char *from, char *rest) return; nick = from; - if ((from = Strchr(from,'!'))) + if ((from = stringchr(from,'!'))) { *from = 0; from++; @@ -549,7 +549,7 @@ void parse_251(char *from, char *rest) setbotnick(current,nick); for(sp=serverlist;sp;sp=sp->next) { - if (!Strcasecmp(sp->name,from) || !Strcasecmp(sp->realname,from)) + if (!stringcasecmp(sp->name,from) || !stringcasecmp(sp->realname,from)) { sp->lastconnect = now; current->ontime = now; @@ -706,7 +706,7 @@ void parse_311(char *from, char *rest) { Free((char**)¤t->userhost); set_mallocdoer(parse_311); - current->userhost = Strdup(user); + current->userhost = stringdup(user); #ifdef BOTNET botnet_refreshbotinfo(); #endif /* BOTNET */ @@ -1059,7 +1059,7 @@ void parse_376(char *from, char *rest) if ((sp = find_server(current->server))) { if (*sp->realname == 0) - Strncpy(sp->realname,from,NAMELEN); + stringcpy_n(sp->realname,from,NAMELEN); sp->lastconnect = now; } if (current->connect != CN_ONLINE) @@ -1107,20 +1107,20 @@ void parse_433(char *from, char *rest) chop(&rest); trynick = chop(&rest); - Strcpy(scopy,s); + stringcpy(scopy,s); s = scopy; nick = NULL; do { s2 = chop(&s); - if (current->connect == CN_ONLINE && !Strcasecmp(current->nick,s2)) + if (current->connect == CN_ONLINE && !stringcasecmp(current->nick,s2)) { /* nicks listed first are more worth, dont try nicks after */ break; } if (!nick) nick = s2; - if (!Strcasecmp(trynick,s2)) + if (!stringcasecmp(trynick,s2)) { nick = NULL; } @@ -1141,7 +1141,7 @@ void parse_433(char *from, char *rest) { Free((char**)¤t->nick); set_mallocdoer(parse_433); - current->nick = Strdup(nick); + current->nick = stringdup(nick); } return; } @@ -1313,7 +1313,7 @@ void parse_005(char *from, char *rest) break; if (!matches("modes=?",opt)) { - n = a2i(opt+6); + n = asc2int(opt+6); if (!errno && n >= 1 && n <= 20) { current->setting[INT_MODES].int_var = n; @@ -1323,7 +1323,7 @@ void parse_005(char *from, char *rest) } } else - if (!Strcasecmp("WALLCHOPS",opt)) + if (!stringcasecmp("WALLCHOPS",opt)) { current->ircx_flags |= IRCX_WALLCHOPS; #ifdef DEBUG @@ -1331,7 +1331,7 @@ void parse_005(char *from, char *rest) #endif /* DEBUG */ } else - if (!Strcasecmp("WALLVOICES",opt)) + if (!stringcasecmp("WALLVOICES",opt)) { current->ircx_flags |= IRCX_WALLVOICES; #ifdef DEBUG @@ -1513,7 +1513,7 @@ void parseline(char *rest) /* * does the hook match? */ - if (hook->flags == HOOK_PARSE && !Strcasecmp(command,hook->type.command)) + if (hook->flags == HOOK_PARSE && !stringcasecmp(command,hook->type.command)) { if (hook->func(from,rest,hook)) /* if the hook returns non-zero, the input should not be parsed internally */ diff --git a/src/partyline.c b/src/partyline.c index d12db36..319276d 100644 --- a/src/partyline.c +++ b/src/partyline.c @@ -1,7 +1,7 @@ /* EnergyMech, IRC bot software - Copyright (c) 1997-2004 proton + Copyright (c) 1997-2018 proton 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 @@ -18,17 +18,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define TELNET_C +#define PARTYLINE_C #include "config.h" -#ifdef TELNET - #include "defines.h" #include "structs.h" #include "global.h" #include "h.h" #include "text.h" +#ifdef TELNET + int check_telnet(int s, char *rest) { Client *client; @@ -39,7 +39,7 @@ int check_telnet(int s, char *rest) { for(user=current->userlist;user;user=user->next) { - if (!Strcasecmp(user->name,rest)) + if (!stringcasecmp(user->name,rest)) goto check_telnet_malloc; } } @@ -76,9 +76,235 @@ void check_telnet_pass(Client *client, char *rest) return; } - Strcpy(CurrentNick,client->user->name); - dcc_banner(client); + stringcpy(CurrentNick,client->user->name); + partyline_banner(client); client->flags = DCC_TELNET|DCC_ACTIVE; } #endif /* TELNET */ + +int partyline_only_command(const char *from) +{ +#ifdef REDIRECT + if (!redirect.to) +#endif /* REDIRECT */ + if (!CurrentDCC) + { + to_user(from,TEXT_DCC_ONLY,CurrentCmd->name); + return(TRUE); + } + return(FALSE); +} + +void partyline_broadcast(const Client *from, const char *format, const char *rest) +{ + Client *client; + Mech *bot; + + for(bot=botlist;bot;bot=bot->next) + { + for(client=bot->clientlist;client;client=client->next) + { + if (0 == (client->flags & (DCC_ACTIVE|DCC_TELNET))) + continue; + if (client == from && client->user->x.x.echo == FALSE) + continue; + to_file(client->sock,format,CurrentNick,rest); + } + } +} + +void partyline_banner(Client *client) +{ + char tmp[MSGLEN]; + + client->flags = DCC_ACTIVE; + client->lasttime = now; + + sprintf(tmp,"[%s] %s[%i] has connected", + current->nick,client->user->name,(int)client->user->x.x.access); + + if ((to_file(client->sock,"[%s] %s\n",time2medium(now),tmp)) < 0) + { + client->flags = DCC_DELETE; + return; + } + send_global(SPYSTR_STATUS,tmp); + if (client->user->x.x.access == OWNERLEVEL) + { + CurrentDCC = client; + stringcpy(tmp,SPYSTR_STATUS); + do_spy(client->user->name,current->nick,tmp,0); + CurrentDCC = NULL; + } +} + +void dcc_chat(char *from) +{ + struct sockaddr_in sai; + Client *client; + User *user; + int sock,sz; + + if ((user = get_authuser(from,NULL)) == NULL) + return; + if (find_client(user->name)) + return; + + if ((sock = SockListener(0)) < 0) + return; + + sz = sizeof(sai); + if (getsockname(sock,(struct sockaddr *)&sai,&sz) < 0) + { + close(sock); + return; + } + + set_mallocdoer(dcc_chat); + client = (Client*)Calloc(sizeof(Client)); +#ifdef DCC_FILE + client->fileno = -1; +#endif /* DCC_FILE */ + client->user = user; + client->sock = sock; + client->flags = DCC_WAIT; + client->lasttime = now; + + client->next = current->clientlist; + current->clientlist = client; + + to_server("PRIVMSG %s :\001DCC CHAT CHAT %u %u\001\n", + CurrentNick,htonl(current->ip.s_addr),ntohs(sai.sin_port)); +} + +#ifdef BOTNET + +void whom_printbot(char *from, BotInfo *binfo, char *stt) +{ + char *us; + int uaccess; + + us = ""; + if (binfo->nuh) + { + uaccess = get_maxaccess(binfo->nuh); + if (uaccess == BOTLEVEL) + us = "b200"; + else + if (uaccess) + sprintf((us = stt),"u%i",uaccess); + } + uaccess = get_authaccess(from,MATCH_ALL); + table_buffer((uaccess >= ASSTLEVEL) ? TEXT_WHOMBOTGUID : TEXT_WHOMBOTLINE,(binfo->nuh) ? nickcpy(NULL,binfo->nuh) : "???",us, + (binfo->server) ? binfo->server : "???",(binfo->version) ? binfo->version : "???",binfo->guid); +} + +#endif /* BOTNET */ + +/* + * + * + * + */ +void do_whom(COMMAND_ARGS) +{ +#ifdef BOTNET + BotNet *bn; + BotInfo *binfo; +#endif /* BOTNET */ + Server *sp; + char stt[NUHLEN]; + Client *client; + Mech *bot; + int m,s; + + if (partyline_only_command(from)) + return; + + for(bot=botlist;bot;bot=bot->next) + { + if (bot->connect == CN_ONLINE) + { + sp = find_server(bot->server); + if (sp) + { + sprintf(stt,"%s:%i",(*sp->realname) ? sp->realname : sp->name,sp->port); + } + else + { + stringcpy(stt,TEXT_NOTINSERVLIST); + } + } + else + { + stringcpy(stt,TEXT_NOTCONNECTED); + } + table_buffer(TEXT_WHOMSELFLINE,bot->nick,(bot == current) ? "(me)" : "b200",stt); + for(client=bot->clientlist;client;client=client->next) + { + m = (now - client->lasttime) / 60; + s = (now - client->lasttime) % 60; + table_buffer(TEXT_WHOMUSERLINE, +#ifdef TELNET + client->user->name,client->user->x.x.access,(client->flags & DCC_TELNET) ? "telnet" : "DCC",m,s); +#else + client->user->name,client->user->x.x.access,"DCC",m,s); +#endif /* TELNET */ + } + } +#ifdef BOTNET + for(bn=botnetlist;bn;bn=bn->next) + { + if (bn->status != BN_LINKED) + continue; + for(binfo=bn->botinfo;binfo;binfo=binfo->next) + whom_printbot(from,binfo,stt); + } +#endif /* BOTNET */ + table_send(from,3); +} + +/* +help:CHAT:(no arguments) +begin +end +*/ +void do_chat(COMMAND_ARGS) +{ + User *user; + + user = get_authuser(from,NULL); + if (!user) + return; + if (find_client(user->name)) + { + to_user(from,"You are already DCC chatting me"); + return; + } + dcc_chat(from); +} + +/* +help:BYE:(no arguments) +begin +end +*/ +void do_bye(COMMAND_ARGS) +{ + if (CurrentDCC) + { + to_user(from,TEXT_DCC_GOODBYE); + CurrentDCC->flags = DCC_DELETE; + } +} + +/* +help:BOOT: +begin +Forcefully disconnect someone from the partyline. +end +*/ +void do_boot(COMMAND_ARGS) +{ +} diff --git a/src/perl.c b/src/perl.c index 28fd192..6977c95 100644 --- a/src/perl.c +++ b/src/perl.c @@ -107,8 +107,8 @@ XS(XS_perl_parse_hook) hook->next = hooklist; hooklist = hook; - hook->type.command = Strcpy(hook->self,sub) + 1; - Strcpy(hook->type.command,name); + hook->type.command = stringcpy(hook->self,sub) + 1; + stringcpy(hook->type.command,name); /* * return successful status to script diff --git a/src/prot.c b/src/prot.c index ff0f2df..7e75bd5 100644 --- a/src/prot.c +++ b/src/prot.c @@ -54,8 +54,8 @@ void send_kick(Chan *chan, const char *nick, const char *format, ...) *pp = new = (qKick*)Calloc(sizeof(qKick) + Strlen2(nick,gsockdata)); // gsockdata is never NULL /* Calloc sets to zero new->next = NULL; */ - new->reason = Strcpy(new->nick,nick) + 1; - Strcpy(new->reason,gsockdata); + new->reason = stringcpy(new->nick,nick) + 1; + stringcpy(new->reason,gsockdata); } void push_kicks(Chan *chan) @@ -148,7 +148,7 @@ void send_mode(Chan *chan, int pri, int type, char plusminus, char modeflag, voi if (data) { set_mallocdoer(send_mode); - mode->data = (void*)Strdup((char*)data); + mode->data = (void*)stringdup((char*)data); } else { @@ -220,7 +220,7 @@ loop: if (srcparm) { *(dstparm++) = ' '; - dstparm = Strcpy(dstparm,srcparm); + dstparm = stringcpy(dstparm,srcparm); } maxmodes--; } @@ -408,6 +408,67 @@ void prot_action(Chan *chan, char *from, ChanUser *doer, char *target, ChanUser } } +#ifdef DYNAMODE + +void check_dynamode(Chan *chan) +{ + ChanUser *cu; + char tempconf[strlen(chan->setting[STR_DYNLIMIT].str_var)+2]; + char ascnum[11]; + char *src,*num,*end; + int n = 0,wind,v[3]; + + /* + * parse `delay:window:minwin' + */ + end = stringcpy(tempconf,chan->setting[STR_DYNLIMIT].str_var); + num = src = tempconf; + for(;(src<=end) && (n<3);src++) + { + if (*src == 0 || *src == ':') + { + *src = 0; + v[n] = asc2int(num); + if (errno) + { + v[0] = 90; /* delay */ + v[1] = 10; /* window */ + v[2] = 4; /* minwin */ + break; + } + num = src+1; + n++; + } + } + v[0] = (v[0] < 20) ? 20 : (v[0] > 600) ? 600 : v[0]; + if ((now - chan->lastlimit) < v[0]) + return; + v[1] = (v[1] < 5) ? 5 : (v[1] > 50) ? 50 : v[1]; + v[2] = (v[2] < 1) ? 1 : (v[2] > 50) ? 50 : v[2]; + + chan->lastlimit = now; + + n = 0; + for(cu=chan->users;cu;cu=cu->next) + n++; + + wind = n / v[1]; + if (wind < v[2]) + wind = v[2]; + + wind += n; + + n = wind - chan->limit; + + if (!chan->limitmode || (n < -2) || (n > 1)) + { + sprintf(ascnum,"%i",wind); + send_mode(chan,160,QM_RAWMODE,'+','l',ascnum); + } +} + +#endif /* DYNAMODE */ + /* * * mode commands @@ -437,8 +498,8 @@ void do_opvoice(COMMAND_ARGS) /* * on_msg checks CAXS + CARGS */ - Chan *chan; - char *m; + const Chan *chan; + const char *m; if ((chan = CurrentChan) && chan->bot_is_op) { @@ -598,7 +659,7 @@ void do_banlist(COMMAND_ARGS) #else /* IRCD_EXTENSIONS */ if (chan->banlist) { - table_buffer(str_underline("channel") "\t\037ban mask\037\t\037set by\037"); + table_buffer(str_underline("channel") "\t" str_underline("ban mask") "\t" str_underline("set by")); for(ban=chan->banlist;ban;ban=ban->next) table_buffer("%s\t%s\t%s",to,ban->banstring,ban->bannedby); table_send(from,2); diff --git a/src/python.c b/src/python.c index bc8afcb..5212bcb 100644 --- a/src/python.c +++ b/src/python.c @@ -334,16 +334,16 @@ PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds) return NULL; } - if (!Strcasecmp(type, "command")) + if (!stringcasecmp(type, "command")) mode = HOOK_COMMAND; else - if (!Strcasecmp(type, "dcc_complete")) + if (!stringcasecmp(type, "dcc_complete")) mode = HOOK_DCC_COMPLETE; else - if (!Strcasecmp(type, "parse")) + if (!stringcasecmp(type, "parse")) mode = HOOK_PARSE; else - if (!Strcasecmp(type, "timer")) + if (!stringcasecmp(type, "timer")) { if (compile_timer(&hooktimer, command) < 0) { @@ -374,13 +374,13 @@ PyObject *python_hook(PyObject *self, PyObject *args, PyObject *keywds) hook->next = hooklist; hooklist = hook; - hook->type.any = (void*) (Strcpy(hook->self, cbname) + 1); + hook->type.any = (void*) (stringcpy(hook->self, cbname) + 1); switch(mode) { case HOOK_COMMAND: case HOOK_PARSE: - Strcpy(hook->type.command, command); + stringcpy(hook->type.command, command); hook->func = python_parse_jump; break; default: @@ -718,8 +718,8 @@ static PyObject *python_dns(PyObject *self, PyObject *args, PyObject *keywds) hook->flags = HOOK_DNS; hook->next = hooklist; hooklist = hook; - hook->type.host = Strcpy(hook->self, cbname) + 1; - Strcpy(hook->type.host, host); + hook->type.host = stringcpy(hook->self, cbname) + 1; + stringcpy(hook->type.host, host); hook->func = python_dns_jump; rawdns(host); @@ -737,7 +737,7 @@ static PyObject *python_execute(PyObject *self, PyObject *args) PyObject *cmd, *from, *to, *rest; char *c_cmd, *c_from, *c_to, *c_rest; int cmdaccess, i; - void (*found)(char*,char*,char*,int) = NULL; + void (*found)(char*, const char*,char*, const int) = NULL; if (!PyArg_ParseTuple(args, "OOOOi", &cmd, &from, &to, &rest, &cmdaccess)) return NULL; @@ -781,7 +781,7 @@ static PyObject *python_execute(PyObject *self, PyObject *args) /* check command exists */ for (i = 0; mcmd[i].name; ++i) { - if (!Strcmp(mcmd[i].name, c_cmd)) + if (!stringcmp(mcmd[i].name, c_cmd)) { found = mcmd[i].func; break; diff --git a/src/redirect.c b/src/redirect.c index 28aa9c5..6670e18 100644 --- a/src/redirect.c +++ b/src/redirect.c @@ -58,7 +58,7 @@ int begin_redirect(char *from, char *args) { if (find_channel_ac(nick)) { - redirect.to = Strdup(nick); + redirect.to = stringdup(nick); redirect.method = R_PRIVMSG; return(0); } @@ -83,13 +83,13 @@ int begin_redirect(char *from, char *args) to_user(from,"Bad filename."); return(-1); } - redirect.to = Strdup(nick); + redirect.to = stringdup(nick); redirect.method = R_FILE; return(0); } if ((pt = find_nuh(nick))) { - redirect.to = Strdup(nick); + redirect.to = stringdup(nick); redirect.method = R_NOTICE; return(0); } @@ -122,7 +122,7 @@ void send_redirect(char *message) case R_FILE: if ((fd = open(redirect.to,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) < 0) return; - fmt = Strcat(message,"\n"); + fmt = stringcat(message,"\n"); write(fd,message,(fmt-message)); close(fd); return; diff --git a/src/reset.c b/src/reset.c index 6006fa2..485b2ac 100644 --- a/src/reset.c +++ b/src/reset.c @@ -98,7 +98,7 @@ char *recover_client(char *env) { for(user=current->userlist;user;user=user->next) { - if (!Strcasecmp(user->name,handle)) + if (!stringcasecmp(user->name,handle)) goto found_user; } break; @@ -133,7 +133,7 @@ found_user: if (user->x.x.access == OWNERLEVEL) { CurrentDCC = client; - Strcpy(client->sockdata,"status"); + stringcpy(client->sockdata,"status"); do_spy(user->name,current->wantnick,client->sockdata,0); *client->sockdata = 0; CurrentDCC = NULL; @@ -371,7 +371,7 @@ void do_reset(COMMAND_ARGS) #endif /* NOTIFY */ *env = 0; - p = Strcat(env,STR_MECHRESET); + p = stringcat(env,STR_MECHRESET); n = 0; #ifdef DEBUG /* diff --git a/src/seen.c b/src/seen.c index d26379d..02d51b8 100644 --- a/src/seen.c +++ b/src/seen.c @@ -81,11 +81,11 @@ int read_seenlist_callback(char *rest) nick = chop(&rest); uh = chop(&rest); - when = a2i(chop(&rest)); /* seen time, a2i handles NULL */ + when = asc2int(chop(&rest)); /* seen time, asc2int handles NULL */ if (errno) return(FALSE); - t = a2i(chop(&rest)); /* seen type, a2i handles NULL */ + t = asc2int(chop(&rest)); /* seen type, asc2int handles NULL */ if (errno) return(FALSE); @@ -197,16 +197,16 @@ step_two: seen->t = t; /* Calloc sets to zero seen->pa = seen->pb = NULL; */ - seen->userhost = Strcpy(seen->nick,nick) + 1; - pt = Strcpy(seen->userhost,userhost) + 1; + seen->userhost = stringcpy(seen->nick,nick) + 1; + pt = stringcpy(seen->userhost,userhost) + 1; if (pa) { seen->pa = pt; - pt = Strcpy(seen->pa,pa) + 1; + pt = stringcpy(seen->pa,pa) + 1; if (pb) { seen->pb = pt; - Strcpy(seen->pb,pb); + stringcpy(seen->pb,pb); } } @@ -222,7 +222,8 @@ void do_seen(COMMAND_ARGS) { Seen *seen; char ago[35]; /* enought for "36500 days, 23 hours and 59 minutes" (100 years) */ - char *chan,*fmt,*n,*u,*c1,*c2,*c3; + const char *chan; + char *fmt,*n,*u,*c1,*c2,*c3; time_t when; int d,h,m,mul; @@ -255,7 +256,7 @@ void do_seen(COMMAND_ARGS) { for(seen=seenlist;seen;seen=seen->next) { - if (!Strcasecmp(n,seen->nick)) + if (!stringcasecmp(n,seen->nick)) break; } diff --git a/src/sha/sha.c b/src/sha/sha.c deleted file mode 100644 index 8f999dd..0000000 --- a/src/sha/sha.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include "sha1.h" - -int main(int argc, char **argv) -{ - SHA1_CTX sha; - uint8_t results[20]; - char *buf; - int n; - - buf = "abc"; - n = strlen(buf); - SHA1Init(&sha); - SHA1Update(&sha, (uint8_t *)buf, n); - SHA1Final(results, &sha); - - /* Print the digest as one long hex value */ -printf("a9993e364706816aba3e25717850c26c9cd0d89d <-- expected result\n"); -for (n = 0; n < 20; n++) - printf("%02x", results[n]); - - putchar('\n'); - - return(0); -} diff --git a/src/sha/sha1.c b/src/sha/sha1.c deleted file mode 100644 index c2bf174..0000000 --- a/src/sha/sha1.c +++ /dev/null @@ -1,296 +0,0 @@ -/* -SHA-1 in C -By Steve Reid -100% Public Domain - -Test Vectors (from FIPS PUB 180-1) -"abc" - A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D -"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" - 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 -A million repetitions of "a" - 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F -*/ - -/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */ -/* #define SHA1HANDSOFF * Copies data before messing with it. */ - -#define SHA1HANDSOFF - -#include -#include - -/* for uint32_t */ -#include - -#include "sha1.h" - - -#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) - -/* blk0() and blk() perform the initial expand. */ -/* I got the idea of expanding during the round function from SSLeay */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ - |(rol(block->l[i],8)&0x00FF00FF)) -#elif BYTE_ORDER == BIG_ENDIAN -#define blk0(i) block->l[i] -#else -#error "Endianness not defined!" -#endif -#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) - -/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ -#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); -#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); -#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); -#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); -#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); - - -/* Hash a single 512-bit block. This is the core of the algorithm. */ - -void SHA1Transform( - uint32_t state[5], - const unsigned char buffer[64] -) -{ - uint32_t a, b, c, d, e; - - typedef union - { - unsigned char c[64]; - uint32_t l[16]; - } CHAR64LONG16; - -#ifdef SHA1HANDSOFF - CHAR64LONG16 block[1]; /* use array to appear as a pointer */ - - memcpy(block, buffer, 64); -#else - /* The following had better never be used because it causes the - * pointer-to-const buffer to be cast into a pointer to non-const. - * And the result is written through. I threw a "const" in, hoping - * this will cause a diagnostic. - */ - CHAR64LONG16 *block = (const CHAR64LONG16 *) buffer; -#endif - /* Copy context->state[] to working vars */ - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(a, b, c, d, e, 0); - R0(e, a, b, c, d, 1); - R0(d, e, a, b, c, 2); - R0(c, d, e, a, b, 3); - R0(b, c, d, e, a, 4); - R0(a, b, c, d, e, 5); - R0(e, a, b, c, d, 6); - R0(d, e, a, b, c, 7); - R0(c, d, e, a, b, 8); - R0(b, c, d, e, a, 9); - R0(a, b, c, d, e, 10); - R0(e, a, b, c, d, 11); - R0(d, e, a, b, c, 12); - R0(c, d, e, a, b, 13); - R0(b, c, d, e, a, 14); - R0(a, b, c, d, e, 15); - R1(e, a, b, c, d, 16); - R1(d, e, a, b, c, 17); - R1(c, d, e, a, b, 18); - R1(b, c, d, e, a, 19); - R2(a, b, c, d, e, 20); - R2(e, a, b, c, d, 21); - R2(d, e, a, b, c, 22); - R2(c, d, e, a, b, 23); - R2(b, c, d, e, a, 24); - R2(a, b, c, d, e, 25); - R2(e, a, b, c, d, 26); - R2(d, e, a, b, c, 27); - R2(c, d, e, a, b, 28); - R2(b, c, d, e, a, 29); - R2(a, b, c, d, e, 30); - R2(e, a, b, c, d, 31); - R2(d, e, a, b, c, 32); - R2(c, d, e, a, b, 33); - R2(b, c, d, e, a, 34); - R2(a, b, c, d, e, 35); - R2(e, a, b, c, d, 36); - R2(d, e, a, b, c, 37); - R2(c, d, e, a, b, 38); - R2(b, c, d, e, a, 39); - R3(a, b, c, d, e, 40); - R3(e, a, b, c, d, 41); - R3(d, e, a, b, c, 42); - R3(c, d, e, a, b, 43); - R3(b, c, d, e, a, 44); - R3(a, b, c, d, e, 45); - R3(e, a, b, c, d, 46); - R3(d, e, a, b, c, 47); - R3(c, d, e, a, b, 48); - R3(b, c, d, e, a, 49); - R3(a, b, c, d, e, 50); - R3(e, a, b, c, d, 51); - R3(d, e, a, b, c, 52); - R3(c, d, e, a, b, 53); - R3(b, c, d, e, a, 54); - R3(a, b, c, d, e, 55); - R3(e, a, b, c, d, 56); - R3(d, e, a, b, c, 57); - R3(c, d, e, a, b, 58); - R3(b, c, d, e, a, 59); - R4(a, b, c, d, e, 60); - R4(e, a, b, c, d, 61); - R4(d, e, a, b, c, 62); - R4(c, d, e, a, b, 63); - R4(b, c, d, e, a, 64); - R4(a, b, c, d, e, 65); - R4(e, a, b, c, d, 66); - R4(d, e, a, b, c, 67); - R4(c, d, e, a, b, 68); - R4(b, c, d, e, a, 69); - R4(a, b, c, d, e, 70); - R4(e, a, b, c, d, 71); - R4(d, e, a, b, c, 72); - R4(c, d, e, a, b, 73); - R4(b, c, d, e, a, 74); - R4(a, b, c, d, e, 75); - R4(e, a, b, c, d, 76); - R4(d, e, a, b, c, 77); - R4(c, d, e, a, b, 78); - R4(b, c, d, e, a, 79); - /* Add the working vars back into context.state[] */ - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - /* Wipe variables */ - a = b = c = d = e = 0; -#ifdef SHA1HANDSOFF - memset(block, '\0', sizeof(block)); -#endif -} - - -/* SHA1Init - Initialize new context */ - -void SHA1Init( - SHA1_CTX * context -) -{ - /* SHA1 initialization constants */ - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; - context->count[0] = context->count[1] = 0; -} - - -/* Run your data through this. */ - -void SHA1Update( - SHA1_CTX * context, - const unsigned char *data, - uint32_t len -) -{ - uint32_t i; - - uint32_t j; - - j = context->count[0]; - if ((context->count[0] += len << 3) < j) - context->count[1]++; - context->count[1] += (len >> 29); - j = (j >> 3) & 63; - if ((j + len) > 63) - { - memcpy(&context->buffer[j], data, (i = 64 - j)); - SHA1Transform(context->state, context->buffer); - for (; i + 63 < len; i += 64) - { - SHA1Transform(context->state, &data[i]); - } - j = 0; - } - else - i = 0; - memcpy(&context->buffer[j], &data[i], len - i); -} - - -/* Add padding and return the message digest. */ - -void SHA1Final( - unsigned char digest[20], - SHA1_CTX * context -) -{ - unsigned i; - - unsigned char finalcount[8]; - - unsigned char c; - -#if 0 /* untested "improvement" by DHR */ - /* Convert context->count to a sequence of bytes - * in finalcount. Second element first, but - * big-endian order within element. - * But we do it all backwards. - */ - unsigned char *fcp = &finalcount[8]; - - for (i = 0; i < 2; i++) - { - uint32_t t = context->count[i]; - - int j; - - for (j = 0; j < 4; t >>= 8, j++) - *--fcp = (unsigned char) t} -#else - for (i = 0; i < 8; i++) - { - finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */ - } -#endif - c = 0200; - SHA1Update(context, &c, 1); - while ((context->count[0] & 504) != 448) - { - c = 0000; - SHA1Update(context, &c, 1); - } - SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ - for (i = 0; i < 20; i++) - { - digest[i] = (unsigned char) - ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); - } - /* Wipe variables */ - memset(context, '\0', sizeof(*context)); - memset(&finalcount, '\0', sizeof(finalcount)); -} - -void SHA1( - char *hash_out, - const char *str, - int len) -{ - SHA1_CTX ctx; - unsigned int ii; - - SHA1Init(&ctx); - for (ii=0; ii - 100% Public Domain - */ - -#include "stdint.h" - -typedef struct -{ - uint32_t state[5]; - uint32_t count[2]; - unsigned char buffer[64]; -} SHA1_CTX; - -void SHA1Transform( - uint32_t state[5], - const unsigned char buffer[64] - ); - -void SHA1Init( - SHA1_CTX * context - ); - -void SHA1Update( - SHA1_CTX * context, - const unsigned char *data, - uint32_t len - ); - -void SHA1Final( - unsigned char digest[20], - SHA1_CTX * context - ); - -void SHA1( - char *hash_out, - const char *str, - int len); - -#endif /* SHA1_H */ diff --git a/src/shit.c b/src/shit.c index 3a30499..dae02ce 100644 --- a/src/shit.c +++ b/src/shit.c @@ -98,7 +98,7 @@ void remove_shit(Shit *shit) Shit **pp; #ifdef DEBUG - debug("(remove_shit) removing shit %s on channel %s (Level 4)\n",shit->mask,shit->chan,shit->action); + debug("(remove_shit) removing shit %s on channel %s (Level %i)\n",shit->mask,shit->chan,shit->action); #endif /* DEBUG */ pp = ¤t->shitlist; while(*pp) @@ -145,10 +145,10 @@ Shit *add_shit(char *from, char *chan, char *mask, char *reason, int axs, int ex shit->next = current->shitlist; current->shitlist = shit; - shit->chan = Strcpy(shit->mask,mask) + 1; - shit->from = Strcpy(shit->chan,chan) + 1; - shit->reason = Strcpy(shit->from,from) + 1; - Strcpy(shit->reason,reason); + shit->chan = stringcpy(shit->mask,mask) + 1; + shit->from = stringcpy(shit->chan,chan) + 1; + shit->reason = stringcpy(shit->from,from) + 1; + stringcpy(shit->reason,reason); current->ul_save++; return(shit); @@ -165,7 +165,7 @@ Shit *find_shit(const char *userhost, const char *channel) best = 0; for(shit=current->shitlist;shit;shit=shit->next) { - if (!channel || !Strcasecmp(channel,shit->chan) || + if (!channel || !stringcasecmp(channel,shit->chan) || (*shit->chan == '*') || (*channel == '*')) { num = num_matches(shit->mask,userhost); @@ -240,7 +240,7 @@ void do_shit(COMMAND_ARGS) * on_msg checks CARGS */ char *channel,*nick,*nuh; - int shitlevel,days,uaccess,shitaccess; + int shitlevel,days,uaccess,shitaccess; if (CurrentCmd->name == C_QSHIT) { @@ -272,7 +272,7 @@ void do_shit(COMMAND_ARGS) } else { - shitlevel = a2i(chop(&rest)); + shitlevel = asc2int(chop(&rest)); if (errno) goto usage; @@ -288,7 +288,7 @@ void do_shit(COMMAND_ARGS) days = 86400 * 30; if (*rest >= '1' && *rest <= '9') { - days = 86400 * a2i(chop(&rest)); + days = 86400 * asc2int(chop(&rest)); if (errno) goto usage; } diff --git a/src/socket.c b/src/socket.c index bf5c600..9d73b51 100644 --- a/src/socket.c +++ b/src/socket.c @@ -353,7 +353,7 @@ void to_user_q(const char *target, const char *format, ...) vsprintf(message,format,args); va_end(args); - Strcat(message,"\n"); + stringcat(message,"\n"); fmt = "NOTICE %s :%s"; if (CurrentChan) @@ -434,12 +434,12 @@ void to_user(const char *target, const char *format, ...) #endif /* DEBUG */ return; } - s = Strcpy(message,"NOTICE "); + s = stringcpy(message,"NOTICE "); if (ischannel(target)) - Strcat(message,target); + stringcat(message,target); else nickcpy(s,target); - s = Strcat(message," :"); + s = stringcat(message," :"); } va_start(args,format); @@ -457,7 +457,7 @@ void to_user(const char *target, const char *format, ...) /* * tag on a newline for DCC or server */ - s = Strcat(message,"\n"); + s = stringcat(message,"\n"); #ifdef DEBUG *s = 0; diff --git a/src/spy.c b/src/spy.c index 6978af5..7d5b350 100644 --- a/src/spy.c +++ b/src/spy.c @@ -65,7 +65,7 @@ void send_spy(const char *src, const char *format, ...) { if ((*src == '#' || *src == '*') && spy->t_src == SPY_CHANNEL) { - if ((*src != '*') && Strcasecmp(spy->src,src)) + if ((*src != '*') && stringcasecmp(spy->src,src)) continue; if ((chan = find_channel_ac(spy->src)) == NULL) continue; @@ -187,7 +187,7 @@ int spy_source(char *from, int *t_src, const char **src) for(i=0;spy_source_list[i].idstring;i++) { - if (!Strcasecmp(*src,spy_source_list[i].idstring)) + if (!stringcasecmp(*src,spy_source_list[i].idstring)) { *src = spy_source_list[i].idstring; *t_src = spy_source_list[i].typenum; @@ -251,7 +251,7 @@ void do_spy(COMMAND_ARGS) return; } - if (dcc_only_command(from)) + if (partyline_only_command(from)) return; table_buffer("\037source\037\t\037target\037"); for(spy=current->spylist;spy;spy=spy->next) @@ -393,7 +393,7 @@ spy_dest_ok: for(spy=current->spylist;spy;spy=spy->next) { if ((spy->t_src == t_src) && (spy->t_dest == t_dest) && - !Strcasecmp(spy->src,src) && !Strcasecmp(spy->dest,dest)) + !stringcasecmp(spy->src,src) && !stringcasecmp(spy->dest,dest)) { to_user(from,"Requested spy channel is already active"); return; @@ -415,7 +415,7 @@ spy_dest_ok: if (t_dest != SPY_DCC) { spy->dest = spy->p; - spy->src = Strcat(spy->p,dest) + 1; + spy->src = stringcat(spy->p,dest) + 1; } else { @@ -426,7 +426,7 @@ spy_dest_ok: if (t_src == SPY_CHANNEL) { - Strcpy((char*)spy->src,src); + stringcpy((char*)spy->src,src); } else { @@ -537,12 +537,12 @@ rspy_dest_ok: */ for(spy=current->spylist;spy;spy=spy->next) { - if ((spy->t_src == t_src) && (spy->t_dest == t_dest) && (!Strcasecmp(spy->src,src))) + if ((spy->t_src == t_src) && (spy->t_dest == t_dest) && (!stringcasecmp(spy->src,src))) { if ((t_dest == SPY_DCC) && (!nickcmp(spy->dest,dest))) break; else - if (!Strcasecmp(spy->dest,dest)) + if (!stringcasecmp(spy->dest,dest)) break; } } diff --git a/src/stats.c b/src/stats.c index a08e000..db13635 100644 --- a/src/stats.c +++ b/src/stats.c @@ -111,13 +111,13 @@ void do_info(COMMAND_ARGS) for(chan=current->chanlist;chan;chan=chan->next) { *(p = text) = 0; - p = Strcat(p,chan->name); + p = stringcat(p,chan->name); if (chan == current->activechan) - p = Strcat(p," (current)"); + p = stringcat(p," (current)"); if ((stats = chan->stats)) { if (stats && stats->flags == CSTAT_PARTIAL) - p = Strcat(p," (partial)"); + p = stringcat(p," (partial)"); while(p < text+35) *(p++) = ' '; if (stats->LHuserseconds > 0) @@ -135,7 +135,7 @@ void do_info(COMMAND_ARGS) } else { - Strcpy(p," (no current data)"); + stringcpy(p," (no current data)"); } to_user(from,FMT_PLAIN,text); } diff --git a/src/structs.h b/src/structs.h index 844cadf..32a0afc 100644 --- a/src/structs.h +++ b/src/structs.h @@ -49,7 +49,7 @@ typedef union usercombo typedef struct OnMsg { const char *name; - void (*func)(char *, char *, char *, int); + void (*func)(char *, const char *, char *, const int); ulong defaultaccess:8, /* defaultaccess */ dcc:1, cc:1, @@ -64,7 +64,7 @@ typedef struct OnMsg cbang:1, acchan:1, supres:1; // -- 21 bits - char *cmdarg; + const char *cmdarg; } OnMsg; @@ -419,7 +419,7 @@ typedef struct ChanStats typedef struct ShortChan { struct ShortChan *next; - char *name; + const char *name; } ShortChan; diff --git a/src/tcl.c b/src/tcl.c index 965df85..310f080 100644 --- a/src/tcl.c +++ b/src/tcl.c @@ -233,16 +233,16 @@ int tcl_hook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]) if (!mode || !sz1 || !sz2) return(TCL_ERROR); - if (!Strcasecmp(type,"command")) + if (!stringcasecmp(type,"command")) mode = HOOK_COMMAND; else - if (!Strcasecmp(type,"dcc_complete")) + if (!stringcasecmp(type,"dcc_complete")) mode = HOOK_DCC_COMPLETE; else - if (!Strcasecmp(type,"parse")) + if (!stringcasecmp(type,"parse")) mode = HOOK_PARSE; else - if (!Strcasecmp(type,"timer")) + if (!stringcasecmp(type,"timer")) { if (compile_timer(&hooktimer,command) < 0) return(TCL_ERROR); @@ -261,13 +261,13 @@ int tcl_hook(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]) hook->next = hooklist; hooklist = hook; - hook->type.any = (void*)(Strcpy(hook->self,self) + 1); + hook->type.any = (void*)(stringcpy(hook->self,self) + 1); switch(mode) { case HOOK_COMMAND: case HOOK_PARSE: - Strcpy(hook->type.command,command); + stringcpy(hook->type.command,command); hook->func = tcl_parse_jump; break; default: @@ -384,7 +384,7 @@ int tcl_to_server(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]) { *pp = sp = (Strp*)Calloc(sizeof(Strp) + sz); /* Calloc sets to zero sp->next = NULL; */ - Strcpy(sp->p,line); + stringcpy(sp->p,line); } } else @@ -502,8 +502,8 @@ int tcl_dns(void *foo, Tcl_Interp *I, int objc, Tcl_Obj *CONST objv[]) hook->flags = HOOK_DNS; hook->next = hooklist; hooklist = hook; - hook->type.host = Strcpy(hook->self,callback) + 1; - Strcpy(hook->type.host,host); + hook->type.host = stringcpy(hook->self,callback) + 1; + stringcpy(hook->type.host,host); hook->func = tcl_dns_jump; rawdns(host); diff --git a/src/toybox.c b/src/toybox.c index 520fdf0..d5ba19a 100644 --- a/src/toybox.c +++ b/src/toybox.c @@ -58,7 +58,7 @@ int read_bigcharset_callback(char *rest) opt = chop(&rest); n = NULL; - if (!Strcasecmp(opt,"chars") && charheight) + if (!stringcasecmp(opt,"chars") && charheight) { charlines = charheight; @@ -71,28 +71,28 @@ int read_bigcharset_callback(char *rest) */ newchar->next = fontlist; fontlist = newchar; - Strcpy(newchar->chars,opt); + stringcpy(newchar->chars,opt); } else - if (!Strcasecmp(opt,"spacewidth")) + if (!stringcasecmp(opt,"spacewidth")) { n = &spacewidth; } else - if (!Strcasecmp(opt,"charheight")) + if (!stringcasecmp(opt,"charheight")) { n = &charheight; } else - if (!Strcasecmp(opt,"kerning")) + if (!stringcasecmp(opt,"kerning")) { n = &kerning; } else - if (!Strcasecmp(opt,"fontname")) + if (!stringcasecmp(opt,"fontname")) { opt = chop(&rest); - if (fontname && !Strcasecmp(fontname,opt)) + if (fontname && !stringcasecmp(fontname,opt)) { fontlist = orig_fontlist; charlines = orig_charlines; @@ -104,12 +104,12 @@ int read_bigcharset_callback(char *rest) } Free((char**)&fontname); set_mallocdoer(read_bigcharset_callback); - fontname = Strdup(opt); + fontname = stringdup(opt); } if (n) { - *n = a2i(rest); + *n = asc2int(rest); if (errno) *n = 0; } @@ -124,7 +124,7 @@ int read_bigcharset(char *fname) if ((fd = open(fname,O_RDONLY)) < 0) { - Strcat(fname,FONT_EXTENSION); + stringcat(fname,FONT_EXTENSION); if ((fd = open(fname,O_RDONLY)) < 0) return(-1); } @@ -178,7 +178,7 @@ void do_bigsay(COMMAND_ARGS) debug("(do_bigsay) rest = \"%s\"\n",rest); #endif /* DEBUG */ - Strcpy(output,BIGSAY_DEFAULTFONT); + stringcpy(output,BIGSAY_DEFAULTFONT); if (read_bigcharset(output) < 0) { @@ -214,7 +214,6 @@ void do_bigsay(COMMAND_ARGS) temp2 = tail; while(*temp && tail < OEND) *(tail++) = *(temp++); - //temp = Strcat(tail,sp->p); while(tail < (temp2 + bigc->width) && tail < OEND) *(tail++) = ' '; if (pt[1]) @@ -248,7 +247,8 @@ void do_bigsay(COMMAND_ARGS) void do_random_msg(COMMAND_ARGS) { - char *filename,*message; + const char *filename; + const char *message; filename = CurrentCmd->cmdarg; @@ -342,7 +342,7 @@ ascii_badfile: to_user_q(from,"%s","Bad filename or file does not exist"); return; } - Strcat(Strcpy(fname,"ascii/"),rest); + stringcat(stringcpy(fname,"ascii/"),rest); debug("(do_ascii) file = \"%s\"\n",fname); if (is_safepath(fname,FILE_MUST_EXIST) != FILE_IS_SAFE) { @@ -361,7 +361,7 @@ ascii_badfile: to_user_q(from,"%s","Bad filename or file does not exist"); return; } - Strcat(Strcpy(fname,"ascii/"),rest); + stringcat(stringcpy2(fname,"ascii/"),rest); if (is_safepath(fname,FILE_MUST_EXIST) != FILE_IS_SAFE) goto ascii_badfile; if ((fd = open(fname,O_RDONLY)) < 0) diff --git a/src/trivia.c b/src/trivia.c index 6eff7b3..477f814 100644 --- a/src/trivia.c +++ b/src/trivia.c @@ -144,7 +144,7 @@ void hint_two(void) dst = STREND(triv_str); src = triv_answers->p; - n = a2i(src); + n = asc2int(src); if (!errno) { if (n > 99 && *src) *(dst++) = *(src++); @@ -181,7 +181,7 @@ void hint_three(void) dst = STREND(triv_str); src = triv_answers->p; - n = a2i(src); + n = asc2int(src); if (!errno) { if (n > 9 && *src) *(dst++) = *(src++); @@ -238,7 +238,7 @@ void trivia_check(Chan *chan, char *rest) for(ans=triv_answers;ans;ans=ans->next) { - if (!Strcasecmp(ans->p,rest)) + if (!stringcasecmp(ans->p,rest)) goto have_answer; } return; @@ -275,7 +275,7 @@ have_answer: su->score_wk = su->score_mo = triv_score; su->week_nr = week; /* su->month_nr = 0; * fix this */ - Strcpy(su->nick,CurrentNick); + stringcpy(su->nick,CurrentNick); } to_server("PRIVMSG %s :Yes, %s! got the answer -> %s <- in %i seconds, and gets %i points!\n", @@ -339,7 +339,7 @@ char *random_question(char *triv_rand) if (STRCHR(triv_qfile,'/') || strlen(triv_qfile) > 100) // really bad filenames... return(NULL); - Strcat(Strcpy(tmpname,"trivia/"),triv_qfile); + stringcat(stringcpy(tmpname,"trivia/"),triv_qfile); if ((fd = open(tmpname,O_RDONLY)) < 0) #ifdef DEBUG @@ -351,10 +351,10 @@ char *random_question(char *triv_rand) return(NULL); #endif /* DEBUG */ - Strcpy(triv_rand,tmpname); + stringcpy(triv_rand,tmpname); if ((p = STRCHR(triv_rand,'.')) == NULL) p = STREND(triv_rand); - Strcpy(p,".index"); + stringcpy(p,".index"); if ((ifd = open(triv_rand,O_RDONLY)) < 0) return(NULL); @@ -508,17 +508,17 @@ int trivia_score_callback(char *rest) if (mnr) { - score_wk = a2i(wk); + score_wk = asc2int(wk); err = errno; - score_mo = a2i(mo); + score_mo = asc2int(mo); err += errno; - score_last_wk = a2i(lwk); + score_last_wk = asc2int(lwk); err += errno; - score_last_mo = a2i(lmo); + score_last_mo = asc2int(lmo); err += errno; - week_nr = a2i(wnr); + week_nr = asc2int(wnr); err += errno; - month_nr = a2i(mnr); + month_nr = asc2int(mnr); err += errno; if (!err) @@ -533,7 +533,7 @@ int trivia_score_callback(char *rest) su->score_last_mo = score_last_mo; su->week_nr = week_nr; su->month_nr = month_nr; - Strcpy(su->nick,nick); + stringcpy(su->nick,nick); } } } @@ -580,7 +580,7 @@ void do_trivia(COMMAND_ARGS) return; } - if (!Strcasecmp(rest,"start")) + if (!stringcasecmp(rest,"start")) { if (triv_chan) { @@ -606,7 +606,7 @@ void do_trivia(COMMAND_ARGS) } } else - if (!Strcasecmp(rest,"stop")) + if (!stringcasecmp(rest,"stop")) { if (chan == triv_chan) { @@ -616,7 +616,7 @@ void do_trivia(COMMAND_ARGS) } } else - if (!Strcasecmp(rest,"top10")) + if (!stringcasecmp(rest,"top10")) { int n; diff --git a/src/uptime.c b/src/uptime.c index f584146..76ce7e9 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -69,7 +69,7 @@ void init_uptime(void) if (!uptimehost) { set_mallocdoer(init_uptime); - uptimehost = Strdup(defaultuptimehost); + uptimehost = stringdup(defaultuptimehost); } if ((uptimesock = socket(AF_INET,SOCK_DGRAM,0)) < 0) @@ -116,7 +116,7 @@ void send_uptime(int type) { Free((char**)&uptimehost); set_mallocdoer(send_uptime); - uptimehost = Strdup(host); + uptimehost = stringdup(host); } } else @@ -160,7 +160,7 @@ void send_uptime(int type) upPack.sysup = htonl(st.st_ctime); } - server = "unknown"; + server = UNKNOWN; nick = BOTLOGIN; /* diff --git a/src/urlcap.c b/src/urlcap.c index 52dd766..3c69969 100644 --- a/src/urlcap.c +++ b/src/urlcap.c @@ -29,6 +29,35 @@ #include "h.h" #include "text.h" +char *urlhost(const char *url) +{ + char copy[strlen(url)]; + const char *end,*beg,*dst; + int n = 0; + + beg = end = url; + while(*end) + { + if (*end == '@') + beg = end+1; + else + if (*end == '/') + { + if (n == 1) + beg = end+1; + else + if (n == 2) + break; + n++; + } + end++; + } + stringcpy_n(copy,beg,(end-beg)); +#ifdef DEBUG + debug("(urlhost) host = %s\n",copy); +#endif +} + void urlcapture(const char *rest) { Strp *sp,*nx; @@ -43,6 +72,7 @@ void urlcapture(const char *rest) #ifdef DEBUG debug("(urlcapture) URL = \"%s\"\n",url); #endif /* ifdef DEBUG */ + urlhost(url); send_spy(SPYSTR_URL,"%s",url); @@ -92,7 +122,7 @@ void do_urlhist(COMMAND_ARGS) else { thenum = chop(&rest); - maxnum = a2i(thenum); + maxnum = asc2int(thenum); } if ((maxnum < 1) || (maxnum > urlhistmax)) usage(from); /* usage for CurrentCmd->name */ diff --git a/src/user.c b/src/user.c index 518e6d3..944a248 100644 --- a/src/user.c +++ b/src/user.c @@ -43,7 +43,7 @@ void cfg_user(char *rest) { set_mallocdoer(cfg_user); cfgUser = Calloc(sizeof(User) + strlen(rest)); - Strcpy(cfgUser->name,rest); + stringcpy(cfgUser->name,rest); } #ifdef BOTNET @@ -52,7 +52,7 @@ void cfg_modcount(char *rest) { int i; - i = a2i(rest); + i = asc2int(rest); if (errno || i < 1) return; cfgUser->modcount = i; @@ -64,7 +64,7 @@ void cfg_pass(char *rest) { Free((char**)&cfgUser->pass); set_mallocdoer(cfg_pass); - cfgUser->pass = Strdup(rest); + cfgUser->pass = stringdup(rest); } void cfg_mask(char *rest) @@ -118,7 +118,7 @@ void cfg_opt(char *rest) cfgUser->x.x.prot = rest[1] - '0'; if (*rest == 'u') { - cfgUser->x.x.access = a2i(rest+1); + cfgUser->x.x.access = asc2int(rest+1); return; } rest++; @@ -147,14 +147,14 @@ void cfg_shit(char *rest) /* * convert the expiry time */ - expire = a2i(chop(&rest)); /* a2i() can handle NULLs */ + expire = asc2int(chop(&rest)); /* asc2int() can handle NULLs */ if (errno || expire < now) return; /* * convert time when the shit was added */ - when = a2i(chop(&rest)); + when = asc2int(chop(&rest)); if (errno || *rest == 0) /* if *rest == 0, the reason is missing */ return; @@ -183,7 +183,7 @@ void cfg_greet(char *rest) { Free((char**)&cfgUser->greet); set_mallocdoer(cfg_greet); - cfgUser->greet = Strdup(rest); + cfgUser->greet = stringdup(rest); } #endif /* GREET */ @@ -199,7 +199,7 @@ void cfg_note(char *rest) np = &(*np)->next; *np = sp = Calloc(sizeof(Strp) + strlen(rest)); /* Calloc sets to zero sp->next = NULL; */ - Strcpy(sp->p,rest); + stringcpy(sp->p,rest); } #endif /* NOTE */ @@ -264,7 +264,7 @@ int read_userlist_callback(char *line) command = chop(&line); for(i=0;userlist_cmds[i].name;i++) { - if (!Strcasecmp(command,userlist_cmds[i].name)) + if (!stringcasecmp(command,userlist_cmds[i].name)) break; } if (userlist_cmds[i].name) @@ -526,14 +526,14 @@ void addtouser(Strp **pp, const char *string, int rehash) while(*pp) { um = *pp; - if (!Strcasecmp(um->p,string)) + if (!stringcasecmp(um->p,string)) return; pp = &um->next; } set_mallocdoer(addtouser); *pp = um = (Strp*)Calloc(sizeof(Strp) + strlen(string)); - Strcpy(um->p,string); + stringcpy(um->p,string); if (rehash) rehash_chanusers(); } @@ -545,7 +545,7 @@ int remfromuser(Strp **pp, const char *string) while(*pp) { um = *pp; - if (!Strcasecmp(um->p,string)) + if (!stringcasecmp(um->p,string)) { *pp = um->next; Free((char**)&um); @@ -578,7 +578,7 @@ void mirror_user(User *user) continue; for(olduser=anybot->userlist;olduser;olduser=olduser->next) { - if (!Strcasecmp(user->name,olduser->name)) + if (!stringcasecmp(user->name,olduser->name)) { #ifdef BOTNET /* dont overwrite "better" users */ @@ -780,11 +780,11 @@ User *add_user(char *handle, char *pass, int axs) /* * "name\0pass\0" */ - p = Strcpy(user->name,handle) + 1; + p = stringcpy(user->name,handle) + 1; if (pass) { user->pass = p; - Strcpy(user->pass,pass); + stringcpy(user->pass,pass); } current->ul_save++; return(user); @@ -799,7 +799,7 @@ User *find_handle(const char *handle) for(user=current->userlist;user;user=user->next) { - if (!Strcasecmp(handle,user->name)) + if (!stringcasecmp(handle,user->name)) return(user); } return(NULL); @@ -813,7 +813,7 @@ int userhaschannel(const User *user, const char *channel) return(TRUE); for(ump=user->chan;ump;ump=ump->next) { - if (*ump->p == '*' || !Strcasecmp(ump->p,channel)) + if (*ump->p == '*' || !stringcasecmp(ump->p,channel)) return(TRUE); } return(FALSE); @@ -963,7 +963,7 @@ int usercanmodify(const char *from, const User *user) return(TRUE); for(ump=user->chan;ump;ump=ump->next) { - if (!Strcasecmp(ump->p,fmp->p)) + if (!stringcasecmp(ump->p,fmp->p)) { if (u->x.x.access >= ua) return(TRUE); @@ -982,7 +982,8 @@ int usercanmodify(const char *from, const User *user) void do_access(COMMAND_ARGS) { - char *chan,*nuh; + const char *chan; + char *nuh; int level; chan = get_channel(to,&rest); @@ -1053,12 +1054,12 @@ void do_userlist(COMMAND_ARGS) { if (*rest == '+' && rest[1] >= '0' && rest[1] <= '9') { - minlevel = a2i(rest+1); + minlevel = asc2int(rest+1); } else if (*rest == '-' && rest[1] >= '0' && rest[1] <= '9') { - maxlevel = a2i(rest+1); + maxlevel = asc2int(rest+1); } else if (*rest == '-' && (*rest|32) == 'b') @@ -1150,7 +1151,7 @@ void do_userlist(COMMAND_ARGS) if (user->greet) { table_buffer("Greet\t: %s%s",user->greet, - (user->x.x.greetfile) ? " (greetfile)" : + (user->x.x.greetfile) ? " (greetfile)" : ((user->x.x.randline) ? " (random line from file)" : "")); } #endif /* GREET */ @@ -1165,7 +1166,7 @@ void do_userlist(COMMAND_ARGS) else sz += strlen(ump->p); } - table_buffer(from,"Message\t: %i message%s (%i bytes)",n,(n == 1) ? "" : "s",sz); + table_buffer("Message\t: %i message%s (%i bytes)",n,(n == 1) ? "" : "s",sz); } #endif /* NOTE */ table_buffer(" "); @@ -1237,7 +1238,7 @@ void do_user(COMMAND_ARGS) anum = chop(&rest); pass = chop(&rest); - newaccess = a2i(anum); + newaccess = asc2int(anum); if (errno) goto usage; @@ -1267,7 +1268,7 @@ void do_user(COMMAND_ARGS) */ if ((mask = nick2uh(from,nick)) == NULL) // nick2uh uses nuh_buf return; - Strcpy(tmpmask,mask); + stringcpy(tmpmask,mask); #ifdef DEBUG debug("(do_user) nick2uh(from \"%s\", nick \"%s\") = mask \"%s\"\n",from,nick,tmpmask); #endif /* DEBUG */ @@ -1381,28 +1382,28 @@ void do_user(COMMAND_ARGS) } #ifdef BOTNET - if (!Strcasecmp(pt,"NS")) + if (!stringcasecmp(pt,"NS")) combo.x.noshare = mode; else - if (!Strcasecmp(pt,"RO")) + if (!stringcasecmp(pt,"RO")) combo.x.readonly = mode; else #endif /* BOTNET */ #ifdef BOUNCE - if (!Strcasecmp(pt,"BNC")) + if (!stringcasecmp(pt,"BNC")) combo.x.bounce = mode; else #endif /* BOUNCE */ - if (!Strcasecmp(pt,"AV")) + if (!stringcasecmp(pt,"AV")) combo.x.avoice = mode; else - if (!Strcasecmp(pt,"AO")) + if (!stringcasecmp(pt,"AO")) combo.x.aop = mode; else - if (!Strcasecmp(pt,"ECHO")) + if (!stringcasecmp(pt,"ECHO")) combo.x.echo = mode; else - if (!Strcasecmp(pt,"CHAN")) + if (!stringcasecmp(pt,"CHAN")) { ch = (mode) ? _ADD : _SUB; mask = chop(&rest); @@ -1410,7 +1411,7 @@ void do_user(COMMAND_ARGS) goto usage; } else - if (!Strcasecmp(pt,"HOST")) + if (!stringcasecmp(pt,"HOST")) { ho = (mode) ? _ADD : _SUB; mask = chop(&rest); @@ -1434,7 +1435,7 @@ void do_user(COMMAND_ARGS) goto usage; } else - if ((uaccess = a2i(pt)) >= 0 && uaccess <= BOTLEVEL && errno == 0) + if ((uaccess = asc2int(pt)) >= 0 && uaccess <= BOTLEVEL && errno == 0) { combo.x.access = uaccess; } @@ -1463,7 +1464,7 @@ usage: { for(ump=user->chan;ump;ump=ump->next) { - if (!Strcasecmp(ump->p,mask)) + if (!stringcasecmp(ump->p,mask)) { to_user(from,"Channel %s already exists for %s",mask,user->name); return; @@ -1489,7 +1490,7 @@ usage: { for(ump=user->mask;ump;ump=ump->next) { - if (!Strcasecmp(ump->p,mask)) + if (!stringcasecmp(ump->p,mask)) { to_user(from,"Mask %s already exists for %s",mask,user->name); return; @@ -1544,7 +1545,7 @@ void do_echo(COMMAND_ARGS) if ((tmp = chop(&rest))) { - if (!Strcasecmp(tmp,"on")) + if (!stringcasecmp(tmp,__STR_ON)) { if (CurrentUser->x.x.echo == FALSE) { @@ -1555,7 +1556,7 @@ void do_echo(COMMAND_ARGS) to_user(from,TEXT_PARTYECHOON); return; } - if (!Strcasecmp(tmp,"off")) + if (!stringcasecmp(tmp,__STR_OFF)) { if (CurrentUser->x.x.echo == TRUE) { @@ -1579,7 +1580,7 @@ void change_pass(User *user, char *pass) enc = makepass(pass); if (strlen(user->pass) <= strlen(enc)) { - Strcpy(user->pass,enc); + stringcpy(user->pass,enc); user->modcount++; } /* @@ -1688,7 +1689,7 @@ void do_setpass(COMMAND_ARGS) to_user(from,TEXT_USEROWNSYOU,user->name); return; } - if (!Strcasecmp(pass,"none")) + if (!stringcasecmp(pass,"none")) { user->pass = NULL; to_user(from,"password for %s has been removed",user->name); diff --git a/src/vars.c b/src/vars.c index c23bdc8..acfddd5 100644 --- a/src/vars.c +++ b/src/vars.c @@ -36,7 +36,7 @@ void set_str_varc(Chan *channel, int which, char *value) if (value && *value) { set_mallocdoer(set_str_varc); - temp = Strdup(value); + temp = stringdup(value); } else temp = NULL; @@ -49,13 +49,13 @@ void set_str_varc(Chan *channel, int which, char *value) /* * The rest */ -int find_setting(char *name) +int find_setting(const char *name) { int i; for(i=0;VarName[i].name;i++) { - if (!Strcasecmp(name,VarName[i].name)) + if (!stringcasecmp(name,VarName[i].name)) return(i); } return(-1); @@ -72,7 +72,7 @@ void copy_vars(UniVar *dst, UniVar *src) if (src[i].str_var) { set_mallocdoer(copy_vars); - dst[i].str_var = Strdup(src[i].str_var); + dst[i].str_var = stringdup(src[i].str_var); } } else @@ -125,7 +125,7 @@ void nobo_strcpy(const char *src) *ec_dest = 0; } -void ec_access(char *from, char *to) +void ec_access(char *from, const char *to) { char num[20]; @@ -133,17 +133,17 @@ void ec_access(char *from, char *to) nobo_strcpy(num); } -void ec_capabilities(char *from, char *to) +void ec_capabilities(char *from, const char *to) { nobo_strcpy(__mx_opts); } -void ec_cc(char *from, char *to) +void ec_cc(char *from, const char *to) { nobo_strcpy((current->activechan) ? current->activechan->name : TEXT_NONE); } -void ec_channels(char *from, char *to) +void ec_channels(char *from, const char *to) { Chan *chan; int n; @@ -166,12 +166,12 @@ void ec_channels(char *from, char *to) } } -void ec_time(char *from, char *to) +void ec_time(char *from, const char *to) { nobo_strcpy(time2away(now)); } -void ec_set(char *from, char *to) +void ec_set(char *from, const char *to) { Chan *chan; UniVar *varval; @@ -225,7 +225,7 @@ void ec_set(char *from, char *to) else if (IsTog(which)) { - nobo_strcpy((varval->int_var) ? "on" : "off"); + nobo_strcpy((varval->int_var) ? __STR_ON : __STR_OFF); } else if (IsStr(which)) @@ -240,12 +240,12 @@ void ec_set(char *from, char *to) ec_src = src; } -void ec_on(char *from, char *to) +void ec_on(char *from, const char *to) { nobo_strcpy(idle2str(now - current->ontime,FALSE)); } -void ec_server(char *from, char *to) +void ec_server(char *from, const char *to) { Server *sv; char *s; @@ -257,12 +257,12 @@ void ec_server(char *from, char *to) nobo_strcpy(s); } -void ec_up(char *from, char *to) +void ec_up(char *from, const char *to) { nobo_strcpy(idle2str(now - uptime,FALSE)); } -void ec_ver(char *from, char *to) +void ec_ver(char *from, const char *to) { nobo_strcpy(BOTCLASS); nobo_strcpy(" "); @@ -271,7 +271,7 @@ void ec_ver(char *from, char *to) LS const struct { - void (*func)(char *, char *); + void (*func)(char *, const char *); char name[12]; char len; @@ -326,7 +326,7 @@ void do_esay(COMMAND_ARGS) c = *chp; *chp = 0; } - n = Strcasecmp(ecmd[i].name,ec_src); + n = stringcasecmp(ecmd[i].name,ec_src); if (c) { *chp = c; @@ -356,7 +356,8 @@ void do_set(COMMAND_ARGS) Chan *chan; UniVar *univar,*varval; char tmp[MSGLEN]; - char *pp,*channel,*name; + char *pp,*name; + const char *channel; int n,which,i,sz,limit,uaccess; /* @@ -421,7 +422,7 @@ second_pass: else if (IsTog(i)) { - pp = Strcat(tmp,(varval->int_var) ? "+" : "-"); + pp = stringcat(tmp,(varval->int_var) ? "+" : "-"); pp = tolowercat(pp,VarName[i].name); pp[0] = ' '; pp[1] = 0; @@ -492,19 +493,19 @@ set_usage: { if (IsTog(which)) { - if (!Strcasecmp(rest,"ON")) + if (!stringcasecmp(rest,__STR_ON)) { n = 1; goto num_data_ok; } else - if (!Strcasecmp(rest,"OFF")) + if (!stringcasecmp(rest,__STR_OFF)) { /* n is 0 by default */ goto num_data_ok; } } - n = a2i((rest = chop(&rest))); + n = asc2int((rest = chop(&rest))); if (errno || n < VarName[which].min || n > VarName[which].max) { to_user(from,"Possible values are %i through %i",VarName[which].min,VarName[which].max); @@ -530,7 +531,7 @@ num_data_ok: if (*rest) { set_mallocdoer(do_set); - chan->setting[which].str_var = Strdup(rest); + chan->setting[which].str_var = stringdup(rest); } } } @@ -553,7 +554,7 @@ num_data_ok: if (*rest) { set_mallocdoer(do_set); - varval->str_var = Strdup(rest); + varval->str_var = stringdup(rest); } } } diff --git a/src/web.c b/src/web.c index 6fce63a..2826acd 100644 --- a/src/web.c +++ b/src/web.c @@ -72,9 +72,9 @@ char *webread(int s, char *rest, char *line) if (np) *np = 0; *pt = 0; - Strcpy(line,rest); + stringcpy(line,rest); pt++; - Strcpy(rest,pt); + stringcpy(rest,pt); #ifdef DEBUG debug("[WoR] {%i} `%s'\n",s,line); #endif /* DEBUG */ @@ -104,9 +104,9 @@ char *webread(int s, char *rest, char *line) if (np) *np = 0; *tp = *pt = 0; - Strcpy(line,rest); + stringcpy(line,rest); pt++; - Strcpy(rest,pt); + stringcpy(rest,pt); #ifdef DEBUG debug("[WoR] {%i} `%s'\n",s,line); #endif /* DEBUG */ @@ -250,7 +250,7 @@ void web_raw(WebSock *client, char *url) goto error; ino = s.st_ino; - dest = Strcpy(path,WEBROOT); + dest = stringcpy(path,WEBROOT); src = url; if (*src == '/') src++; @@ -401,7 +401,7 @@ void parse(WebSock *client, char *rest) method = chop(&rest); url = chop(&rest); proto = chop(&rest); - if (!method || !proto || Strcasecmp(method,"GET")) + if (!method || !proto || stringcasecmp(method,"GET")) { client->status = WEB_DEAD; return; @@ -409,13 +409,13 @@ void parse(WebSock *client, char *rest) client->docptr = &docraw; for(i=0;doclist[i].proc;i++) { - if (!Strcasecmp(doclist[i].url,url)) + if (!stringcasecmp(doclist[i].url,url)) { client->docptr = &doclist[i]; break; } } - client->url = Strdup(url); + client->url = stringdup(url); client->status = WEB_WAITCR; break; case WEB_WAITCR: