reorganizing

This commit is contained in:
joonicks 2018-04-04 06:04:58 +02:00
parent a5187a7a8f
commit c5b03f35e1
66 changed files with 1670 additions and 2742 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ trivia/*.index
energymech
src/energymech
src/*.o
src/lib/*.o
src/gencmd
src/aliastest
src/safepathtest

View File

@ -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

6
README
View File

@ -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.

View File

@ -1 +1 @@
../src/md5/md5.h
../src/lib/md5.h

View File

@ -1 +1 @@
../src/md5/md5.c
../src/lib/md5.c

View File

@ -1 +1 @@
../src/sha/sha1.h
../src/lib/sha1.h

View File

@ -1 +1 @@
../src/sha/sha1.c
../src/lib/sha1.c

19
configure vendored
View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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 = &current->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;

View File

@ -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;
}

View File

@ -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)

View File

@ -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 */

View File

@ -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

View File

@ -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**)&current->nick);
set_mallocdoer(do_nick);
current->nick = Strdup(nick);
current->nick = stringdup(nick);
current->guid = guid;
}
Free((char**)&current->wantnick);
set_mallocdoer(do_nick);
current->wantnick = Strdup(nick);
current->wantnick = stringdup(nick);
to_server("NICK %s\n",current->wantnick);
}
current = backup;

View File

@ -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)

View File

@ -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);

View File

@ -82,6 +82,9 @@
#define MAXSHITLEVELSTRING "4"
#define MAXSHITLEVELCHAR '4'
#define __STR_ON "on"
#define __STR_OFF "off"
/*
* channel modequeues
*/

View File

@ -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 */

View File

@ -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 */

View File

@ -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(;orig<rest;orig++)
{
if (*orig == 0)
*orig = ' ';
}
}
int Strcasecmp(const char *p1, const char *p2)
{
int ret;
if (p1 != p2)
{
while(!(ret = tolowertab[(uchar)*(p1++)] - tolowertab[(uchar)*p2]) && *(p2++))
;
return(ret);
}
return(0);
}
int Strcmp(const char *p1, const char *p2)
{
int ret;
if (p1 != p2)
{
while(!(ret = *(p1++) - *p2) && *(p2++))
;
return(ret);
}
return(0);
}
int nickcmp(const char *p1, const char *p2)
{
int ret;
int c;
if (p1 != p2)
{
while(!(ret = nickcmptab[(uchar)*(p1++)] - (c = nickcmptab[(uchar)*(p2++)])) && c)
;
return(ret);
}
return(0);
}
void Strncpy(char *dst, const char *src, int sz)
{
char *stop = dst + sz - 1;
while(*src)
{
*(dst++) = *(src++);
if (dst == stop)
break;
}
*dst = 0;
}
char *Strcpy(char *dst, const char *src)
{
while(*src)
*(dst++) = *(src++);
*dst = 0;
return(dst);
}
char *Strchr(const char *t, int c)
{
char ch = c;
while(*t != ch && *t)
t++;
return((*t == ch) ? (char*)t : NULL);
}
char *Strdup(const char *src)
{
char *dest;
dest = (char*)Calloc(strlen(src)+1);
Strcpy(dest,src);
return(dest);
}
char *tolowercat(char *dest, const char *src)
{
dest = STREND(dest);
while(*src)
*(dest++) = (char)tolowertab[(uchar)*(src++)];
return(dest);
}
/*
* This code might look odd but its optimized for size,
* so dont change it!
*/
char *Strcat(char *dst, const char *src)
{
while(*(dst++))
;
--dst;
while((*(dst++) = *(src++)) != 0)
;
return(dst-1);
}
#endif /* ifndef TEST */
/*
* mask matching
@ -998,140 +883,6 @@ int num_matches(const char *mask, const char *text)
return(n);
}
Strp *e_table = NULL;
void table_buffer(const char *format, ...)
{
Strp **sp;
va_list msg;
int sz;
va_start(msg,format);
sz = sizeof(Strp) + vsprintf(gsockdata,format,msg);
va_end(msg);
for(sp=&e_table;*sp;sp=&(*sp)->next)
;
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);
}

View File

@ -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 */

View File

@ -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)" : ""));

1253
src/h.h

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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 <sys/utsname.h>
/*---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
*/

View File

@ -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=&current->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);

View File

@ -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++;

View File

@ -1,27 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#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);
}

View File

@ -19,27 +19,24 @@ A million repetitions of "a"
#include <stdio.h>
#include <string.h>
/* for uint32_t */
#include <stdint.h>
#include <unistd.h>
#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

View File

@ -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

Binary file not shown.

View File

@ -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 <NULL> <NULL> <NULL> <NULL> }, envp = { MECHRESET=d3 f1881:2:X12 } )
(recover_debug) debug fd recovered
*/
/*
execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> },
envp = { MECHRESET=d3 f1881:2:X12 } )
*/
while(*envp)
{
char *p1;
@ -881,7 +881,7 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
if ((opt = STRCHR(*argv,' ')) != NULL)
{
*(opt++) = 0;
respawn = a2i(opt);
respawn = asc2int(opt);
if (errno)
{
to_file(1,bad_exe);

View File

@ -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 <string.h> /* 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<<s | 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):
* <phk@login.dknet.dk> 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 */

View File

@ -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 */

View File

@ -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"

View File

@ -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<guid> <hops> <nick>!<userhost> <server> <version>
*/
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);

View File

@ -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)

View File

@ -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;

View File

@ -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 = &current->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;n<NF_OPTIONS;n++)
{
if (!Strcasecmp(notify_opt[n],opt))
if (!stringcasecmp(notify_opt[n],opt))
{
flags |= (1 << n);
break;
@ -691,8 +690,8 @@ void do_notify(COMMAND_ARGS)
if (!nf)
{
if (*message)
Strcat(message,", ");
Strcat(message,opt);
stringcat(message,", ");
stringcat(message,opt);
}
nf_header++;
}

View File

@ -57,7 +57,7 @@ void on_kick(char *from, char *rest)
#endif /* DEBUG */
Free(&chan->kickedby);
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 */

View File

@ -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**)&current->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**)&current->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 */

View File

@ -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:<nick>
begin
Forcefully disconnect someone from the partyline.
end
*/
void do_boot(COMMAND_ARGS)
{
}

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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
/*

View File

@ -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;
}

View File

@ -1,27 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#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);
}

View File

@ -1,296 +0,0 @@
/*
SHA-1 in C
By Steve Reid <steve@edmweb.com>
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 <stdio.h>
#include <string.h>
/* for uint32_t */
#include <stdint.h>
#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<len; ii+=1)
SHA1Update(&ctx, (const unsigned char*)str + ii, 1);
SHA1Final((unsigned char *)hash_out, &ctx);
hash_out[20] = '\0';
}

View File

@ -1,44 +0,0 @@
#ifndef SHA1_H
#define SHA1_H
/*
SHA-1 in C
By Steve Reid <steve@edmweb.com>
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 */

View File

@ -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 = &current->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;
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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;
/*

View File

@ -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 */

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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: