From b4c6efaf0e4e980c5f054422a83340c250d1f694 Mon Sep 17 00:00:00 2001 From: joonicks Date: Sat, 21 Apr 2018 01:32:53 +0200 Subject: [PATCH 1/2] * Fixed: Botnet auth messages now propagate correctly throughout the botnet --- VERSIONS | 1 + src/channel.c | 16 +--------------- src/function.c | 8 +++++--- src/h.h | 3 +-- src/io.c | 3 +-- src/net.c | 45 ++++++++++++++++++++++----------------------- src/parse.c | 2 +- src/spy.c | 3 +-- src/toybox.c | 2 +- src/vars.c | 9 +++++++++ 10 files changed, 43 insertions(+), 49 deletions(-) diff --git a/VERSIONS b/VERSIONS index af8595f..a5665ab 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,6 @@ 3.1 -- WORK IN PROGRESS (~April, 2018) + * Fixed: Botnet auth messages now propagate correctly throughout the botnet * Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords) * Fixed: Issue #25, clients lost when doing reset, no more * Fixed: compiler warnings and missing defines/conflicting defines with certain options diff --git a/src/channel.c b/src/channel.c index 2a15427..19e910c 100644 --- a/src/channel.c +++ b/src/channel.c @@ -97,7 +97,7 @@ void remove_chan(Chan *chan) if (*pp == chan) { *pp = chan->next; - purge_banlist(chan); + purge_linklist((void**)&chan->banlist); purge_chanusers(chan); delete_vars(chan->setting,CHANSET_SIZE); Free(&chan->name); @@ -350,20 +350,6 @@ void delete_modemask(Chan *chan, char *mask, int mode) #endif /* IRCD_EXTENSIONS */ -void purge_banlist(Chan *chan) -{ - Ban *ban,*next; - - ban = chan->banlist; - while(ban) - { - next = ban->next; - Free((char**)&ban); - ban = next; - } - chan->banlist = NULL; -} - void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar) { ChanUser *cu; diff --git a/src/function.c b/src/function.c index 3edb811..55dae83 100644 --- a/src/function.c +++ b/src/function.c @@ -194,18 +194,20 @@ Strp *prepend_strp(Strp **pp, const char *string) } /* - * Free() a chain of Strp's + * Free() a whole linked list of any suitable type (Strp, Banlist) */ -void purge_strplist(Strp *sp) +void purge_linklist(void **list) { - Strp *nxt; + Strp *sp,*nxt; + sp = *list; while(sp) { nxt = sp->next; Free((char**)&sp); sp = nxt; } + *list = NULL; } /* diff --git a/src/h.h b/src/h.h index 3444ec2..a248153 100644 --- a/src/h.h +++ b/src/h.h @@ -152,7 +152,6 @@ char *find_nuh(char *); Ban *make_ban(Ban **, char *, char *, time_t); void delete_ban(Chan *, char *); void delete_modemask(Chan *, char *, int); -void purge_banlist(Chan *); void channel_massmode(const Chan *, char *, int, char, char); void channel_massunban(Chan *, char *, time_t); LS ChanUser *find_chanuser(Chan *, const char *); @@ -280,7 +279,7 @@ LS void Free(char **) __attr(CORE_SEG, __regparm(1)); LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); -LS void purge_strplist(Strp *) __attr(CORE_SEG, __regparm(1)); +LS void purge_linklist(void **) __attr(CORE_SEG, __regparm(1)); LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2)); LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1)); LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2)); diff --git a/src/io.c b/src/io.c index 33f8740..82bfa49 100644 --- a/src/io.c +++ b/src/io.c @@ -689,8 +689,7 @@ void do_clearqueue(COMMAND_ARGS) #ifdef DEBUG debug("(do_clearqueue) purging sendq...\n"); #endif - purge_strplist(current->sendq); - current->sendq = NULL; + purge_linklist((void**)¤t->sendq); } #endif /* GENCMD_C */ diff --git a/src/net.c b/src/net.c index c6dae20..8c33aa7 100644 --- a/src/net.c +++ b/src/net.c @@ -64,32 +64,35 @@ LS struct */ typedef struct LinkCmd { - char c1; - char c2; + char cmd[2]; void (*func)(BotNet *, char *); + int relay; } LinkCmd; +#define RELAY_YES 1 +#define RELAY_NO 0 + LS const LinkCmd basicProto[] = { -{ 'B', 'A', basicAuth }, -{ 'B', 'B', basicBanner }, -{ 'B', 'K', basicAuthOK }, -{ 'B', 'L', basicLink }, -{ 'B', 'Q', basicQuit }, -{ 'C', 'O', netchanNeedop }, +{ "BA", basicAuth, RELAY_NO }, +{ "BB", basicBanner, RELAY_NO }, +{ "BK", basicAuthOK, RELAY_NO }, +{ "BL", basicLink, RELAY_NO }, +{ "BQ", basicQuit, RELAY_NO }, +{ "CO", netchanNeedop, RELAY_YES }, #ifdef SUPPRESS -{ 'C', 'S', netchanSuppress }, // experimental command supression +{ "CS", netchanSuppress, RELAY_YES }, // experimental command supression #endif /* SUPPRESS */ -{ 'P', 'A', partyAuth }, +{ "PA", partyAuth, RELAY_YES }, #ifdef REDIRECT -{ 'P', 'C', partyCommand }, +{ "PC", partyCommand, RELAY_NO }, #endif /* REDIRECT */ -{ 'P', 'M', partyMessage }, -{ 'U', 'T', ushareTick }, -{ 'U', 'U', ushareUser }, -{ 'U', 'D', ushareDelete }, -{ 0, 0, NULL }, +{ "PM", partyMessage, RELAY_NO }, +{ "UT", ushareTick, RELAY_NO }, +{ "UU", ushareUser, RELAY_NO }, +{ "UD", ushareDelete, RELAY_YES }, +{ "\0\0", NULL, RELAY_NO }, }; LS int deadlinks = FALSE; @@ -844,8 +847,6 @@ void netchanNeedop(BotNet *source, char *rest) if (errno || guid < 1 || !channel) return; - botnet_relay(source,"CO%i %s\n",guid,channel); - for(bn=botnetlist;bn;bn=bn->next) { if (bn->status != BN_LINKED) @@ -866,8 +867,6 @@ void netchanSuppress(BotNet *source, char *rest) const char *cmd; int crc,i,j; - botnet_relay(source,"CS%s\n",rest); - cmd = chop(&rest); // convert command to const command @@ -1339,8 +1338,6 @@ void ushareDelete(BotNet *bn, char *rest) } } } - unchop(orig,rest); - botnet_relay(bn,"UD%s\n",orig); } /* @@ -1383,8 +1380,10 @@ not_a_botnet_connection: for(i=0;basicProto[i].func;i++) { - if (basicProto[i].c1 == rest[0] && basicProto[i].c2 == rest[1]) + if (basicProto[i].cmd[0] == rest[0] && basicProto[i].cmd[1] == rest[1]) { + if (basicProto[i].relay == RELAY_YES) + botnet_relay(bn,"%s\n",rest); basicProto[i].func(bn,rest+2); return; } diff --git a/src/parse.c b/src/parse.c index e085d6c..ea145d4 100644 --- a/src/parse.c +++ b/src/parse.c @@ -111,7 +111,7 @@ void parse_join(char *from, char *rest) current->lastchanban = 0; #endif /* CHANBAN */ to_server("WHO %s\nMODE %s\nMODE %s b\n",rest,rest,rest); - purge_banlist(chan); + purge_linklist((void**)&chan->banlist); purge_chanusers(chan); #ifdef STATS diff --git a/src/spy.c b/src/spy.c index fe8e826..9ad54f5 100644 --- a/src/spy.c +++ b/src/spy.c @@ -406,8 +406,7 @@ void urlcapture(const char *rest) { if (n <= 0) { - purge_strplist(sp->next); - sp->next = NULL; + purge_linklist((void**)&sp->next); return; } n--; diff --git a/src/toybox.c b/src/toybox.c index 4915226..41ddcc3 100644 --- a/src/toybox.c +++ b/src/toybox.c @@ -178,7 +178,7 @@ int read_bigcharset(char *fname) bigc = orig_fontlist; orig_fontlist = bigc->next; if (bigc->data) - purge_strplist(bigc->data); + purge_linklist((void**)&bigc->data); Free((char**)&bigc); } diff --git a/src/vars.c b/src/vars.c index acfddd5..2974179 100644 --- a/src/vars.c +++ b/src/vars.c @@ -269,6 +269,14 @@ void ec_ver(char *from, const char *to) nobo_strcpy(VERSION); } +void ec_guid(char *from, const char *to) +{ + char tmp[32]; + + sprintf(tmp,"%i",current->guid); + nobo_strcpy(tmp); +} + LS const struct { void (*func)(char *, const char *); @@ -287,6 +295,7 @@ LS const struct { ec_server, "$server", 7 }, { ec_up, "$up", 3 }, { ec_ver, "$ver", 4 }, + { ec_guid, "$guid", 5 }, { NULL, "", 0 }, }; From 0e6f3c4b73872f774cb1ef5de15ee59ed8c7a65a Mon Sep 17 00:00:00 2001 From: joonicks Date: Sun, 22 Apr 2018 02:34:04 +0200 Subject: [PATCH 2/2] * Added: $guid to esay variables * Added: New bigsay font: spider, use with .bigsay -spider cowabunga! * Fixed: Error in printing pointers would make lots of debug output go missing * Changed: Debug output (./energymech -d -o ) now appends instead of truncating * Fixed: Botnet auth messages now propagate correctly throughout the botnet --- Makefile | 3 + VERSIONS | 5 ++ spider.bigchars | 208 ++++++++++++++++++++++++++++++++++++++++++++++++ src/channel.c | 16 +--- src/config.h.in | 10 +++ src/debug.c | 8 +- src/function.c | 8 +- src/h.h | 3 +- src/io.c | 3 +- src/main.c | 20 +++-- src/net.c | 45 +++++------ src/parse.c | 2 +- src/spy.c | 3 +- src/toybox.c | 37 ++++++--- src/vars.c | 9 +++ 15 files changed, 312 insertions(+), 68 deletions(-) create mode 100644 spider.bigchars diff --git a/Makefile b/Makefile index 57c2fb5..eba9440 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,9 @@ mega-install: test: $(MAKE) -C src test +defines: + (gcc -dM -E - < /dev/null) | sort + # # packing things up for distribution # diff --git a/VERSIONS b/VERSIONS index af8595f..d0c72e0 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,10 @@ 3.1 -- WORK IN PROGRESS (~April, 2018) + * Added: $guid to esay variables + * Added: New bigsay font: spider, use with .bigsay -spider cowabunga! + * Fixed: Error in printing pointers would make lots of debug output go missing + * Changed: Debug output (./energymech -d -o ) now appends instead of truncating + * Fixed: Botnet auth messages now propagate correctly throughout the botnet * Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords) * Fixed: Issue #25, clients lost when doing reset, no more * Fixed: compiler warnings and missing defines/conflicting defines with certain options diff --git a/spider.bigchars b/spider.bigchars new file mode 100644 index 0000000..82bdd52 --- /dev/null +++ b/spider.bigchars @@ -0,0 +1,208 @@ +fontname energymech-capitals-spider-height5-v3 +spacewidth 4 +charheight 5 +kerning 1 + +chars ! +| +| +| + +o + +chars . + + + + + +o + +chars | +| +| +| +| +| + +chars : + +o + +o + + +chars aA + ,-. +/ \ +|___| +| | +| | + +chars bB +,--. +| ) +|--{ +| \ +|___/ + +chars cC + ,--. +/ +| +| +\___/ + +chars dD +,-. +| \ +| | +| | +|___/ + +chars eE +,--- +| +|-- +| +|___, + +chars fF +,--- +| +|-- +| +| + +chars gG + ,--. +/ +| _ +| | +\___/ + +chars hH +, , +| | +|___| +| | +| | + +chars iI + , + | + | + | + | + +chars jJ + , + | + | +, | +\___/ + +chars kK +, , +| / +|-{ +| \ +| \ + +chars lL +, +| +| +| +|___, + +chars mM +,~. ,~. +| | | +| | | +| | | +| | | + +chars nN +, , +|\ | +| \ | +| \| +| | + +chars oO +,-~-. +| | +| | +| | +\___/ + +chars pP +,--. +| ) +|--' +| +| + +chars rR +,--. +| ) +|--' +| \ +| \ + +chars sS + ,-~ +( + '-. + ) +'--' + +chars tT +~-+-~ + | + | + | + + + +chars uU +, , +| | +| | +| | +\___/ + +chars vV +, , +| | +' ' + \ / + V + +chars wW +, , , +| | | +| | | +' | ' + \/ \/ + +chars xX +. , + \ / + X + / \ +/ \ + +chars yY +. , + \ / + Y + | + | + +chars zZ + -~~, + / + / + / +/___, diff --git a/src/channel.c b/src/channel.c index 2a15427..19e910c 100644 --- a/src/channel.c +++ b/src/channel.c @@ -97,7 +97,7 @@ void remove_chan(Chan *chan) if (*pp == chan) { *pp = chan->next; - purge_banlist(chan); + purge_linklist((void**)&chan->banlist); purge_chanusers(chan); delete_vars(chan->setting,CHANSET_SIZE); Free(&chan->name); @@ -350,20 +350,6 @@ void delete_modemask(Chan *chan, char *mask, int mode) #endif /* IRCD_EXTENSIONS */ -void purge_banlist(Chan *chan) -{ - Ban *ban,*next; - - ban = chan->banlist; - while(ban) - { - next = ban->next; - Free((char**)&ban); - ban = next; - } - chan->banlist = NULL; -} - void channel_massmode(const Chan *chan, char *pattern, int filtmode, char mode, char typechar) { ChanUser *cu; diff --git a/src/config.h.in b/src/config.h.in index 8b50865..784bd33 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -427,15 +427,25 @@ */ #ifdef PTSIZE_32BIT +#if defined(__GNUC__) +#define mx_ptr void* +#define mx_pfmt "%p" +#else #define mx_ptr unsigned int #define mx_pfmt "%.8x" +#endif #endif #ifdef PTSIZE_64BIT +#if defined(__GNUC__) +#define mx_ptr void* +#define mx_pfmt "%p" +#else #define mx_ptr long long #define mx_pfmt "%.16Lx" +#endif #endif diff --git a/src/debug.c b/src/debug.c index 39ad1c0..6668b46 100644 --- a/src/debug.c +++ b/src/debug.c @@ -773,6 +773,7 @@ void debug_core(void) User *user; int i; + debug("; mx_pfmt\t\t\"%s\"\n",mx_pfmt); debug("; VERSION\t\t\"%s\"\n",VERSION); debug("; SRCDATE\t\t\"%s\"\n",SRCDATE); debug("; BOTLOGIN\t\t\"%s\"\n",BOTLOGIN); @@ -1176,13 +1177,14 @@ void debug_core(void) memtouch(bigc); debug(" ; width\t\t%i\n",bigc->width); debug(" ; chars\t\t\"%s\"\n",bigc->chars); - debug(" > data\t\t"mx_pfmt"\n",(mx_ptr)bigc->data); - for(st=bigc->data;st;st=st->next) + debug(" > data\t\t" mx_pfmt "\n",(mx_ptr)bigc->data); + for(st=bigc->data;st != NULL;st=st->next) { memtouch(st); debug(" ; Strp*\t\t"mx_pfmt" { "mx_pfmt", \"%s\" }\n", (mx_ptr)st,(mx_ptr)st->next,st->p); } + debug(" ; next\t\t" mx_pfmt "\n",(mx_ptr)bigc->next); } #endif /* TOYBOX */ #ifdef TRIVIA @@ -1403,7 +1405,7 @@ void debug(char *format, ...) { if (debugfile) { - if ((debug_fd = open(debugfile,O_CREAT|O_TRUNC|O_WRONLY,SECUREFILEMODE)) < 0) + if ((debug_fd = open(debugfile,O_CREAT|O_APPEND|O_WRONLY,SECUREFILEMODE)) < 0) { dodebug = FALSE; return; diff --git a/src/function.c b/src/function.c index 3edb811..55dae83 100644 --- a/src/function.c +++ b/src/function.c @@ -194,18 +194,20 @@ Strp *prepend_strp(Strp **pp, const char *string) } /* - * Free() a chain of Strp's + * Free() a whole linked list of any suitable type (Strp, Banlist) */ -void purge_strplist(Strp *sp) +void purge_linklist(void **list) { - Strp *nxt; + Strp *sp,*nxt; + sp = *list; while(sp) { nxt = sp->next; Free((char**)&sp); sp = nxt; } + *list = NULL; } /* diff --git a/src/h.h b/src/h.h index 3444ec2..a248153 100644 --- a/src/h.h +++ b/src/h.h @@ -152,7 +152,6 @@ char *find_nuh(char *); Ban *make_ban(Ban **, char *, char *, time_t); void delete_ban(Chan *, char *); void delete_modemask(Chan *, char *, int); -void purge_banlist(Chan *); void channel_massmode(const Chan *, char *, int, char, char); void channel_massunban(Chan *, char *, time_t); LS ChanUser *find_chanuser(Chan *, const char *); @@ -280,7 +279,7 @@ LS void Free(char **) __attr(CORE_SEG, __regparm(1)); LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2)); -LS void purge_strplist(Strp *) __attr(CORE_SEG, __regparm(1)); +LS void purge_linklist(void **) __attr(CORE_SEG, __regparm(1)); LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2)); LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1)); LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2)); diff --git a/src/io.c b/src/io.c index 33f8740..82bfa49 100644 --- a/src/io.c +++ b/src/io.c @@ -689,8 +689,7 @@ void do_clearqueue(COMMAND_ARGS) #ifdef DEBUG debug("(do_clearqueue) purging sendq...\n"); #endif - purge_strplist(current->sendq); - current->sendq = NULL; + purge_linklist((void**)¤t->sendq); } #endif /* GENCMD_C */ diff --git a/src/main.c b/src/main.c index 38983b5..199de80 100644 --- a/src/main.c +++ b/src/main.c @@ -452,10 +452,6 @@ void sig_segv(int crap, siginfo_t *si, void *uap) time(&now); - respawn++; - if (respawn > 10) - mechexit(1,exit); - #ifdef DEBUG debug("(sigsegv) trying to access "mx_pfmt"\n",(mx_ptr)si->si_addr); #ifdef __x86_64__ @@ -475,6 +471,10 @@ void sig_segv(int crap, siginfo_t *si, void *uap) } #endif /* DEBUG */ + respawn++; + if (respawn > 10) + mechexit(1,exit); + do_exec = TRUE; sig_suicide(TEXT_SIGSEGV /* comma */ UP_CALL(UPTIME_SIGSEGV)); /* NOT REACHED */ @@ -1171,6 +1171,7 @@ int main(int argc, char **argv, char **envp) { mirror_userlist(); } + #ifdef SEEN read_seenlist(); #endif /* SEEN */ @@ -1227,8 +1228,12 @@ int main(int argc, char **argv, char **envp) s.sa_flags = SA_SIGINFO; sigemptyset(&s.sa_mask); s.sa_sigaction = sig_segv; - sigaction(SIGSEGV, &s, NULL); - //signal(SIGSEGV,sig_segv); + if (sigaction(SIGSEGV, &s, NULL) < 0) + { +#ifdef DEBUG + debug("(main) binding SIGSEGV handler failed: %s\n",strerror(errno)); +#endif + } #ifdef DEBUG signal(SIGILL,sig_ill); signal(SIGABRT,sig_abrt); @@ -1245,5 +1250,8 @@ int main(int argc, char **argv, char **envp) _exit(0); } startup = FALSE; +#ifdef DEBUG + debug("(main) entering doit()...\n"); +#endif doit(); } diff --git a/src/net.c b/src/net.c index c6dae20..8c33aa7 100644 --- a/src/net.c +++ b/src/net.c @@ -64,32 +64,35 @@ LS struct */ typedef struct LinkCmd { - char c1; - char c2; + char cmd[2]; void (*func)(BotNet *, char *); + int relay; } LinkCmd; +#define RELAY_YES 1 +#define RELAY_NO 0 + LS const LinkCmd basicProto[] = { -{ 'B', 'A', basicAuth }, -{ 'B', 'B', basicBanner }, -{ 'B', 'K', basicAuthOK }, -{ 'B', 'L', basicLink }, -{ 'B', 'Q', basicQuit }, -{ 'C', 'O', netchanNeedop }, +{ "BA", basicAuth, RELAY_NO }, +{ "BB", basicBanner, RELAY_NO }, +{ "BK", basicAuthOK, RELAY_NO }, +{ "BL", basicLink, RELAY_NO }, +{ "BQ", basicQuit, RELAY_NO }, +{ "CO", netchanNeedop, RELAY_YES }, #ifdef SUPPRESS -{ 'C', 'S', netchanSuppress }, // experimental command supression +{ "CS", netchanSuppress, RELAY_YES }, // experimental command supression #endif /* SUPPRESS */ -{ 'P', 'A', partyAuth }, +{ "PA", partyAuth, RELAY_YES }, #ifdef REDIRECT -{ 'P', 'C', partyCommand }, +{ "PC", partyCommand, RELAY_NO }, #endif /* REDIRECT */ -{ 'P', 'M', partyMessage }, -{ 'U', 'T', ushareTick }, -{ 'U', 'U', ushareUser }, -{ 'U', 'D', ushareDelete }, -{ 0, 0, NULL }, +{ "PM", partyMessage, RELAY_NO }, +{ "UT", ushareTick, RELAY_NO }, +{ "UU", ushareUser, RELAY_NO }, +{ "UD", ushareDelete, RELAY_YES }, +{ "\0\0", NULL, RELAY_NO }, }; LS int deadlinks = FALSE; @@ -844,8 +847,6 @@ void netchanNeedop(BotNet *source, char *rest) if (errno || guid < 1 || !channel) return; - botnet_relay(source,"CO%i %s\n",guid,channel); - for(bn=botnetlist;bn;bn=bn->next) { if (bn->status != BN_LINKED) @@ -866,8 +867,6 @@ void netchanSuppress(BotNet *source, char *rest) const char *cmd; int crc,i,j; - botnet_relay(source,"CS%s\n",rest); - cmd = chop(&rest); // convert command to const command @@ -1339,8 +1338,6 @@ void ushareDelete(BotNet *bn, char *rest) } } } - unchop(orig,rest); - botnet_relay(bn,"UD%s\n",orig); } /* @@ -1383,8 +1380,10 @@ not_a_botnet_connection: for(i=0;basicProto[i].func;i++) { - if (basicProto[i].c1 == rest[0] && basicProto[i].c2 == rest[1]) + if (basicProto[i].cmd[0] == rest[0] && basicProto[i].cmd[1] == rest[1]) { + if (basicProto[i].relay == RELAY_YES) + botnet_relay(bn,"%s\n",rest); basicProto[i].func(bn,rest+2); return; } diff --git a/src/parse.c b/src/parse.c index e085d6c..ea145d4 100644 --- a/src/parse.c +++ b/src/parse.c @@ -111,7 +111,7 @@ void parse_join(char *from, char *rest) current->lastchanban = 0; #endif /* CHANBAN */ to_server("WHO %s\nMODE %s\nMODE %s b\n",rest,rest,rest); - purge_banlist(chan); + purge_linklist((void**)&chan->banlist); purge_chanusers(chan); #ifdef STATS diff --git a/src/spy.c b/src/spy.c index fe8e826..9ad54f5 100644 --- a/src/spy.c +++ b/src/spy.c @@ -406,8 +406,7 @@ void urlcapture(const char *rest) { if (n <= 0) { - purge_strplist(sp->next); - sp->next = NULL; + purge_linklist((void**)&sp->next); return; } n--; diff --git a/src/toybox.c b/src/toybox.c index 4915226..d961ef5 100644 --- a/src/toybox.c +++ b/src/toybox.c @@ -90,14 +90,11 @@ int read_bigcharset_callback(char *rest) if (!stringcasecmp(opt,"chars") && charheight) { charlines = charheight; - opt = chop(&rest); + set_mallocdoer(read_bigcharset_callback); newchar = (BigC*)Calloc(sizeof(BigC) + strlen(opt)); - /* Calloc sets to zero - newchar->width = 0; - newchar->data = NULL; - */ + newchar->next = fontlist; fontlist = newchar; stringcpy(newchar->chars,opt); @@ -141,7 +138,6 @@ int read_bigcharset_callback(char *rest) *n = asc2int(rest); if (errno) *n = 0; } - return(FALSE); } @@ -163,6 +159,7 @@ int read_bigcharset(char *fname) orig_spacewidth = spacewidth; orig_kerning = kerning; + fontlist = NULL; charlines = 0; spacewidth = 0; charheight = 0; @@ -173,12 +170,15 @@ int read_bigcharset(char *fname) /* * free the old font if there is one */ +#ifdef DEBUG + debug("(read_bigcharset) purge old charset, if there is one. orig = %p\n",orig_fontlist); +#endif while(orig_fontlist) { bigc = orig_fontlist; orig_fontlist = bigc->next; if (bigc->data) - purge_strplist(bigc->data); + purge_linklist((void**)&bigc->data); Free((char**)&bigc); } @@ -708,6 +708,7 @@ void read_triviascore(void) void do_bigsay(COMMAND_ARGS) { +#define OEND (output + MSGLEN - 1) /* * on_msg checks CARGS + CAXS */ @@ -717,19 +718,33 @@ void do_bigsay(COMMAND_ARGS) char *pt,*tail,*temp,*temp2; int i,x; -#ifdef DEBUG - debug("(do_bigsay) rest = \"%s\"\n",rest); -#endif /* DEBUG */ + if (fontname && *rest != '-') + goto reuse_font; stringcpy(output,BIGSAY_DEFAULTFONT); + if (rest[0] == '-') + { + temp = chop(&rest); + if (temp[1] == '-') + ; // allow .bigsay -- -dash- + else + if (STRCHR(temp,'/') == NULL) // no filesystem perversions... + { + stringcat(stringcpy(output,temp+1),".bigchars"); // temp+1 = skip initial '-' + } + } +#ifdef DEBUG + debug("(do_bigsay) fontfile %s, text = \"%s\"\n",output,rest); +#endif /* DEBUG */ + if (read_bigcharset(output) < 0) { to_user(from,ERR_FILEOPEN,output); return; } -#define OEND (output + MSGLEN - 1) +reuse_font: for(i=0;iguid); + nobo_strcpy(tmp); +} + LS const struct { void (*func)(char *, const char *); @@ -287,6 +295,7 @@ LS const struct { ec_server, "$server", 7 }, { ec_up, "$up", 3 }, { ec_ver, "$ver", 4 }, + { ec_guid, "$guid", 5 }, { NULL, "", 0 }, };