From 581c44e7fbb2528b283cdef6d01f91253f6da8eb Mon Sep 17 00:00:00 2001 From: joonicks Date: Wed, 4 Apr 2018 08:56:14 +0200 Subject: [PATCH] reorganizing3 --- configure | 4 +++- src/Makefile.in | 10 ++++----- src/auth.c | 6 +++--- src/channel.c | 4 ++-- src/config.h.in | 4 ---- src/core.c | 18 ++++++++-------- src/ctcp.c | 6 +++--- src/debug.c | 32 ++++++++++++++-------------- src/dns.c | 56 ++++++++++++++++++++++++------------------------- src/gencmd.c | 34 ++++++++++++++++++++++++++++-- src/global.h | 11 +++++++--- src/h.h | 16 +++++++------- src/kicksay.c | 2 +- src/main.c | 4 ++-- src/mega.c | 2 +- src/parse.c | 10 ++++----- src/prot.c | 7 ++++--- src/shit.c | 5 +++-- src/socket.c | 6 +++--- src/spy.c | 7 ++++--- src/stats.c | 2 +- src/structs.h | 47 ++++++++++++++++++++--------------------- src/text.h | 9 ++++++-- src/uptime.c | 22 +++++++++---------- 24 files changed, 182 insertions(+), 142 deletions(-) diff --git a/configure b/configure index 9c374b2..d02d537 100755 --- a/configure +++ b/configure @@ -1247,7 +1247,7 @@ fi # def_perl='#undef PERL' unset ans -$out $ac_n "[ ALPHA] Perl scripting support? .................... [y/N] "$ac_c +$out $ac_n "[ ALPHA] Scripting with Perl? ....................... [y/N] "$ac_c if [ "$has_perl" = no ]; then $out 'no (unsupported)' else @@ -1375,6 +1375,8 @@ s%@gdbflag@%$cc_g_flag%; /@L_PERL@/ { s,@L_PERL@,$L_PERL,; }; /@PYINCLUDE@/ { s,@PYINCLUDE@,$incpython,; }; /@TCLINCLUDE@/ { s,@TCLINCLUDE@,$inctcl,; }; +s|@MD5_C@|$MD5_C|; +s|@SHA_C@|$SHA_C|; s|@MD5_O@|$MD5_O|; s|@SHA_O@|$SHA_O|; s%@oc@%$objcomment%; diff --git a/src/Makefile.in b/src/Makefile.in index 7fa77ad..ee61390 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -84,12 +84,12 @@ clean: $(INSTALLNAME): $(OFILES) $(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) $(L_PERL) -@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) +@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment -R .got -R .got.plt $(INSTALLNAME) @sz@ size $(INSTALLNAME) $(INSTALLNAME)-static: $(OFILES) $(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) $(L_PERL) -static -@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) +@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment -R .got -R .got.plt $(INSTALLNAME) @sz@ size $(INSTALLNAME) @@ -104,12 +104,12 @@ mega-install: mega $(SRCFILES) $(INCS) usage.h $(MV) $(INSTALLNAME) $(INSTALLDIR) mega: $(SRCFILES) $(INCS) usage.h - $(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c -DGENDATE="`./gencmd date`" -I. $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) @oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) @sz@ size $(INSTALLNAME) mega-static: $(SRCFILES) $(INCS) usage.h - $(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) -static + $(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c -DGENDATE="`./gencmd date`" -I. $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) -static @oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) @sz@ size $(INSTALLNAME) @@ -189,7 +189,7 @@ kicksay.o: kicksay.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) main.o: main.c $(INCS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) $(PYINCLUDE) + $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -DGENDATE="`./gencmd date`" $(CPROF) $(PYINCLUDE) net.o: net.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) diff --git a/src/auth.c b/src/auth.c index 7d5cdd8..1f3d596 100644 --- a/src/auth.c +++ b/src/auth.c @@ -61,10 +61,10 @@ char pctab[] = char *cipher(char *arg) { static char res[40]; - ulong B1a,B2a,B3a,B4a; - ulong B1b,B2b,B3b,B4b; + uint32_t B1a,B2a,B3a,B4a; + uint32_t B1b,B2b,B3b,B4b; uchar *ptr; - ulong R1; + uint32_t R1; int i; if (!arg || !*arg) diff --git a/src/channel.c b/src/channel.c index 653b338..f05d3e6 100644 --- a/src/channel.c +++ b/src/channel.c @@ -574,7 +574,7 @@ ChanUser *find_chanuser(Chan *chan, const char *nick) return(NULL); } -void remove_chanuser(Chan *chan, char *nick) +void remove_chanuser(Chan *chan, const char *nick) { ChanUser *cu,**pp; uchar ni; @@ -786,7 +786,7 @@ void do_channels(COMMAND_ARGS) to_user(from,ERR_NOCHANNELS); return; } - table_buffer("\037channel\037\t \037@\037\t\037users\037\t\037ops\037\t\037voiced\037\t\037modes\037"); + table_buffer(str_underline("channel") "\t" str_underline("@") "\t" str_underline("users") "\t" str_underline("ops") "\t" str_underline("voiced") "\t" str_underline("modes")); for(chan=current->chanlist;chan;chan=chan->next) { p = stringcpy(text,chan->name); diff --git a/src/config.h.in b/src/config.h.in index 4b56510..4f5087a 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -589,10 +589,6 @@ extern char __mx_opts[]; #endif /* MAIN_C */ -#ifndef ulong -#define ulong unsigned long -#endif - #ifndef uchar #define uchar unsigned char #endif diff --git a/src/core.c b/src/core.c index f6e1034..5b33d7a 100644 --- a/src/core.c +++ b/src/core.c @@ -566,7 +566,7 @@ int try_server(Server *sp, char *hostname) #ifdef RAWDNS char temphost[NAMEBUF]; char *host; - ulong ip; + uint32_t ip; #endif /* RAWDNS */ if (!hostname) @@ -758,10 +758,10 @@ void register_with_server(void) #ifdef SCRIPTING -int sub_compile_timer(int limit, ulong *flags1, ulong *flags2, char *args) +int sub_compile_timer(int limit, uint32_t *flags1, uint32_t *flags2, char *args) { char *s,*dash; - ulong f; + uint32_t f; int n,hi,lo; *flags1 = 0; @@ -855,12 +855,12 @@ typedef struct { time_t last; time_t next; - ulong second1:30; - ulong second2:30; - ulong minute1:30; - ulong minute2:30; - ulong hour:24; - ulong weekday:7; + uint32_t second1:30; + uint32_t second2:30; + uint32_t minute1:30; + uint32_t minute2:30; + uint32_t hour:24; + uint32_t weekday:7; } HookTimer; diff --git a/src/ctcp.c b/src/ctcp.c index f6fa817..76fd87e 100644 --- a/src/ctcp.c +++ b/src/ctcp.c @@ -229,7 +229,7 @@ void parse_dcc(Client *client) if (client->flags & DCC_RECV) { char bigtemp[4096]; - ulong where; + uint32_t where; do { @@ -259,7 +259,7 @@ void parse_dcc(Client *client) } if (client->flags & DCC_SEND) { - ulong where; + uint32_t where; client->lasttime = now; s = client->inputcount; @@ -421,7 +421,7 @@ void ctcp_dcc(char *from, char *to, char *rest) Client *client; User *user; char *addr,*port,ip_addr[20]; - ulong longip; + uint32_t longip; int x; #ifdef DCC_FILE char *filename; diff --git a/src/debug.c b/src/debug.c index 5d82f71..4a06933 100644 --- a/src/debug.c +++ b/src/debug.c @@ -389,10 +389,10 @@ void memreset(void) } } -LS void *mem_lowptr; -LS void *mem_hiptr; +LS const void *mem_lowptr; +LS const void *mem_hiptr; -void memtouch(void *addr) +void memtouch(const void *addr) { aMEA *mp; int i; @@ -1245,19 +1245,19 @@ typedef struct { time_t last; time_t next; - ulong second1; //:30; - ulong second2; //:30; - ulong minute1; //:30; - ulong minute2; //:30; - ulong hour; //:24; - ulong weekday; //:7; + uint32_t second1; //:30; + uint32_t second2; //:30; + uint32_t minute1; //:30; + uint32_t minute2; //:30; + uint32_t hour; //:24; + uint32_t weekday; //:7; } HookTimer; #endif /* 0 */ char binstr[33]; -char *ulong2bin(int limit, ulong x) +char *uint32tobin(int limit, uint32_t x) { char *dst = binstr; int n; @@ -1296,12 +1296,12 @@ void debug_scripthook(void) if (h->flags == HOOK_TIMER) { debug(" ; timer\t\t"mx_pfmt"\n",(mx_ptr)h->type.timer); - debug(" ; timer.second1\t%s ( 0..29)\n",ulong2bin(30,h->type.timer->second1)); - debug(" ; timer.second2\t%s (30..59)\n",ulong2bin(30,h->type.timer->second2)); - debug(" ; timer.minute1\t%s ( 0..29)\n",ulong2bin(30,h->type.timer->minute1)); - debug(" ; timer.minute2\t%s (30..59)\n",ulong2bin(30,h->type.timer->minute2)); - debug(" ; timer.hour\t\t%s (0..23)\n",ulong2bin(24,h->type.timer->hour)); - debug(" ; timer.weekday\t%s (0..6)\n",ulong2bin(7,h->type.timer->weekday)); + debug(" ; timer.second1\t%s ( 0..29)\n",uint32tobin(30,h->type.timer->second1)); + debug(" ; timer.second2\t%s (30..59)\n",uint32tobin(30,h->type.timer->second2)); + debug(" ; timer.minute1\t%s ( 0..29)\n",uint32tobin(30,h->type.timer->minute1)); + debug(" ; timer.minute2\t%s (30..59)\n",uint32tobin(30,h->type.timer->minute2)); + debug(" ; timer.hour\t\t%s (0..23)\n",uint32tobin(24,h->type.timer->hour)); + debug(" ; timer.weekday\t%s (0..6)\n",uint32tobin(7,h->type.timer->weekday)); } debug(" ; self\t\t\"%s\"\n",nullstr(h->self)); if (h->next) diff --git a/src/dns.c b/src/dns.c index eb58442..4926ee0 100644 --- a/src/dns.c +++ b/src/dns.c @@ -30,22 +30,22 @@ #include "text.h" #include "mcmd.h" -#define unpack_ushort(x) (((x)[0] << 8) | ((x)[1])) -#define unpack_ulong(x) (((x)[0] << 24) | ((x)[1] << 16) | ((x)[2] << 8) | ((x)[3])) +#define unpack_uint16_t(x) (((x)[0] << 8) | ((x)[1])) +#define unpack_uint32_t(x) (((x)[0] << 24) | ((x)[1] << 16) | ((x)[2] << 8) | ((x)[3])) typedef struct dnsType { - ushort type; - ushort class; + uint16_t type; + uint16_t class; } dnsType; typedef struct dnsRType { - ushort type; /* &0 */ - ushort class; /* &2 */ - ulong ttl; /* &4 */ - ushort rdlength; /* &8 */ + uint16_t type; /* &0 */ + uint16_t class; /* &2 */ + uint32_t ttl; /* &4 */ + uint16_t rdlength; /* &8 */ } dnsRType; @@ -112,7 +112,7 @@ struct in_addr dnsroot_lookup(const char *hostname) const char *get_dns_token(const char *src, const char *packet, char *dst, int sz) { const char *endsrc = NULL; - ushort offptr; + uint16_t offptr; int tsz; int dot = 0; @@ -268,7 +268,7 @@ void parse_query(int psz, dnsQuery *query) { /* skip QNAME */ src = get_dns_token(src,(const char *)query,token,psz); - /* skip (ushort)QTYPE and (ushort)QCLASS */ + /* skip (uint16_t)QTYPE and (uint16_t)QCLASS */ src += 4; } @@ -283,8 +283,8 @@ void parse_query(int psz, dnsQuery *query) debug("(parse_query) %i: answer = %s\n",dns->id,token); #endif /* DEBUG */ - if ((unpack_ushort(&rtyp[0]) == DNS_TYPE_CNAME) && - (unpack_ushort(&rtyp[2]) == DNS_CLASS_IN)) + if ((unpack_uint16_t(&rtyp[0]) == DNS_TYPE_CNAME) && + (unpack_uint16_t(&rtyp[2]) == DNS_CLASS_IN)) { get_dns_token(src,(const char *)query,token2,psz); #ifdef DEBUG @@ -297,9 +297,9 @@ void parse_query(int psz, dnsQuery *query) dns->cname = stringdup(token2); } - if ((unpack_ushort(&rtyp[0]) == DNS_TYPE_A) && - (unpack_ushort(&rtyp[2]) == DNS_CLASS_IN) && - (unpack_ushort(&rtyp[8]) == 4)) + if ((unpack_uint16_t(&rtyp[0]) == DNS_TYPE_A) && + (unpack_uint16_t(&rtyp[2]) == DNS_CLASS_IN) && + (unpack_uint16_t(&rtyp[8]) == 4)) { ip = get_stored_ip(src); if (dns->auth && !stringcasecmp(dns->auth->hostname,token)) @@ -331,7 +331,7 @@ void parse_query(int psz, dnsQuery *query) return; } } - src += unpack_ushort(&rtyp[8]); + src += unpack_uint16_t(&rtyp[8]); n--; } @@ -346,8 +346,8 @@ void parse_query(int psz, dnsQuery *query) src = get_dns_token(src,(const char*)query,token,psz); rtyp = src; src += 10; - if ((unpack_ushort(&rtyp[0]) == DNS_TYPE_NS) && - (unpack_ushort(&rtyp[2]) == DNS_CLASS_IN)) + if ((unpack_uint16_t(&rtyp[0]) == DNS_TYPE_NS) && + (unpack_uint16_t(&rtyp[2]) == DNS_CLASS_IN)) { dnsAuthority *da; @@ -384,11 +384,11 @@ void parse_query(int psz, dnsQuery *query) else { debug("(parse_query) DNS TYPE %s(%i), CLASS %i, size %i\n", - type_textlist[unpack_ushort(&rtyp[0])],unpack_ushort(&rtyp[0]), - unpack_ushort(&rtyp[2]),unpack_ushort(&rtyp[8])); + type_textlist[unpack_uint16_t(&rtyp[0])],unpack_uint16_t(&rtyp[0]), + unpack_uint16_t(&rtyp[2]),unpack_uint16_t(&rtyp[8])); } #endif /* DEBUG */ - src += unpack_ushort(&rtyp[8]); + src += unpack_uint16_t(&rtyp[8]); n--; } @@ -402,9 +402,9 @@ void parse_query(int psz, dnsQuery *query) rtyp = src; src += 10; - if ( (unpack_ushort(&rtyp[0]) == DNS_TYPE_A) && - (unpack_ushort(&rtyp[2]) == DNS_CLASS_IN) && - (unpack_ushort(&rtyp[8]) == 4)) + if ( (unpack_uint16_t(&rtyp[0]) == DNS_TYPE_A) && + (unpack_uint16_t(&rtyp[2]) == DNS_CLASS_IN) && + (unpack_uint16_t(&rtyp[8]) == 4)) { ip = get_stored_ip(src); if (dns->auth && !stringcasecmp(dns->auth->hostname,token)) @@ -415,7 +415,7 @@ void parse_query(int psz, dnsQuery *query) debug("(parse_query) resources: %s = %s\n",token,inet_ntoa(*ip)); #endif /* DEBUG */ } - src += unpack_ushort(&rtyp[8]); + src += unpack_uint16_t(&rtyp[8]); n--; } @@ -717,9 +717,9 @@ int read_dnsroot(char *line) /* * find the IP quickly */ -ulong rawdns_get_ip(const char *host) +uint32_t rawdns_get_ip(const char *host) { - ulong ip; + uint32_t ip; if ((ip = inet_addr(host)) == INADDR_NONE) { @@ -852,7 +852,7 @@ void do_dns(COMMAND_ARGS) * on_msg checks: CARGS and GAXS */ char *host,*res,*src,*dst,*dot; - ulong ip; + uint32_t ip; /* to date, all hostnames contain atleast one dot */ if ((STRCHR(rest,'.'))) diff --git a/src/gencmd.c b/src/gencmd.c index dfc92a8..1d7933d 100644 --- a/src/gencmd.c +++ b/src/gencmd.c @@ -55,7 +55,7 @@ struct int pass; const char *name; const char *func; - ulong flags; + uint32_t flags; char *cmdarg; } pre_mcmd[] = @@ -303,7 +303,7 @@ void make_mcmd(void) } if (pass == __struct_acces) { - to_file(fd,"LS OnMsg_access acmd[] = \n{\n"); + to_file(fd,"LS OnMsg_access acmd[] =\n{\n"); } for(i=0;pre_mcmd[i].name;i++) { @@ -482,6 +482,33 @@ void test_help(void) exit(0); } +const char *month[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; +int hourampm[24] = { 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + +void datestamp(void) +{ + char str[100],*th; + struct tm *t; + time_t now; + + time(&now); + t = localtime(&now); + + switch(t->tm_mday) + { + case 31: + case 21: + case 1:th="st";break; + case 22: + case 2:th="nd";break; + case 23: + case 3:th="rd";break; + default:th="th"; + } + to_file(1,"\"%s %i%s, %i at %i:%02i%s\"",month[t->tm_mon],t->tm_mday,th, + t->tm_year + 1900,hourampm[t->tm_hour],t->tm_min,(t->tm_hour <= 11) ? "am" : "pm"); +} + int main(int argc, char **argv) { @@ -494,5 +521,8 @@ int main(int argc, char **argv) if (argv[1] && strcmp(argv[1],"testhelp") == 0) test_help(); + if (argv[1] && strcmp(argv[1],"date") == 0) + datestamp(); + return(0); } diff --git a/src/global.h b/src/global.h index fe76dd5..dfa45d7 100644 --- a/src/global.h +++ b/src/global.h @@ -69,6 +69,11 @@ BEG const char SPYSTR_URL[] MDEF("url"); BEG const char STR_MECHRESET[] MDEF("MECHRESET="); +BEG const char FMT_6XSTRTAB[] MDEF("%s\t%s\t%s\t%s\t%s\t%s"); +#define FMT_4XSTRTAB &FMT_6XSTRTAB[6] +#define FMT_3XSTRTAB &FMT_6XSTRTAB[9] +#define FMT_PLAIN &FMT_6XSTRTAB[15] + BEG Mech *botlist MDEF(NULL); BEG Mech *current; @@ -247,9 +252,9 @@ BEG int uptimeport MDEF(9969); /* proc var */ BEG char *uptimehost MDEF(NULL); /* proc var */ BEG char *uptimenick MDEF(NULL); /* proc var */ BEG int uptimesock; -BEG ulong uptimeip MDEF((ulong)-1); -BEG ulong uptimecookie; -BEG ulong uptimeregnr MDEF(0); +BEG uint32_t uptimeip MDEF((uint32_t)-1); +BEG uint32_t uptimecookie; +BEG uint32_t uptimeregnr MDEF(0); BEG time_t uptimelast MDEF(0); BEG const char *defaultuptimehost MDEF("uptime.energymech.net"); diff --git a/src/h.h b/src/h.h index 6a8e9fd..79e5514 100644 --- a/src/h.h +++ b/src/h.h @@ -161,7 +161,7 @@ void purge_banlist(Chan *); void channel_massmode(const Chan *, char *, int, char, char); void channel_massunban(Chan *, char *, time_t); ChanUser *find_chanuser(Chan *, const char *); -void remove_chanuser(Chan *, char *); +void remove_chanuser(Chan *, const char *); void make_chanuser(char *, char *); void purge_chanusers(Chan *); char *get_nuh(ChanUser *); @@ -198,8 +198,8 @@ Server *find_server(int id); int try_server(Server *sp, char *hostname); void connect_to_server(void); void register_with_server(void); -int sub_compile_timer(int limit, ulong *flags1, ulong *flags2, char *args); -int compile_timer(HookTimer *timer, char *rest); +int sub_compile_timer(int, uint32_t *, uint32_t *, char *); +int compile_timer(HookTimer *, char *); void update(SequenceTime *this); void parse_server_input(void); void do_version(COMMAND_ARGS) __page(CMD1_SEG); @@ -239,7 +239,7 @@ void strflags(char *dst, const DEFstruct *flagsstruct, int flags); const char *strdef(const DEFstruct *dtab, int num); const char *funcdef(const DEFstruct *dtab, void *func); void memreset(void); -void memtouch(void *addr); +void memtouch(const void *addr); const char *proc_lookup(void *addr, int size); char *atime(time_t when); void debug_server(Server *sp, char *pad); @@ -249,7 +249,7 @@ void debug_botinfo(BotInfo *binfo); void debug_botnet(void); void debug_core(void); void debug_rawdns(void); -char *ulong2bin(int limit, ulong x); +char *uint32tobin(int limit, uint32_t x); void debug_scripthook(void); void run_debug(void); int wrap_debug(void); @@ -271,7 +271,7 @@ void select_rawdns(void); void process_rawdns(void); char *poll_rawdns(char *hostname); int read_dnsroot(char *line); -ulong rawdns_get_ip(const char *host); +uint32_t rawdns_get_ip(const char *host); void do_dnsroot(COMMAND_ARGS) __page(CMD1_SEG); void do_dnsserver(COMMAND_ARGS) __page(CMD1_SEG); void do_dns(COMMAND_ARGS) __page(CMD1_SEG); @@ -517,7 +517,7 @@ void parse_346(char *from, char *rest); void parse_348(char *from, char *rest); void parse_368(char *from, char *rest); void parse_005(char *from, char *rest); -ulong stringhash(char *s); +uint32_t stringhash(char *s); void parseline(char *rest); /* partyline.c */ @@ -620,7 +620,7 @@ void do_clearshit(COMMAND_ARGS) __page(CMD1_SEG); /* socket.c */ -LS ulong get_ip(const char *) __page(CORE_SEG); +LS uint32_t get_ip(const char *) __page(CORE_SEG); LS void SockFlags(int) __page(CORE_SEG); LS int SockOpts(void) __page(CORE_SEG); LS int SockListener(int) __page(CORE_SEG); diff --git a/src/kicksay.c b/src/kicksay.c index f57231d..86e67e8 100644 --- a/src/kicksay.c +++ b/src/kicksay.c @@ -164,7 +164,7 @@ void do_kicksay(COMMAND_ARGS) table_buffer("\037channel\037\t\037action\037\t\037string\037\t\037kick reason\037"); for(kick=current->kicklist;kick;kick=kick->next) { - table_buffer("%s\t%s\t%s\t%s",kick->chan,ks_actions[kick->action],kick->mask,kick->reason); + table_buffer(FMT_4XSTRTAB,kick->chan,ks_actions[kick->action],kick->mask,kick->reason); } table_send(from,2); return; diff --git a/src/main.c b/src/main.c index de027ec..2a34670 100644 --- a/src/main.c +++ b/src/main.c @@ -142,7 +142,7 @@ char *randstring(const char *file) LS struct { - ulong sighup:1, + uint32_t sighup:1, sigint:1, sigusr1:1; @@ -985,7 +985,7 @@ int main(int argc, char **argv, char **envp) if (!mechresetenv) { to_file(1,TEXT_HDR_VERS,VERSION,SRCDATE); - to_file(1,TEXT_HDR_DATE); + to_file(1,"Compiled on " GENDATE "\n"); to_file(1,TEXT_HDR_FEAT,__mx_opts); } diff --git a/src/mega.c b/src/mega.c index 315e8f1..d5a1c03 100644 --- a/src/mega.c +++ b/src/mega.c @@ -20,13 +20,13 @@ #include "ctcp.c" #include "debug.c" #include "dns.c" -#include "dynamode.c" #include "function.c" #include "greet.c" #include "help.c" #include "hostinfo.c" #include "irc.c" #include "kicksay.c" +#include "lib/string.c" #include "main.c" #include "net.c" #include "net_chan.c" diff --git a/src/parse.c b/src/parse.c index 22aafc2..05b3d15 100644 --- a/src/parse.c +++ b/src/parse.c @@ -243,7 +243,7 @@ void parse_mode(char *from, char *rest) void parse_notice(char *from, char *rest) { char *ctcp,*to; - ulong pingtime; + uint32_t pingtime; to = chop(&rest); if (*rest == ':') @@ -1375,7 +1375,7 @@ void parse_005(char *from, char *rest) LS const struct { - ulong hash; + uint32_t hash; short flags; void (*func)(char *, char *); @@ -1448,9 +1448,9 @@ LS const struct { 0, 0, NULL } }; -ulong stringhash(char *s) +uint32_t stringhash(char *s) { - ulong hash; + uint32_t hash; int i; hash = 0; @@ -1465,7 +1465,7 @@ void parseline(char *rest) Hook *hook; #endif /* SCRIPTING */ char *from,*command; - ulong cmdhash; + uint32_t cmdhash; int i; if (current->spy & SPYF_RAWIRC) diff --git a/src/prot.c b/src/prot.c index 7e75bd5..27d4539 100644 --- a/src/prot.c +++ b/src/prot.c @@ -184,8 +184,9 @@ int mode_effect(Chan *chan, qMode *mode) void push_modes(Chan *chan, int lowpri) { qMode *mode; + const char *srcparm; char flaglist[32],parmlist[MSGLEN]; - char *dstflag,*dstparm,*srcparm,lastmode; + char *dstflag,*dstparm,lastmode; int n,maxmodes; n = (current->sendq_time - now); @@ -650,7 +651,7 @@ void do_banlist(COMMAND_ARGS) s = "b"; #endif /* NEWBIE */ - table_buffer("%s\t%s\t%s\t%s",to,s,ban->banstring,ban->bannedby); + table_buffer(FMT_4XSTRTAB,to,s,ban->banstring,ban->bannedby); } table_send(from,2); } @@ -661,7 +662,7 @@ void do_banlist(COMMAND_ARGS) { 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_buffer(FMT_3XSTRTAB,to,ban->banstring,ban->bannedby); table_send(from,2); } else diff --git a/src/shit.c b/src/shit.c index dae02ce..7b5ae14 100644 --- a/src/shit.c +++ b/src/shit.c @@ -37,7 +37,8 @@ void shit_action(Chan *chan, ChanUser *cu) { Shit *shit; - char *nick,*fromnick; + const char *nick; + char *fromnick; char *userhost; if (!chan->setting[TOG_SHIT].int_var || !chan->bot_is_op || cu->user) @@ -388,7 +389,7 @@ void do_shitlist(COMMAND_ARGS) table_buffer("\037channel\037\t\037mask\037\t\037action\037\t\037set by\037\t\037reason\037\t\037expires\037"); for(shit=current->shitlist;shit;shit=shit->next) { - table_buffer("%s\t%s\t%s\t%s\t%s\t%s",shit->chan,shit->mask,shit_actions[shit->action], + table_buffer(FMT_6XSTRTAB,shit->chan,shit->mask,shit_actions[shit->action], nickcpy(NULL,shit->from),shit->reason,time2away(shit->expire)); } table_send(from,2); diff --git a/src/socket.c b/src/socket.c index 9d73b51..83fae74 100644 --- a/src/socket.c +++ b/src/socket.c @@ -32,10 +32,10 @@ /* * only include this hack if rawdns isnt compiled in */ -ulong get_ip(const char *host) +uint32_t get_ip(const char *host) { struct hostent *he; - ulong ip; + uint32_t ip; if ((ip = inet_addr(host)) == INADDR_NONE) { @@ -46,7 +46,7 @@ ulong get_ip(const char *host) #endif /* DEBUG */ return(-1); } - ip = (ulong)((struct in_addr*)he->h_addr)->s_addr; + ip = (uint32_t)((struct in_addr*)he->h_addr)->s_addr; } #ifdef DEBUG debug("(get_ip) %s -> %s\n",host,inet_ntoa(*((struct in_addr*)&ip))); diff --git a/src/spy.c b/src/spy.c index 7d5b350..df02080 100644 --- a/src/spy.c +++ b/src/spy.c @@ -163,7 +163,7 @@ void spy_typecount(Mech *bot) struct { const char *idstring; - int typenum; + int typenum; } spy_source_list[] = { @@ -206,7 +206,8 @@ int spy_source(char *from, int *t_src, const char **src) * */ -/*---Help:SPY:[STATUS|MESSAGE|RAWIRC|URL|[guid:|botnick:] [channel|> filename] +/* +help:SPY:[STATUS|MESSAGE|RAWIRC|URL|[guid:|botnick:] [channel|> filename] Spy on a certain source of messages. When you join DCC chat, the STATUS source is added by default as a spy source for you. @@ -253,7 +254,7 @@ void do_spy(COMMAND_ARGS) if (partyline_only_command(from)) return; - table_buffer("\037source\037\t\037target\037"); + table_buffer(str_underline("source") "\t" str_underline("target")); for(spy=current->spylist;spy;spy=spy->next) { switch(spy->t_src) diff --git a/src/stats.c b/src/stats.c index db13635..e186222 100644 --- a/src/stats.c +++ b/src/stats.c @@ -99,7 +99,7 @@ void do_info(COMMAND_ARGS) Chan *chan; char *p; char text[MSGLEN]; - ulong avg; + uint32_t avg; if (current->chanlist == NULL) { diff --git a/src/structs.h b/src/structs.h index 32a0afc..6c0f95d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -25,7 +25,7 @@ typedef union usercombo { struct { - ulong access:8, /* access level (0-200) [0-255] */ + uint32_t access:8, /* access level (0-200) [0-255] */ prot:3, /* protlevel (0-4) [0-7] */ #ifdef BOTNET noshare:1, /* dont share this user over botnet */ @@ -42,7 +42,7 @@ typedef union usercombo aop:1, /* auto-opping */ avoice:1; /* auto-voicing */ } x; - ulong comboflags; + uint32_t comboflags; } usercombo; @@ -50,7 +50,7 @@ typedef struct OnMsg { const char *name; void (*func)(char *, const char *, char *, const int); - ulong defaultaccess:8, /* defaultaccess */ + uint32_t defaultaccess:8, /* defaultaccess */ dcc:1, cc:1, pass:1, @@ -385,7 +385,7 @@ typedef struct Ban time_t time; #ifdef IRCD_EXTENSIONS - ulong imode:1, + uint32_t imode:1, emode:1; #endif /* IRCD_EXTENSIONS */ @@ -440,8 +440,8 @@ typedef struct Chan ChanUser *cacheuser; /* cache for find_chanuser() */ int limit; /* channel limit */ - ulong - bot_is_op:1, /* set if the bot is opped */ + + uint32_t bot_is_op:1, /* set if the bot is opped */ private:1, /* channel mode: +p */ secret:1, /* channel mode: +s */ moderated:1, /* channel mode: +m */ @@ -545,7 +545,7 @@ typedef struct Mech char *userhost; int vhost_type; - ulong reset:1, + uint32_t reset:1, rejoin:1, away:1; @@ -684,7 +684,7 @@ typedef struct BotNet struct { - ulong pta:1, /* plain text auth */ + uint32_t pta:1, /* plain text auth */ sha:1, /* SHA */ md5:1; /* MD5 */ @@ -710,9 +710,8 @@ typedef struct NetCfg struct NetCfg *next; int guid; - ushort port; - - ushort linked:1; + uint16_t port; + uint16_t linked; //:1; char *host; char pass[2]; @@ -749,12 +748,12 @@ typedef struct { time_t last; time_t next; - ulong second1; //:30; - ulong second2; //:30; - ulong minute1; //:30; - ulong minute2; //:30; - ulong hour; //:24; - ulong weekday; //:7; + uint32_t second1; //:30; + uint32_t second2; //:30; + uint32_t minute1; //:30; + uint32_t minute2; //:30; + uint32_t hour; //:24; + uint32_t weekday; //:7; } HookTimer; @@ -805,7 +804,7 @@ typedef struct dnsList struct dnsList *next; time_t when; struct in_addr ip; - ushort id; + uint16_t id; int findauth; dnsAuthority *auth; dnsAuthority *auth2; @@ -816,12 +815,12 @@ typedef struct dnsList typedef struct dnsQuery { - ushort qid; /* query id */ - ushort flags; - ushort questions; - ushort answers; - ushort authorities; - ushort resources; + uint16_t qid; /* query id */ + uint16_t flags; + uint16_t questions; + uint16_t answers; + uint16_t authorities; + uint16_t resources; } dnsQuery; diff --git a/src/text.h b/src/text.h index c99dac0..b062506 100644 --- a/src/text.h +++ b/src/text.h @@ -25,7 +25,13 @@ * These are more or less globally used.. */ +/* #define FMT_PLAIN "%s" +#define FMT_6XSTRTAB "%s\t%s\t%s\t%s\t%s\t%s" +#define FMT_4XSTRTAB "%s\t%s\t%s\t%s" +#define FMT_3XSTRTAB "%s\t%s\t%s" +*/ + #define FMT_PLAINLINE "%s\n" #define MATCH_ALL "*" @@ -62,7 +68,7 @@ #define TEXT_NOTCONNECTED "(not connected)" #define TEXT_WHOMUSERLINE "%s\tu%i\t%s (idle %i min, %i sec)" #define TEXT_WHOMSELFLINE "\037%s\037\t%s\t%s" -#define TEXT_WHOMBOTLINE "%s\t%s\t%s" +#define TEXT_WHOMBOTLINE FMT_3XSTRTAB #define TEXT_WHOMBOTGUID "%s\t%s\t%s [%s] [%i]" /* @@ -142,7 +148,6 @@ #define TEXT_XSWITCH " -X write a debug file before exit\n" #define TEXT_HDR_VERS "EnergyMech %s, %s\n" -#define TEXT_HDR_DATE "Compiled on " __DATE__ " " __TIME__ "\n" #define TEXT_HDR_FEAT "Features: %s\n" #define ERR_MISSINGCONF "init: No configfile specified\n" diff --git a/src/uptime.c b/src/uptime.c index 76ce7e9..9c6c67c 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -38,11 +38,11 @@ typedef struct int regnr; int pid; int type; - ulong cookie; - ulong uptime; - ulong ontime; - ulong now; - ulong sysup; + uint32_t cookie; + uint32_t uptime; + uint32_t ontime; + uint32_t now; + uint32_t sysup; } PackStub; @@ -51,11 +51,11 @@ typedef struct int regnr; int pid; int type; - ulong cookie; - ulong uptime; - ulong ontime; - ulong now; - ulong sysup; + uint32_t cookie; + uint32_t uptime; + uint32_t ontime; + uint32_t now; + uint32_t sysup; char string[512]; } PackUp; @@ -225,7 +225,7 @@ void process_uptime(void) struct { int regnr; - ulong cookie; + uint32_t cookie; } regPack;