From e119860be8601cf31b701eb59816d6e7efa2f087 Mon Sep 17 00:00:00 2001 From: joonicks Date: Mon, 8 Dec 2025 13:51:07 +0100 Subject: [PATCH] cx.now + ipv6 stuff + december sync --- config/inet_addr.c | 13 +++++- configure | 16 ++++++- src/auth.c | 6 +-- src/bounce.c | 14 +++--- src/channel.c | 8 ++-- src/config.h.in | 6 +-- src/core.c | 62 +++++++++++++-------------- src/ctcp.c | 28 ++++++------ src/debug.c | 10 +++-- src/dns.c | 14 +++--- src/function.c | 8 ++-- src/global.h | 15 ++++--- src/help.c | 2 +- src/hostinfo.c | 6 +-- src/io.c | 4 +- src/irc.c | 2 +- src/main.c | 103 +++++++++++++++++++++++++-------------------- src/net.c | 28 ++++++------ src/note.c | 6 +-- src/ons.c | 24 +++++------ src/parse.c | 30 ++++++------- src/partyline.c | 12 +++--- src/prot.c | 24 +++++------ src/reset.c | 6 +-- src/seen.c | 22 +++++----- src/shit.c | 8 ++-- src/spy.c | 18 ++++---- src/structs.h | 9 ++++ src/toybox.c | 24 +++++------ src/uptime.c | 10 ++--- src/user.c | 10 ++--- src/vars.c | 4 +- src/web.c | 2 +- 33 files changed, 302 insertions(+), 252 deletions(-) diff --git a/config/inet_addr.c b/config/inet_addr.c index 1b7b58e..b6f024d 100644 --- a/config/inet_addr.c +++ b/config/inet_addr.c @@ -1,9 +1,20 @@ #include #include -int main(int argc, char **argv) +#include +#include +int main(int argc, char **argv) { struct in_addr ia; ia.s_addr = inet_addr("0.0.0.0"); + if (argc == 2) + { + if (strcmp("safamily",argv[1]) == 0) + printf("%i\n",(int)sizeof(sa_family_t)); + if (strcmp("sockaddr",argv[1]) == 0) + printf("%i\n",(int)sizeof(struct sockaddr_in)); + if (strcmp("sockaddrv6",argv[1]) == 0) + printf("%i\n",(int)sizeof(struct sockaddr_in6)); + } return(0); } diff --git a/configure b/configure index 5bc7e8f..c5bb330 100755 --- a/configure +++ b/configure @@ -25,6 +25,7 @@ install=no silentopt=no try_libmusl=no no_flto=no +use_fnostrictalias=no # default optimization goal, speed = -O2, size = -Os optitype=size @@ -310,6 +311,8 @@ do --no-optimize) cc_optimize_opt=no ;; --optimize=speed) optitype=speed ;; --optimize=size) optitype=size ;; + --use-nostrictalias) use_fnostrictalias=yes ;; + --no-nostrictalias) use_fnostrictalias=no ;; --use-gnudebug) cc_g_opt=yes ;; --no-gnudebug) cc_g_opt=no ;; --use-warnflag) cc_wall_opt=yes ;; @@ -591,7 +594,7 @@ if [ -z "$cf_cflags" -a -n "$cf_GNUCC" ]; then fi fi fi - if [ "$cc_wall_flag" = -Wall -a "$cf_GNUCC" = 33 ]; then + if [ "$use_fnostrictalias" = yes -a "$cc_wall_opt" = -Wall ]; then cc_fnostrictalias="-fno-strict-aliasing" echo $ac_n "-fno-strict-aliasing "$ac_c fi @@ -843,6 +846,17 @@ else fi fi echo $ac_t "$has_inet_addr" +if [ "$has_inet_addr" = no ]; then + echo "error: missing inet_addr(), cant proceed without it." + exit +fi + +echo $ac_n "checking sizeof(sa_family_t) ... "$ac_c +safamily=unknown +if [ -x $TESTP ]; then + safamily=`$TESTP` +fi +echo $ac_t "$safamily" rm -f $TESTP # diff --git a/src/auth.c b/src/auth.c index 4aeb21a..a7f6abc 100644 --- a/src/auth.c +++ b/src/auth.c @@ -259,7 +259,7 @@ void change_authnick(char *nuh, char *newnuh) set_mallocdoer(change_authnick); auth = (Auth*)Calloc(sizeof(Auth) + strlen(newnuh)); auth->user = oldauth->user; - auth->active = now; + auth->active = cx.now; auth->next = current->authlist; current->authlist = auth; stringcpy(auth->nuh,newnuh); @@ -349,7 +349,7 @@ int get_authaccess(const char *userhost, const char *channel) User *user; Strp *ump; - if (userhost == CoreUser.name) + if (userhost == cx.CoreUser.name) return(100); if (CurrentDCC && CurrentDCC->user->name == userhost) { @@ -391,7 +391,7 @@ int make_auth(const char *userhost, const User *user) set_mallocdoer(make_auth); auth = (Auth*)Calloc(sizeof(Auth) + strlen(userhost)); auth->user = (User*)user; - auth->active = now; + auth->active = cx.now; stringcpy(auth->nuh,userhost); auth->next = current->authlist; diff --git a/src/bounce.c b/src/bounce.c index e7e7463..7ccc237 100644 --- a/src/bounce.c +++ b/src/bounce.c @@ -82,7 +82,7 @@ void bounce_parse(ircLink *irc, char *message) if (irc->userLine && irc->nickLine) { to_file(irc->usersock,TEXT_ASK_HANDLE,irc->nick); - irc->active = now; + irc->active = cx.now; ++irc->status; } return; @@ -135,7 +135,7 @@ void bounce_parse(ircLink *irc, char *message) { to_file(irc->usersock,TEXT_ASK_SERVER,irc->nick); irc->status = BNC_ASK_SERVER; - irc->active = now; + irc->active = cx.now; return; } } @@ -176,7 +176,7 @@ void bounce_parse(ircLink *irc, char *message) if ((irc->servsock = SockConnect(server,iport,USE_VHOST)) >= 0) { irc->status = BNC_CONNECTING; - irc->active = now + 60; /* 120 second timeout */ + irc->active = cx.now + 60; /* 120 second timeout */ } } } @@ -249,7 +249,7 @@ void process_bounce(void) irc = (ircLink*)Calloc(sizeof(ircLink)); /* sets all to zero */ irc->next = bnclist; bnclist = irc; - irc->active = now; + irc->active = cx.now; irc->usersock = s; --irc->servsock; /* == -1 */ } @@ -297,7 +297,7 @@ void process_bounce(void) debug("(process_bounce) {%i} servsock connected\n",irc->servsock); #endif /* DEBUG */ irc->status = BNC_ACTIVE; - irc->active = now; + irc->active = cx.now; to_file(irc->servsock,"USER %s\n",irc->userLine); if (to_file(irc->servsock,"NICK %s\n",irc->nickLine) < 0) { @@ -314,7 +314,7 @@ void process_bounce(void) */ if (FD_ISSET(irc->servsock,&read_fds)) { - irc->active = now; + irc->active = cx.now; while((p = sockread(irc->servsock,irc->servmem,message))) { if (to_file(irc->usersock,FMT_PLAINLINE,message) < 0) @@ -338,7 +338,7 @@ void process_bounce(void) pp = &bnclist; while((irc = *pp)) { - if (irc->status == BNC_DEAD || ((irc->status != BNC_ACTIVE) && ((now - irc->active) > 60))) + if (irc->status == BNC_DEAD || ((irc->status != BNC_ACTIVE) && ((cx.now - irc->active) > 60))) { #ifdef DEBUG debug("(process_bounce) {%i} {%i} BNC_DEAD or timeout, removing...\n",irc->usersock,irc->servsock); diff --git a/src/channel.c b/src/channel.c index 4ab6c73..03f46bd 100644 --- a/src/channel.c +++ b/src/channel.c @@ -45,7 +45,7 @@ void check_idlekick(void) limit = chan->setting[INT_IKT].int_var; if (limit == 0) continue; - timeout = (now - (60 * limit)); + timeout = (cx.now - (60 * limit)); for(cu=chan->users;cu;cu=cu->next) { cu->flags &= ~CU_KSWARN; /* remove KS warnings */ @@ -537,7 +537,7 @@ void channel_massunban(Chan *chan, char *pattern, time_t seconds) { if (!matches(pattern,ban->banstring) || !matches(ban->banstring,pattern)) { - if (!seconds || ((now - ban->time) > seconds)) + if (!seconds || ((cx.now - ban->time) > seconds)) { if (chan->setting[TOG_SHIT].int_var) { @@ -681,7 +681,7 @@ void make_chanuser(char *nick, char *userhost) new = (ChanUser*)Calloc(sizeof(ChanUser) + strlen(userhost)); /* Calloc sets it all to zero */ - new->idletime = now; + new->idletime = cx.now; new->next = CurrentChan->users; CurrentChan->users = new; stringcpy(new->userhost,userhost); @@ -1218,7 +1218,7 @@ void do_showidle(COMMAND_ARGS) table_buffer(str_underline("Users on %s that are idle more than %i seconds"),chan->name,n); for(cu=chan->users;cu;cu=cu->next) { - if (n >= (now - cu->idletime)) + if (n >= (cx.now - cu->idletime)) continue; table_buffer("%s\r %s\t%s",idle2str(cu->idletime,TRUE),cu->nick,cu->userhost); } diff --git a/src/config.h.in b/src/config.h.in index 53f6f14..c33f102 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -97,7 +97,7 @@ @DEF_DCCFILE@ #define DCC_PUBLICFILES "public/" #define DCC_PUBLICINCOMING DCC_PUBLICFILES "incoming/" -#define DCC_FILETIMEOUT 90 +#define DCCFILE_TIMEOUT 90 /* * REDIRECT: send command output from certain commands to a different target @@ -316,8 +316,8 @@ #define AWAYFORM "AWAY :%s (since %s)\n" -#define KILLSOCKTIMEOUT 30 -#define WAITTIMEOUT 30 +#define KILLSOCK_TIMEOUT 30 +#define WAIT_TIMEOUT 30 #define NICKFLOODTIME 120 /* 240 second window for floods ( 240 / 2 = 120 ) */ diff --git a/src/core.c b/src/core.c index 5670054..ea7f621 100644 --- a/src/core.c +++ b/src/core.c @@ -41,7 +41,7 @@ int conf_callback(char *line) fix_config_line(line); - on_msg((char*)CoreUser.name,getbotnick(current),line); + on_msg((char*)cx.CoreUser.name,getbotnick(current),line); return(FALSE); } @@ -79,7 +79,7 @@ void readcfgfile(void) CurrentShit = NULL; CurrentChan = NULL; CurrentDCC = (Client*)&CoreClient; - CurrentUser = (User*)&CoreUser; + CurrentUser = (User*)&cx.CoreUser; readline(in,&conf_callback); /* readline closes in */ @@ -527,7 +527,7 @@ int try_server(Server *sp, char *hostname) hostname = sp->name; } - sp->lastattempt = now; + sp->lastattempt = cx.now; sp->usenum++; #ifdef RAWDNS @@ -544,7 +544,7 @@ int try_server(Server *sp, char *hostname) { current->server = sp->ident; current->connect = CN_DNSLOOKUP; - current->conntry = now; + current->conntry = cx.now; rawdns(hostname); return(0); } @@ -557,7 +557,7 @@ int try_server(Server *sp, char *hostname) } current->away = FALSE; current->connect = CN_TRYING; - current->activity = current->conntry = now; + current->activity = current->conntry = cx.now; *current->modes = 0; return(current->sock); } @@ -572,7 +572,7 @@ void connect_to_server(void) * This should prevent the bot from chewing up too * much CPU when it fails to connect to ANYWHERE */ - current->conntry = now; + current->conntry = cx.now; /* * Is this the proper action if there is no serverlist? @@ -623,7 +623,7 @@ void connect_to_server(void) sptry = NULL; for(sp=serverlist;sp;sp=sp->next) { - if (sp->lastattempt == now) + if (sp->lastattempt == cx.now) continue; if (sgroup && (stringcasecmp(sgroup,sp->group) != 0)) continue; @@ -633,8 +633,8 @@ void connect_to_server(void) if (sp->err == 0 || sp->err == SP_ERRCONN) sptry = sp; else - if ((sp->err == SP_THROTTLED && (sp->lastattempt + 45) < now) || /* retry throttled after 45 seconds */ - (sp->err == SP_KLINED && (sp->lastattempt + 86400) < now)) /* retry Klined after a day */ + if ((sp->err == SP_THROTTLED && (sp->lastattempt + 45) < cx.now) || /* retry throttled after 45 seconds */ + (sp->err == SP_KLINED && (sp->lastattempt + 86400) < cx.now)) /* retry Klined after a day */ sptry = sp; } /* @@ -689,7 +689,7 @@ void register_with_server(void) (ident) ? ident : BOTLOGIN, (ircname) ? ircname : VERSION); current->connect = CN_CONNECTED; - current->conntry = now; + current->conntry = cx.now; } /* @@ -807,7 +807,7 @@ typedef struct //using that struct, calculate when the next time will be //start by determining what the time is now - thistime = now; + thistime = cx.now; //which second is it thissecond = thistime % 60; @@ -886,19 +886,19 @@ void update(SequenceTime *this) int tt,th; int x,n; - tt = now / 600; /* current 10-minute period */ - th = tt / 6; /* current hour */ + tt = cx.now / 600; /* current 10-minute period */ + th = tt / 6; /* current hour */ #ifdef DEBUG x = 0; if (tt != this->tenminute) { - debug("(update) running: ten minute updates [%i]",tt); + debug("(update) running: ten minute update [%i]",tt); x++; } if (th != this->hour) { - debug("%shour updates [%i]",(x) ? ", " : "(update) running: ",th); + debug("%shour update [%i]",(x) ? ", " : "(update) running: ",th); x++; } if (x) @@ -913,10 +913,10 @@ void update(SequenceTime *this) if (current->rejoin) { - if ((now - current->lastrejoin) > REJOIN_DELAY) + if ((cx.now - current->lastrejoin) > REJOIN_DELAY) { current->rejoin = FALSE; - current->lastrejoin = now; + current->lastrejoin = cx.now; } cx.short_tv |= TV_REJOIN; } @@ -957,18 +957,18 @@ void update(SequenceTime *this) check_dynamode(chan); #endif /* DYNAMODE */ } - if ((now - current->lastreset) > RESETINTERVAL) + if ((cx.now - current->lastreset) > RESETINTERVAL) { - current->lastreset = now; + current->lastreset = cx.now; if (stringcmp(getbotnick(current),getbotwantnick(current))) to_server("NICK %s\n",getbotwantnick(current)); check_idlekick(); if ((x = current->setting[INT_AAWAY].int_var) && current->away == FALSE) { - if ((now - current->activity) > (x * 60)) + if ((cx.now - current->activity) > (x * 60)) { temp = randstring(AWAYFILE); - to_server(AWAYFORM,(temp && *temp) ? temp : "auto-away",maketimestr(now,TFMT_AWAY)); + to_server(AWAYFORM,(temp && *temp) ? temp : "auto-away",maketimestr(cx.now,TFMT_AWAY)); current->away = TRUE; } } @@ -1085,7 +1085,7 @@ void process_server_input(void) current->vhost_type |= VH_WINGATE_FAIL; } current->connect = CN_WINGATEWAIT; - current->conntry = now; + current->conntry = cx.now; current->heartbeat = 0; return; } @@ -1119,7 +1119,7 @@ get_line: } } #endif /* WINGATE */ - current->conntry = now; + current->conntry = cx.now; current->heartbeat = 0; parse_server_input(linebuf); goto get_line; @@ -1135,7 +1135,7 @@ get_line: } /* server has been quiet for too long */ - if (current->conntry + SERVERSILENCETIMEOUT <= now && current->heartbeat == 0) + if (current->conntry + SERVERSILENCETIMEOUT <= cx.now && current->heartbeat == 0) { #ifdef DEBUG debug("[PSI] {%i} server has been quiet for too long (%is)...\n",current->sock,SERVERSILENCETIMEOUT); @@ -1146,7 +1146,7 @@ get_line: } /* server has been quiet for WAY too long */ - if (current->conntry + (SERVERSILENCETIMEOUT*2) <= now) + if (current->conntry + (SERVERSILENCETIMEOUT*2) <= cx.now) { #ifdef DEBUG debug("[PSI] {%i} server has been quiet for WAY too long (%is), forcing reconnect...\n",current->sock,SERVERSILENCETIMEOUT*2); @@ -1283,7 +1283,7 @@ void do_core(COMMAND_ARGS) if (uname(&un) == 0) table_buffer(TEXT_HOSTINFO,h,un.sysname,un.release,un.machine); #endif /* HOSTINFO */ - table_buffer(TEXT_CURRENTTIME,maketimestr(now,TFMT_FULL)); + table_buffer(TEXT_CURRENTTIME,maketimestr(cx.now,TFMT_FULL)); table_buffer(TEXT_BOTSTARTED,maketimestr(uptime,TFMT_FULL)); table_buffer(TEXT_BOTUPTIME,idle2str(uptime,FALSE)); table_buffer(TEXT_BOTVERSION,VERSION,SRCDATE); @@ -1527,7 +1527,7 @@ do_server_einval: return; } sp = add_server(server,iport,pass,group); /* add_server has no failure mode */ - if (add_or_sub == '+' || from == CoreUser.name) + if (add_or_sub == '+' || from == cx.CoreUser.name) return; current->nextserver = sp->ident; @@ -1564,10 +1564,10 @@ void do_away(COMMAND_ARGS) to_server("AWAY\n"); to_user(from,TEXT_NOLONGERAWAY); current->away = FALSE; - current->activity = now; + current->activity = cx.now; return; } - to_server(AWAYFORM,rest,maketimestr(now,TFMT_AWAY)); + to_server(AWAYFORM,rest,maketimestr(cx.now,TFMT_AWAY)); to_user(from,TEXT_NOWSETAWAY); current->away = TRUE; } @@ -1622,7 +1622,7 @@ void do_nick(COMMAND_ARGS) current = add_bot(guid,nick); if (!sigmaster) sigmaster = guid; - if (from == CoreUser.name) + if (from == cx.CoreUser.name) return; } else @@ -1640,7 +1640,7 @@ void do_nick(COMMAND_ARGS) void do_time(COMMAND_ARGS) { - to_user_q(from,"Current time: %s",maketimestr(now,TFMT_AWAY)); + to_user_q(from,"Current time: %s",maketimestr(cx.now,TFMT_AWAY)); } void do_upontime(COMMAND_ARGS) diff --git a/src/ctcp.c b/src/ctcp.c index ef3e00e..5abbae9 100644 --- a/src/ctcp.c +++ b/src/ctcp.c @@ -128,7 +128,7 @@ int dcc_sendfile(char *target, char *filename) client->sock = s; client->user = NULL; client->flags = DCC_WAIT|DCC_ASYNC|DCC_SEND; - client->lasttime = now; + client->lasttime = cx.now; client->whom = stringcpy(client->filename,filename) + 1; stringcpy(client->whom,target); @@ -216,7 +216,7 @@ void parse_dcc(Client *client) else { client->flags = DCC_SEND; - client->start = now; + client->start = cx.now; dcc_pushfile(client,0); } #endif /* DCC_FILE */ @@ -250,7 +250,7 @@ void parse_dcc(Client *client) if (write(client->sock,&where,4) == -1) return; - client->lasttime = now; + client->lasttime = cx.now; if (oc == client->fileend) { @@ -266,7 +266,7 @@ void parse_dcc(Client *client) { uint32_t where; - client->lasttime = now; + client->lasttime = cx.now; s = client->inputcount; oc = read(client->sock,(client->sockdata+s),(4-s)); if ((oc < 1) && (errno != EINTR) && (errno != EAGAIN)) @@ -319,7 +319,7 @@ void parse_dcc(Client *client) /* * DCC input flood protection */ - s = now - client->lasttime; + s = cx.now - client->lasttime; if (s > 10) { client->inputcount = strlen(ptr); @@ -338,7 +338,7 @@ void parse_dcc(Client *client) */ CurrentShit = NULL; CurrentChan = NULL; - client->lasttime = now; + client->lasttime = cx.now; CurrentDCC = client; CurrentUser = client->user; stringcpy(CurrentNick,CurrentUser->name); @@ -390,7 +390,7 @@ void process_dcc(void) partyline_banner(client); } else - if ((client->flags & DCC_WAIT) && ((now - client->lasttime) >= WAITTIMEOUT)) + if ((client->flags & DCC_WAIT) && ((cx.now - client->lasttime) >= WAIT_TIMEOUT)) { #ifdef DEBUG debug("(process_dcc) connection timed out (%s)\n", @@ -400,7 +400,7 @@ void process_dcc(void) } #ifdef DCC_FILE else - if ((client->flags & DCC_SEND) && ((now - client->lasttime) >= DCC_FILETIMEOUT)) + if ((client->flags & DCC_SEND) && ((cx.now - client->lasttime) >= DCCFILE_TIMEOUT)) { #ifdef DEBUG debug("(process_dcc) {%i} DCC %s stalled (%s), closing connection\n", @@ -412,7 +412,7 @@ void process_dcc(void) #endif /* DCC_FILE */ #ifdef TELNET else - if ((client->flags & DCC_TELNETPASS) && ((now - client->lasttime) >= TELNET_TIMEOUT)) + if ((client->flags & DCC_TELNETPASS) && ((cx.now - client->lasttime) >= TELNET_TIMEOUT)) { client->flags = DCC_DELETE; } @@ -529,7 +529,7 @@ void ctcp_dcc(char *from, char *to, char *rest) client->fileend = filesz; client->sock = s; client->flags = DCC_WAIT|DCC_SEND|DCC_RECV; - client->lasttime = client->start = now; + client->lasttime = client->start = cx.now; client->whom = stringcpy(client->filename,filename) + 1; stringcpy(client->whom,from); @@ -588,7 +588,7 @@ void ctcp_dcc(char *from, char *to, char *rest) client->sock = x; client->user = user; client->flags = DCC_WAIT|DCC_ASYNC; - client->lasttime = now; + client->lasttime = cx.now; client->next = current->clientlist; current->clientlist = client; } @@ -732,9 +732,9 @@ void on_ctcp(char *from, char *to, char *rest) { for(mul=0;mulname == C_PING || !stringcasecmp(rest,"PING")) { - to_server("PRIVMSG %s :\001PING %lu\001\n",target,now); + to_server("PRIVMSG %s :\001PING %lu\001\n",target,cx.now); return; } if (*rest) diff --git a/src/debug.c b/src/debug.c index 93c524e..7579de0 100644 --- a/src/debug.c +++ b/src/debug.c @@ -36,6 +36,8 @@ #define boolstr(x) (x) ? "TRUE" : "FALSE" +#define UNKNOWNSTR "(unknown)" + const char tabs[20] = "\t\t\t\t\t\t\t\t\t\t"; const struct @@ -245,7 +247,7 @@ struct #ifdef URLCAPTURE { urlcapture, "urlcapture" CORE_SE }, #endif /* URLCAPTURE */ -{ 0, "(unknown)" }, +{ 0, UNKNOWNSTR }, { NULL, }}; #ifdef HOSTINFO @@ -406,7 +408,7 @@ const char *strdef(const DEFstruct *dtab, int num) if (dtab[i].id == num) return(dtab[i].idstr); } - return("UNKNOWN"); + return(UNKNOWNSTR); } void memreset(void) @@ -458,7 +460,7 @@ const char *proc_getname(void *addr) if (ProcList[i].func == addr) return(ProcList[i].name); } - return("(unknown)"); + return(UNKNOWNSTR); } const char *proc_lookup(void *addr, int size) @@ -1422,7 +1424,7 @@ int wrap_debug(void) backup_dodebug = dodebug; backup_fd = debug_fd; - sprintf(fname,"debug.%lu",now); + sprintf(fname,"debug.%lu",cx.now); if ((fd = open(fname,O_WRONLY|O_CREAT|O_TRUNC,NEWFILEMODE)) < 0) return(0); debug_fd = fd; diff --git a/src/dns.c b/src/dns.c index 7765aa7..353ea39 100644 --- a/src/dns.c +++ b/src/dns.c @@ -289,7 +289,7 @@ void parse_query(int psz, dnsQuery *query) #endif /* DEBUG */ if (dns->cname) Free((char**)&dns->cname); - dns->when = now + 30; + dns->when = cx.now + 30; set_mallocdoer(parse_query); dns->cname = stringdup(token2); } @@ -302,7 +302,7 @@ void parse_query(int psz, dnsQuery *query) if (dns->auth && !stringcasecmp(dns->auth->hostname,token)) { dns->auth->ip.s_addr = ip->s_addr; - dns->when = now + 60; + dns->when = cx.now + 60; #ifdef DEBUG debug("(parse_query) a auth: %s = %s\n",token,inet_ntoa(*ip)); #endif /* DEBUG */ @@ -311,7 +311,7 @@ void parse_query(int psz, dnsQuery *query) if (!stringcasecmp(dns->host,token) || (dns->cname && !stringcasecmp(dns->cname,token))) { dns->ip.s_addr = ip->s_addr; - dns->when = now + 3600; + dns->when = cx.now + 3600; #ifdef DEBUG debug("(parse_query) a: %s = %s\n",token,inet_ntoa(*ip)); #endif /* DEBUG */ @@ -515,7 +515,7 @@ void parse_query(int psz, dnsQuery *query) debug("(parse_query) %i: asking %s who is `%s'\n",dns->id,inet_ntoa(sai.sin_addr),src); #endif /* DEBUG */ sz = make_query(packet,src); - dns->when = now + 60; + dns->when = cx.now + 60; sai.sin_family = AF_INET; sai.sin_port = htons(53); ((dnsQuery*)packet)->qid = htons(dns->id); @@ -539,7 +539,7 @@ void parse_query(int psz, dnsQuery *query) debug("(parse_query) %i: asking %s who is `%s' (CNAME question)\n",dns->id,inet_ntoa(sai.sin_addr),dns->cname); #endif /* DEBUG */ sz = make_query(packet,dns->cname); - dns->when = now + 60; + dns->when = cx.now + 60; sai.sin_family = AF_INET; sai.sin_port = htons(53); ((dnsQuery*)packet)->qid = htons(dns->id); @@ -572,7 +572,7 @@ void rawdns(const char *hostname) item = (dnsList*)Calloc(sizeof(dnsList) + strlen(hostname)); stringcpy(item->host,hostname); item->id = ntohs(query->qid); - item->when = now + 30; + item->when = cx.now + 30; item->next = dnslist; dnslist = item; @@ -611,7 +611,7 @@ restart: pdns = &dnslist; while(*pdns) { - if ((*pdns)->when < now) + if ((*pdns)->when < cx.now) { dns = *pdns; if (dns->cname) diff --git a/src/function.c b/src/function.c index bbf09d7..560916e 100644 --- a/src/function.c +++ b/src/function.c @@ -92,7 +92,7 @@ void *Calloc(int size) exit(1); } mmep->size = size; - mmep->when = now; + mmep->when = cx.now; mmep->doer = mallocdoer; mallocdoer = NULL; return((void*)mmep->area+4); @@ -405,7 +405,7 @@ char *idle2str(time_t when, int small) char *dst; int n,z[4]; - when = now - when; + when = cx.now - when; z[0] = when / 86400; z[1] = (when -= z[0] * 86400) / 3600; @@ -942,11 +942,11 @@ int main(int argc, char **argv, char **envp) debug("testpath %s -> result %s\n",argv[1],(r) ? "TRUE" : "FALSE"); } - time(&now); + time(&cx.now); for(r=0;r<10;r++) { - when = now - (int[]){100000,888,534569,999999,99,9000,84600,7777777,56565656+3600,78987654}[r]; + when = cx.now - (int[]){100000,888,534569,999999,99,9000,84600,7777777,56565656+3600,78987654}[r]; debug("\nmaketimestr %s\n",maketimestr(when,TFMT_LOG)); debug("maketimestr %s\n",maketimestr(when,TFMT_FULL)); debug("maketimestr %s\n",maketimestr(when,TFMT_AWAY)); diff --git a/src/global.h b/src/global.h index 5603241..d280eaf 100644 --- a/src/global.h +++ b/src/global.h @@ -44,16 +44,22 @@ struct CoreData /* Collect core data all in one place */ time_t now; time_t system_uptime; Mech *current; + char *from; + char *to; + char *rest; char *rest_end; char *chop_end; + sai_v4 myip4; /* where to reach me by ipv4 */ + sai_v6 myip6; /* where to reach me by ipv4 */ int socksmodified; int hisock; int short_tv; + User CoreUser; + User LocalBot; }; BEG struct CoreData cx; -#define now cx.now #define current cx.current #define DEFAULTCMDCHAR '-' @@ -130,9 +136,6 @@ BEG const OnMsg *CurrentCmd MDEF(NULL); BEG User *cfgUser MDEF(NULL); BEG const char *global_from MDEF(NULL); -BEG User __internal_users[2]; -#define CoreUser (__internal_users[0]) -#define LocalBot (__internal_users[1]) /* * generic output buffer, can be used as buffer in any `leaf' function @@ -458,7 +461,7 @@ const Strp CMA = ShortClient CoreClient = { NULL, /* next */ - (User*)&CoreUser, /* user */ + (User*)&cx.CoreUser, /* user */ -1, /* socket */ 0, /* flags */ 0, /* inputcount */ @@ -489,8 +492,6 @@ struct extern const uchar tolowertab[]; extern const uchar nickcmptab[]; extern const uchar attrtab[]; -extern const User xxCoreUser; -extern const User xxLocalBot; extern ShortClient CoreClient; extern ShortChan CoreChan; diff --git a/src/help.c b/src/help.c index 1136bfa..f1ac0e9 100644 --- a/src/help.c +++ b/src/help.c @@ -229,7 +229,7 @@ void usage_command(char *to, const char *arg) char *pt; int i; - if (to == CoreUser.name) /* dont send usage notices to config file */ + if (to == cx.CoreUser.name) /* dont send usage notices to config file */ return; for(i=0;ulist[i].command;i++) { diff --git a/src/hostinfo.c b/src/hostinfo.c index 35e0667..5f49cec 100644 --- a/src/hostinfo.c +++ b/src/hostinfo.c @@ -79,7 +79,7 @@ int monitor_fs(const char *file) set_mallocdoer(monitor_fs); fnew = Calloc(sizeof(FileMon) + strlen(file)); fnew->fd = ino; - fnew->nospam = now; + fnew->nospam = cx.now; stringcpy(fnew->filename,file); fnew->next = filemonlist; @@ -254,9 +254,9 @@ void process_monitor(void) #endif /* DEBUG */ if ((ivent->mask & IN_CLOSE_WRITE) == IN_CLOSE_WRITE) return; - if (fmon->nospam > now-30) + if (fmon->nospam > (cx.now - 30)) return; - fmon->nospam = now; + fmon->nospam = cx.now; send_global(SPYSTR_SYSMON,"Alert: file ``%s'' was touched",fmon->filename); } } diff --git a/src/io.c b/src/io.c index 3539602..32db75e 100644 --- a/src/io.c +++ b/src/io.c @@ -679,7 +679,7 @@ int killsock(int sock) { set_mallocdoer(killsock); ks = (KillSock*)Calloc(sizeof(KillSock)); - ks->time = now; + ks->time = cx.now; ks->sock = sock; ks->next = killsocks; killsocks = ks; @@ -731,7 +731,7 @@ int killsock(int sock) if ((n == 0) || ((n == -1) && (errno != EAGAIN))) remove_ks(ks); } - if ((now - ks->time) > KILLSOCKTIMEOUT) + if ((cx.now - ks->time) > KILLSOCK_TIMEOUT) remove_ks(ks); ks = ksnext; } diff --git a/src/irc.c b/src/irc.c index 14681af..fe413c4 100644 --- a/src/irc.c +++ b/src/irc.c @@ -40,7 +40,7 @@ void make_ireq(int t, const char *from, const char *nick) ir = (IReq*)Calloc(sizeof(IReq) + StrlenX(from,nick,NULL)); /* can not use Strlen2() if 2nd arg might be NULL, StrlenX() handles NULLs. */ ir->t = t; - ir->when = now; + ir->when = cx.now; pt = stringcat(ir->from,from) + 1; if (nick) diff --git a/src/main.c b/src/main.c index 93cc691..d321b68 100755 --- a/src/main.c +++ b/src/main.c @@ -209,7 +209,7 @@ struct int sig_hup_callback(char *line) { - on_msg((char*)CoreUser.name,getbotnick(current),line); + on_msg((char*)cx.CoreUser.name,getbotnick(current),line); return(FALSE); } @@ -221,7 +221,7 @@ void do_sighup(void) CurrentShit = NULL; CurrentChan = NULL; - CurrentUser = (User*)&CoreUser; + CurrentUser = (User*)&cx.CoreUser; CurrentDCC = (Client*)&CoreClient; *CurrentNick = 0; @@ -321,7 +321,7 @@ void sig_usr1(int crap) */ void sig_usr2(int crap) { - time(&now); + time(&cx.now); debug("(sigusr2)\n"); signal(SIGUSR2,sig_usr2); @@ -420,7 +420,7 @@ void sig_abrt(int crap) */ void sig_bus(int crap) { - time(&now); + time(&cx.now); respawn++; if (respawn > 10) @@ -438,27 +438,42 @@ void sig_bus(int crap) /* * SIGSEGV shows no mercy, cant schedule it. */ -#if defined(__linux__) && defined(__x86_64__) && defined(DEBUG) && !defined(__STRICT_ANSI__) +#if defined(__linux__) && defined(DEBUG) && !defined(__STRICT_ANSI__) #include -void sig_segv(int crap, siginfo_t *si, void *uap) +void sig_segv(int sig, siginfo_t *si, void *context) { - mcontext_t *mctx; - greg_t *rsp,*rip; /* general registers */ + ucontext_t *crashcontext = (ucontext_t*)context; + char *sp,*ip; /* general registers */ - time(&now); startup = STARTUP_SIGSEGV; - debug("(sigsegv) trying to access "mx_pfmt"\n",(mx_ptr)si->si_addr); - mctx = &((ucontext_t *)uap)->uc_mcontext; - rsp = &mctx->gregs[15]; /* RSP, 64-bit stack pointer */ - rip = &mctx->gregs[16]; /* RIP, 64-bit instruction pointer */ +#if defined(__x86_64__) + ip = (char*)crashcontext->uc_mcontext.gregs[16]; + sp = (char*)crashcontext->uc_mcontext.gregs[15]; +#elif defined(__i386__) + void *ip = (void*)crashcontext->uc_mcontext.gregs[REG_EIP]; + void *sp = (void*)crashcontext->uc_mcontext.gregs[REG_ESP]; +#elif defined(__aarch64__) + void *ip = (void*)uc->uc_mcontext.pc; + void *sp = (void*)uc->uc_mcontext.sp; +#elif defined(__arm__) + void *pc = (void*)uc->uc_mcontext.arm_pc; + void *sp = (void*)uc->uc_mcontext.arm_sp; +#elif defined(__mips__) + void *pc = (void*)uc->uc_mcontext.pc; + void *sp = (void*)uc->uc_mcontext.gregs[29]; +#else +#error "sig_segv(): Unsupported architecture" +#endif - debug("(sigsegv) Stack pointer: "mx_pfmt", Instruction pointer: "mx_pfmt"\n",(mx_ptr)*rsp,(mx_ptr)*rip); + debug("(sigsegv) trying to access "mx_pfmt"\n",(mx_ptr)si->si_addr); + debug("(sigsegv) Stack pointer: "mx_pfmt", Instruction pointer: "mx_pfmt"\n",(mx_ptr)sp,(mx_ptr)ip); debug("(sigsegv) sig_segv() = "mx_pfmt"\n",(mx_ptr)sig_segv); debug("(sigsegv) do_crash() = "mx_pfmt"\n",(mx_ptr)do_crash); if (debug_on_exit) { + time(&cx.now); run_debug(); debug_on_exit = FALSE; } @@ -472,11 +487,11 @@ void sig_segv(int crap, siginfo_t *si, void *uap) /* NOT REACHED */ } -#else /* defined(__linux__) && defined(__x86_64__) && defined(DEBUG) && !defined(__STRICT_ANSI__) */ +#else /* defined(__linux__) && defined(DEBUG) && !defined(__STRICT_ANSI__) */ void sig_segv(int signum) { - time(&now); + startup = STARTUP_SIGSEGV; #ifdef DEBUG if (debug_on_exit) @@ -495,7 +510,7 @@ void sig_segv(int signum) /* NOT REACHED */ } -#endif /* else defined(__linux__) && defined(__x86_64__) && defined(DEBUG) && !defined(__STRICT_ANSI__) */ +#endif /* else defined(__linux__) && defined(DEBUG) && !defined(__STRICT_ANSI__) */ /* * SIGTERM @@ -506,8 +521,6 @@ void sig_term(int signum) exit(0); #endif /* __profiling__ */ - time(&now); - #ifdef DEBUG debug("(sigterm)\n"); #endif /* DEBUG */ @@ -532,13 +545,13 @@ void mainloop(void) time_t last_update; - last_update = now; + last_update = cx.now; /* * init update times so that they dont all run right away */ - this.tenminute = now / 600; - this.hour = now / 3600; + this.tenminute = cx.now / 600; + this.hour = cx.now / 3600; /* * The Main Loop @@ -564,9 +577,9 @@ mainloop: /* * check for regular updates */ - if (last_update != now) + if (last_update != cx.now) { - last_update = now; + last_update = cx.now; update(&this); } @@ -610,7 +623,7 @@ mainloop: if ((sp = find_server(current->server))) { - if ((now - current->conntry) > ctimeout) + if ((cx.now - current->conntry) > ctimeout) { #ifdef DEBUG debug("(doit) RAWDNS timed out (%s)\n",sp->name); @@ -636,27 +649,27 @@ mainloop: { if (current->connect == CN_SPINNING) { - if ((now - current->conntry) >= 60) + if ((cx.now - current->conntry) >= 60) connect_to_server(); } else { doit_jumptonext: cx.short_tv |= TV_SERVCONNECT; - if ((now - current->conntry) >= 2) + if ((cx.now - current->conntry) >= 2) connect_to_server(); } } #else /* ! RAWDNS */ if (current->connect == CN_SPINNING) { - if ((now - current->conntry) >= 60) + if ((cx.now - current->conntry) >= 60) connect_to_server(); } else { cx.short_tv |= TV_SERVCONNECT; - if ((now - current->conntry) >= 2) + if ((cx.now - current->conntry) >= 2) connect_to_server(); } #endif /* RAWDNS */ @@ -676,7 +689,7 @@ doit_jumptonext: if ((current->connect == CN_TRYING) || (current->connect == CN_CONNECTED)) { cx.short_tv |= TV_SERVCONNECT; - if ((now - current->conntry) > ctimeout) + if ((cx.now - current->conntry) > ctimeout) { #ifdef DEBUG debug("(doit) {%i} Connection timed out\n",current->sock); @@ -756,7 +769,7 @@ restart_dcc: /* * Update current time */ - time(&now); + time(&cx.now); for(current=botlist;current;current=current->next) { @@ -765,8 +778,8 @@ restart_dcc: * it is important that the check is done before anything * else that could potentially send output to the server! */ - if (current->sendq_time < now) - current->sendq_time = now; + if (current->sendq_time < cx.now) + current->sendq_time = cx.now; } for(current=botlist;current;current=current->next) @@ -796,10 +809,10 @@ restart_dcc: */ if (current->setting[TOG_NOIDLE].int_var) { - if ((now - current->lastantiidle) > PINGSENDINTERVAL) + if ((cx.now - current->lastantiidle) > PINGSENDINTERVAL) { to_server("PRIVMSG * :0\n"); - current->lastantiidle = now; + current->lastantiidle = cx.now; } } /* @@ -829,7 +842,7 @@ restart_dcc: /* * the un-important sendq only sends when sendq_time <= now */ - if ((current->sendq) && (current->sendq_time <= now)) + if ((current->sendq) && (current->sendq_time <= cx.now)) { qm = current->sendq; to_server(FMT_PLAINLINE,qm->p); @@ -890,7 +903,7 @@ restart_die: #endif #ifdef TRIVIA - if (triv_next_time && (now >= triv_next_time)) + if (triv_next_time && (cx.now >= triv_next_time)) trivia_tick(); #endif /* TRIVIA */ @@ -918,8 +931,9 @@ void parse_commandline(int argc, char **argv, char **envp) #ifdef NEWBIE int n = 0; #endif + memset(&cx,0,sizeof(cx)); - uptime = time(&now); + uptime = time(&cx.now); startup = STARTUP_NORMALSTART; if ((getuid() == 0) || (geteuid() == 0)) @@ -936,7 +950,7 @@ void parse_commandline(int argc, char **argv, char **envp) cx.system_uptime = st.st_ctime; } - srand(now+getpid()); + srand(cx.now + getpid()); /* * Code to detect and recover after a RESET @@ -1158,11 +1172,10 @@ void parse_commandline(int argc, char **argv, char **envp) ia_default.s_addr = LOCALHOST_ULONG; #endif /* RAWDNS */ - memset(&__internal_users,0,sizeof(User)*2); - CoreUser.x.x.access = 100; - LocalBot.x.x.access = 200; - LocalBot.x.x.aop = 1; - LocalBot.chan = CoreUser.chan = (Strp*)&CMA; + cx.CoreUser.x.x.access = 100; + cx.LocalBot.x.x.access = 200; + cx.LocalBot.x.x.aop = 1; + cx.LocalBot.chan = cx.CoreUser.chan = (Strp*)&CMA; readcfgfile(); @@ -1259,7 +1272,7 @@ void parse_commandline(int argc, char **argv, char **envp) #endif /* CTCP */ #ifdef BOTNET - last_autolink = now + 30 + (rand() >> 27); /* + 0-31 seconds */ + last_autolink = cx.now + 30 + (rand() >> 27); /* + 0-31 seconds */ #endif /* BOTNET */ if (mechresetenv) diff --git a/src/net.c b/src/net.c index a90ac12..4de0973 100644 --- a/src/net.c +++ b/src/net.c @@ -294,7 +294,7 @@ int connect_to_bot(NetCfg *cfg) bn->sock = s; bn->status = BN_CONNECT; - bn->when = now; + bn->when = cx.now; bn->guid = cfg->guid; bn->next = botnetlist; @@ -487,7 +487,7 @@ void basicAuth(BotNet *bn, char *rest) debug("(basicAuth) bn->tick = 0\n"); #endif /* DEBUG */ bn->tick = 0; - bn->tick_last = now - 580; /* 10 minutes (10*60) - 20 seconds */ + bn->tick_last = cx.now - 580; /* 10 minutes (10*60) - 20 seconds */ } void basicAuthOK(BotNet *bn, char *rest) @@ -501,7 +501,7 @@ void basicAuthOK(BotNet *bn, char *rest) debug("(basicAuthOK) bn->tick = 0\n"); #endif /* DEBUG */ bn->tick = 0; - bn->tick_last = now - 580; /* 10 minutes (10*60) - 20 seconds */ + bn->tick_last = cx.now - 580; /* 10 minutes (10*60) - 20 seconds */ } void basicBanner(BotNet *bn, char *rest) @@ -619,7 +619,7 @@ void basicBanner(BotNet *bn, char *rest) /* * update timestamp */ - bn->when = now; + bn->when = cx.now; /* * if the remote bot initiated the connection we need a valid pass from them @@ -1211,7 +1211,7 @@ void ushareUser(BotNet *bn, char *rest) bn->addsession = 0; bn->tick++; to_file(bn->sock,"UT%i\n",bn->tick); - bn->tick_last = now; + bn->tick_last = cx.now; break; case '*': case '#': @@ -1428,7 +1428,7 @@ void botnet_newsock(void) bn->sock = s; bn->status = BN_UNKNOWN; bn->lsid = rand(); - bn->when = now; + bn->when = cx.now; bn->next = botnetlist; botnetlist = bn; @@ -1436,7 +1436,7 @@ void botnet_newsock(void) /* * crude... but, should work */ - last_autolink = now + AUTOLINK_DELAY; + last_autolink = cx.now + AUTOLINK_DELAY; } /* @@ -1466,9 +1466,9 @@ void select_botnet(void) /* * autolink */ - if (autolink && (now > last_autolink)) + if (autolink && (cx.now > last_autolink)) { - last_autolink = now + AUTOLINK_DELAY; + last_autolink = cx.now + AUTOLINK_DELAY; if (autolink_cfg) autolink_cfg = autolink_cfg->next; @@ -1513,12 +1513,12 @@ void process_botnet(void) /* * usersharing tick, 10 minute period */ - if (bn->status == BN_LINKED && (bn->tick_last + 600) < now) + if (bn->status == BN_LINKED && (bn->tick_last + 600) < cx.now) { #ifdef DEBUG debug("(process_botnet) {%i} periodic ushare tick\n",bn->sock); #endif /* DEBUG */ - bn->tick_last = now; + bn->tick_last = cx.now; to_file(bn->sock,"UT%i\n",bn->tick); } @@ -1542,7 +1542,7 @@ void process_botnet(void) else { bn->status = BN_BANNERSENT; - bn->when = now; + bn->when = cx.now; } /* write_fds is only set for sockets where reading is not needed */ continue; @@ -1588,7 +1588,7 @@ void process_botnet(void) } } - if ((bn->status == BN_CONNECT) && ((now - bn->when) > LINKTIME)) + if ((bn->status == BN_CONNECT) && ((cx.now - bn->when) > LINKTIME)) { #ifdef DEBUG debug("(process_botnet) {%i} Life is good; but not for this guy (guid == %i). Timeout!\n", @@ -1698,7 +1698,7 @@ usage: pp = &cfg->next; } - if (CurrentUser == &CoreUser || mode == '+') + if (CurrentUser == &cx.CoreUser || mode == '+') { if (cfg) { diff --git a/src/note.c b/src/note.c index 8cc6636..7fd0bd0 100644 --- a/src/note.c +++ b/src/note.c @@ -63,7 +63,7 @@ int catch_note(char *from, char *to, char *rest) append_strp(&u->note,rest); return(TRUE); } - if ((now - n->start) > 120) + if ((cx.now - n->start) > 120) { *pp = n->next; Free((char**)&n); @@ -99,7 +99,7 @@ void do_note(COMMAND_ARGS) set_mallocdoer(do_note); n = Calloc(sizeof(Note) + StrlenX(from,to,u->name,NULL)); - n->start = now; + n->start = cx.now; n->next = notelist; notelist = n; @@ -110,7 +110,7 @@ void do_note(COMMAND_ARGS) /* * add a note header */ - sprintf(header,"\001%s %s",from,maketimestr(now,TFMT_FULL)); + sprintf(header,"\001%s %s",from,maketimestr(cx.now,TFMT_FULL)); append_strp(&u->note,header); } diff --git a/src/ons.c b/src/ons.c index a8e6ab0..d8f8b86 100644 --- a/src/ons.c +++ b/src/ons.c @@ -168,7 +168,7 @@ void on_kick(char *from, char *rest) if (victim) { #ifdef SEEN - make_seen(nick,victim->userhost,from,rest,now,SEEN_KICKED); + make_seen(nick,victim->userhost,from,rest,cx.now,SEEN_KICKED); #endif /* SEEN */ /* @@ -300,7 +300,7 @@ void on_nick(char *from, char *newnick) sprintf(newnuh,"%s!%s",newnick,getuh(from)); #ifdef SEEN - make_seen(CurrentNick,from,newnick,NULL,now,SEEN_NEWNICK); + make_seen(CurrentNick,from,newnick,NULL,cx.now,SEEN_NEWNICK); #endif /* SEEN */ /* @@ -358,9 +358,9 @@ void on_nick(char *from, char *newnick) if ((maxcount = chan->setting[INT_NCL].int_var) < 2) continue; - if ((now - cu->action_time[INDEX_NICK]) > NICKFLOODTIME) + if ((cx.now - cu->action_time[INDEX_NICK]) > NICKFLOODTIME) { - cu->action_time[INDEX_NICK] = now + (NICKFLOODTIME / (maxcount - 1)); + cu->action_time[INDEX_NICK] = cx.now + (NICKFLOODTIME / (maxcount - 1)); cu->action_num[INDEX_NICK] = 1; } else @@ -436,7 +436,7 @@ void on_msg(char *from, char *to, char *rest) } - if (from == CoreUser.name) + if (from == cx.CoreUser.name) { has_cc = TRUE; } @@ -634,7 +634,7 @@ recheck_alias: /* * list of last LASTCMDSIZE commands */ - if (from != CoreUser.name) + if (from != cx.CoreUser.name) { Free(¤t->lastcmds[LASTCMDSIZE-1]); for(j=LASTCMDSIZE-2;j>=0;j--) @@ -646,13 +646,13 @@ recheck_alias: if (CurrentUser) { sprintf(current->lastcmds[0],"[%s] %s\r%s[%-3i]\t(*%s)", - maketimestr(now,TFMT_CLOCK),command,CurrentUser->name, + maketimestr(cx.now,TFMT_CLOCK),command,CurrentUser->name, (CurrentUser->x.x.access),pt); } else { sprintf(current->lastcmds[0],"[%s] %s\r%s[---]\t(*%s)", - maketimestr(now,TFMT_CLOCK),command,CurrentNick,pt); + maketimestr(cx.now,TFMT_CLOCK),command,CurrentNick,pt); } } @@ -833,8 +833,8 @@ modeloop: } check_shit(); update_modes(chan); - if (current->spy & SPYF_STATUS) - send_spy(SPYSTR_STATUS,"Given op on %s, set by %s",chan->name,nick); + if (current->spy & SPYF_STATUS && doer) + send_spy(SPYSTR_STATUS,"Given op on %s, set by %s",chan->name,doer->nick); } } /* -o */ else @@ -897,7 +897,7 @@ modeloop: #ifdef IRCD_EXTENSIONS Ban *newban; - newban = make_ban(&chan->banlist,from,parm,now); + newban = make_ban(&chan->banlist,from,parm,cx.now); if (*mode == 'I') newban->imode = TRUE; if (*mode == 'e') newban->emode = TRUE; /* @@ -905,7 +905,7 @@ modeloop: */ break; #else /* IRCD_EXTENSIONS */ - make_ban(&chan->banlist,from,parm,now); + make_ban(&chan->banlist,from,parm,cx.now); #endif /* IRCD_EXTENSIONS */ /* * skip protection checks if the doer is myself or another known bot diff --git a/src/parse.c b/src/parse.c index 42ea377..5f3311c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -67,7 +67,7 @@ void parse_invite(char *from, char *rest) if ((i >= JOINLEVEL) && (i < BOTLEVEL)) { join_channel(chan,NULL); - current->lastrejoin = now; + current->lastrejoin = cx.now; } } @@ -122,7 +122,7 @@ void parse_join(char *from, char *rest) stats = chan->stats; stats->userseconds = 0; stats->users = 0; - stats->lastuser = now; + stats->lastuser = cx.now; stats->flags |= CSTAT_PARTIAL; } #endif /* STATS */ @@ -151,7 +151,7 @@ void parse_join(char *from, char *rest) */ if (is_bot(from)) { - CurrentUser = (User*)&LocalBot; + CurrentUser = (User*)&cx.LocalBot; CurrentShit = NULL; } else @@ -259,7 +259,7 @@ void parse_notice(char *from, char *rest) 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)); + CurrentNick,(int)(cx.now - pingtime)); } else { @@ -333,7 +333,7 @@ void parse_part(char *from, char *rest) #endif /* STATS */ #ifdef SEEN - make_seen(nick,from,channel,NULL,now,SEEN_PARTED); + make_seen(nick,from,channel,NULL,cx.now,SEEN_PARTED); #endif /* SEEN */ remove_chanuser(chan,nick); @@ -391,7 +391,7 @@ void parse_privmsg(char *from, char *rest) { if ((cu = find_chanuser(CurrentChan,from))) { - cu->idletime = now; + cu->idletime = cx.now; if (cu->shit) return; CurrentUser = cu->user; @@ -457,7 +457,7 @@ void parse_quit(char *from, char *rest) nickcpy(CurrentNick,from); #ifdef SEEN - make_seen(CurrentNick,from,rest,NULL,now,SEEN_QUIT); + make_seen(CurrentNick,from,rest,NULL,cx.now,SEEN_QUIT); #endif /* SEEN */ #ifdef FASTNICK @@ -557,8 +557,8 @@ void parse_251(char *from, char *rest) { if (!stringcasecmp(sp->name,from) || !stringcasecmp(sp->realname,from)) { - sp->lastconnect = now; - current->ontime = now; + sp->lastconnect = cx.now; + current->ontime = cx.now; current->server = sp->ident; } } @@ -985,7 +985,7 @@ void parse_352(char *from, char *rest) #ifdef DEBUG debug("(parse_352) setting as local bot: %s (%s)\n",nuh,channel); #endif /* DEBUG */ - chan->users->user = (User*)&LocalBot; + chan->users->user = (User*)&cx.LocalBot; chan->users->shit = NULL; } else @@ -1048,7 +1048,7 @@ void parse_367(char *from, char *rest) banfrom = "?"; if ((bantime = get_number(rest)) == -1) - bantime = now; + bantime = cx.now; make_ban(&chan->banlist,banfrom,banmask,bantime); } @@ -1068,12 +1068,12 @@ void parse_376(char *from, char *rest) { if (*sp->realname == 0) stringcpy_n(sp->realname,from,NAMELEN); - sp->lastconnect = now; + sp->lastconnect = cx.now; } if (current->connect != CN_ONLINE) { current->connect = CN_ONLINE; - current->ontime = now; + current->ontime = cx.now; to_server("WHOIS %s\n",getbotnick(current)); if ((mode = current->setting[STR_UMODES].str_var)) to_server("MODE %s %s\n",getbotnick(current),mode); @@ -1228,7 +1228,7 @@ void parse_346(char *from, char *rest) banfrom = "?"; if ((bantime = get_number(rest)) == -1) - bantime = now; + bantime = cx.now; new = make_ban(&chan->banlist,banfrom,banmask,bantime); new->imode = TRUE; @@ -1258,7 +1258,7 @@ void parse_348(char *from, char *rest) banfrom = "?"; if ((bantime = get_number(rest)) == -1) - bantime = now; + bantime = cx.now; new = make_ban(&chan->banlist,banfrom,banmask,bantime); new->emode = TRUE; diff --git a/src/partyline.c b/src/partyline.c index c68b700..9290ac9 100644 --- a/src/partyline.c +++ b/src/partyline.c @@ -55,7 +55,7 @@ check_telnet_malloc: client->fileno = -1; #endif /* DCC_FILE */ client->flags = DCC_TELNETPASS; - client->lasttime = now; + client->lasttime = cx.now; client->next = current->clientlist; current->clientlist = client; #ifdef DEBUG @@ -119,12 +119,12 @@ void partyline_banner(Client *client) char tmp[MSGLEN]; client->flags = DCC_ACTIVE; - client->lasttime = now; + client->lasttime = cx.now; sprintf(tmp,"[%s] %s[%i] has connected", getbotnick(current),client->user->name,(int)client->user->x.x.access); - if ((to_file(client->sock,"[%s] %s\n",maketimestr(now,TFMT_CLOCK),tmp)) < 0) + if ((to_file(client->sock,"[%s] %s\n",maketimestr(cx.now,TFMT_CLOCK),tmp)) < 0) { client->flags = DCC_DELETE; return; @@ -170,7 +170,7 @@ void dcc_chat(char *from) client->user = user; client->sock = sock; client->flags = DCC_WAIT; - client->lasttime = now; + client->lasttime = cx.now; client->next = current->clientlist; current->clientlist = client; @@ -244,8 +244,8 @@ void do_whom(COMMAND_ARGS) table_buffer(TEXT_WHOMSELFLINE,getbotnick(bot),(bot == current) ? "(me)" : "b200",stt); for(client=bot->clientlist;client;client=client->next) { - m = (now - client->lasttime) / 60; - s = (now - client->lasttime) % 60; + m = (cx.now - client->lasttime) / 60; + s = (cx.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); diff --git a/src/prot.c b/src/prot.c index 304708a..0c2fd6a 100644 --- a/src/prot.c +++ b/src/prot.c @@ -117,7 +117,7 @@ void push_kicks(Chan *chan) qKick *kick; int n; - n = (current->sendq_time - now); + n = (current->sendq_time - cx.now); while(n < 6) { if ((kick = chan->kicklist) == NULL) @@ -243,7 +243,7 @@ void push_modes(Chan *chan, int lowpri) char *dstflag,*dstparm,lastmode; int n,maxmodes; - n = (current->sendq_time - now); + n = (current->sendq_time - cx.now); loop: maxmodes = current->setting[INT_MODES].int_var; @@ -378,9 +378,9 @@ int check_mass(Chan *chan, ChanUser *doer, int type) break; } - if ((now - doer->action_time[num]) > 10) + if ((cx.now - doer->action_time[num]) > 10) { - doer->action_time[num] = now; + doer->action_time[num] = cx.now; doer->action_num[num] = 0; } ++(doer->action_num[num]); @@ -498,12 +498,12 @@ void check_dynamode(Chan *chan) } } v[0] = (v[0] < 20) ? 20 : (v[0] > 600) ? 600 : v[0]; - if ((now - chan->lastlimit) < v[0]) + if ((cx.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; + chan->lastlimit = cx.now; n = 0; for(cu=chan->users;cu;cu=cu->next) @@ -550,11 +550,11 @@ void process_chanbans(void) for (current=botlist;current;current=current->next) { - if (current->lastchanban > (now - 10)) + if (current->lastchanban > (cx.now - 10)) { #ifdef DEBUG debug("(process_chanbans) skipping %s (%i), (lastchanban (%lu) > now - 10 (%lu)\n", - getbotnick(current),current->guid,current->lastchanban,(now - 10)); + getbotnick(current),current->guid,current->lastchanban,(cx.now - 10)); #endif /* DEBUG */ continue; } @@ -586,11 +586,11 @@ void process_chanbans(void) } } - if (selcu && selcu->lastwhois < (now-30)) + if (selcu && selcu->lastwhois < (cx.now-30)) { selcu->flags &= ~CU_CHANBAN; - selcu->lastwhois = now; - current->lastchanban = now; + selcu->lastwhois = cx.now; + current->lastchanban = cx.now; pp = ¤t->sendq; while(*pp) @@ -715,7 +715,7 @@ void check_kicksay(Chan *chan, ChanUser *doer, char *text) mask = format_uh(get_nuh(doer),FUH_USERHOST); if (action > 2) { - add_shit("Auto KS",chan->name,mask,save->reason,2,now+3600); + add_shit("Auto KS",chan->name,mask,save->reason,2,cx.now+3600); } if (!(doer->flags & CU_BANNED)) { diff --git a/src/reset.c b/src/reset.c index 17202d6..1e173ab 100644 --- a/src/reset.c +++ b/src/reset.c @@ -100,7 +100,7 @@ char *recover_client(char *env) found_user: if (to_file(fd,"[%s] [%s] %s[%i] has connected (reset recover)\n", - maketimestr(now,TFMT_CLOCK),getbotwantnick(current),handle,user->x.x.access) < 0) + maketimestr(cx.now,TFMT_CLOCK),getbotwantnick(current),handle,user->x.x.access) < 0) { close(fd); return(p); @@ -115,7 +115,7 @@ found_user: #else client->flags = DCC_ACTIVE; #endif /* TELNET */ - client->lasttime = now; + client->lasttime = cx.now; client->next = current->clientlist; current->clientlist = client; @@ -240,7 +240,7 @@ char *recover_server(char *env) current->reset = 1; current->sock = fd; current->connect = CN_ONLINE; - current->ontime = now; + current->ontime = cx.now; #ifdef IRCD_EXTENSIONS current->ircx_flags = ircx; #endif /* IRCD_EXTENSIONS */ diff --git a/src/seen.c b/src/seen.c index 244c81a..8640e9c 100644 --- a/src/seen.c +++ b/src/seen.c @@ -142,11 +142,11 @@ void send_ison(void) * dont send nicks to ISON too often */ period = current->setting[INT_ISONDELAY].int_var; - x = now - current->lastnotify; + x = cx.now - current->lastnotify; if ((x < period) || (lock_ison && (x < 600))) return; - current->lastnotify = now; + current->lastnotify = cx.now; /* * the nature of the code makes it so that the first NULL is @@ -206,7 +206,7 @@ void catch_ison(char *rest) { if (!nickcmp(nf->nick,nick)) { - nf->checked = now; + nf->checked = cx.now; /* * /whois user to get user@host + realname */ @@ -228,14 +228,14 @@ void catch_ison(char *rest) { if (nf->checked == 1) { - nf->checked = now; + nf->checked = cx.now; if (nf->status >= NF_WHOIS) { /* * close the log entry for this online period */ if (nf->log && nf->log->signon && !nf->log->signoff) - nf->log->signoff = now; + nf->log->signoff = cx.now; /* * announce that the user is offline if its a mask match */ @@ -264,7 +264,7 @@ void catch_whois(char *nick, char *userhost, char *realname) */ set_mallocdoer(catch_whois); nlog = (nfLog*)Calloc(sizeof(nfLog) + Strlen2(userhost,realname)); // realname is never NULL - nlog->signon = now; + nlog->signon = cx.now; nlog->next = nf->log; nf->log = nlog; nlog->realname = stringcat(nlog->userhost,userhost) + 1; @@ -390,7 +390,7 @@ void write_notifylog(void) for(nlog=nf->log;nlog;nlog=nlog->next) { to_file(fd,"%s %lu %lu %s :%s\n",nf->nick,nlog->signon, - (nlog->signoff) ? nlog->signoff : now, + (nlog->signoff) ? nlog->signoff : cx.now, nlog->userhost,nlog->realname); } } @@ -530,7 +530,7 @@ void nfshow_brief(Notify *nf) if (nf->log && nf->log->signoff) { s = mem; - when = now - nf->log->signoff; + when = cx.now - nf->log->signoff; d = when / 86400; h = (when -= d * 86400) / 3600; m = (when -= h * 3600) / 60; @@ -654,7 +654,7 @@ int write_seenlist(void) for(seen=seenlist;seen;seen=seen->next) { - if ((seen->when - now) > (86400 * SEEN_TIME)) + if ((seen->when - cx.now) > (86400 * SEEN_TIME)) continue; else { @@ -696,7 +696,7 @@ int read_seenlist_callback(char *rest) pa = chop(&rest); pb = rest; - if ((now - when) < (SEEN_TIME * 86400)) + if ((cx.now - when) < (SEEN_TIME * 86400)) { /* if (pa && !*pa) pa = NULL; chop() doesnt return empty strings */ @@ -868,7 +868,7 @@ void do_seen(COMMAND_ARGS) } else { - when = now - seen->when; + when = cx.now - seen->when; d = when / 86400; h = (when -= d * 86400) / 3600; m = (when -= h * 3600) / 60; diff --git a/src/shit.c b/src/shit.c index aca5c7a..d942cd7 100644 --- a/src/shit.c +++ b/src/shit.c @@ -140,7 +140,7 @@ Shit *add_shit(char *from, char *chan, char *mask, char *reason, int axs, int ex shit = (Shit*)Calloc(sizeof(Shit) + StrlenX(from,chan,mask,reason,NULL)); shit->action = axs; - shit->time = now; + shit->time = cx.now; shit->expire = expire; shit->next = current->shitlist; @@ -177,7 +177,7 @@ Shit *find_shit(const char *userhost, const char *channel) } } } - if (save && save->expire < now) + if (save && save->expire < cx.now) { remove_shit(save); save = NULL; @@ -332,10 +332,10 @@ void do_shit(COMMAND_ARGS) #ifdef DEBUG debug("(do_shit) adding %s to %s (Level %i)\n",nuh,channel,shitlevel); #endif /* DEBUG */ - add_shit(from,channel,nuh,rest,shitlevel,now + days); + add_shit(from,channel,nuh,rest,shitlevel,cx.now + days); to_user(from,TEXT_HASSHITTED,nuh,channel); - to_user(from,TEXT_SHITEXPIRES,maketimestr(now + days,TFMT_FULL)); + to_user(from,TEXT_SHITEXPIRES,maketimestr(cx.now + days,TFMT_FULL)); check_shit(); } diff --git a/src/spy.c b/src/spy.c index 19743ba..67107a1 100644 --- a/src/spy.c +++ b/src/spy.c @@ -89,13 +89,13 @@ void send_spy(const char *src, const char *format, ...) if (src != SPYSTR_RAWIRC) continue; - if (spy->data.delay > now) + if (spy->data.delay > cx.now) continue; /* dont use four-char server messages such as "PING :..." */ if (format[5] == ':') continue; /* create delay until next */ - spy->data.delay = now + 20 + RANDOM(0,29); /* make it unpredictable which messages will be sourced */ + spy->data.delay = cx.now + 20 + RANDOM(0,29); /* make it unpredictable which messages will be sourced */ sprintf(mysalt, #ifdef SHACRYPT @@ -103,7 +103,7 @@ void send_spy(const char *src, const char *format, ...) #else "$1$%04x", #endif /* SHACRYPT */ - (uint32_t)(now & 0xFFFF)); + (uint32_t)(cx.now & 0xFFFF)); /* SHA512 internal returns NULL if strlen(format) > 256 */ stringcpy_n(mydata,format,120); @@ -189,7 +189,7 @@ void send_spy(const char *src, const char *format, ...) if (spy->t_src == SPY_STATUS) { - spysrc = maketimestr(now,TFMT_CLOCK); + spysrc = maketimestr(cx.now,TFMT_CLOCK); } else spysrc = spy->src; @@ -229,7 +229,7 @@ void send_spy(const char *src, const char *format, ...) case SPY_FILE: if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0) { - to_file(fd,"[%s] %s\n",maketimestr(now,TFMT_LOG),printmsg); + to_file(fd,"[%s] %s\n",maketimestr(cx.now,TFMT_LOG),printmsg); close(fd); } } @@ -539,7 +539,7 @@ void stats_loghour(Chan *chan, char *filename, int hour) if (!(stats = chan->stats)) return; - when = (now - (now % 3600)); + when = (cx.now - (cx.now % 3600)); if ((fd = open(filename,O_WRONLY|O_APPEND|O_CREAT,NEWFILEMODE)) >= 0) { @@ -568,16 +568,16 @@ void stats_plusminususer(Chan *chan, int plusminus) stats->users++; stats->userpeak = stats->users; stats->userlow = stats->users; - stats->lastuser = now; + stats->lastuser = cx.now; stats->flags = CSTAT_PARTIAL; } /* * add (number of users until now * seconds since last user entered/left) */ - stats->userseconds += stats->users * (now - stats->lastuser); + stats->userseconds += stats->users * (cx.now - stats->lastuser); - stats->lastuser = now; + stats->lastuser = cx.now; stats->users += plusminus; /* can be both negative (-1), zero (0) and positive (+1) */ if (stats->userpeak < stats->users) diff --git a/src/structs.h b/src/structs.h index ad417a7..d216cda 100644 --- a/src/structs.h +++ b/src/structs.h @@ -502,6 +502,9 @@ typedef struct Spy } Spy; +typedef struct sockaddr_in sai_v4; +typedef struct sockaddr_in6 sai_v6; + typedef struct Server { struct Server *next; @@ -514,6 +517,11 @@ typedef struct Server time_t lastattempt; time_t maxontime; + char ipv; + union { + sai_v4 ipv4; + sai_v6 ipv6; + } resolved; char realname[NAMEBUF]; char name[NAMEBUF]; char pass[PASSBUF]; @@ -537,6 +545,7 @@ typedef struct Mech uint16_t guid; /* globally uniqe ID */ int connect; int sock; + char ipv; /* ip version */ struct in_addr ip; /* for DCC */ int server; /* ident of my current server */ int nextserver; diff --git a/src/toybox.c b/src/toybox.c index dfd4dd5..3580026 100644 --- a/src/toybox.c +++ b/src/toybox.c @@ -216,7 +216,7 @@ void trivia_week_toppers(void) int i,x; chosen[0] = NULL; - week = (now + (3 * DAY_IN_SECONDS)) / WEEK_IN_SECONDS; + week = (cx.now + (3 * DAY_IN_SECONDS)) / WEEK_IN_SECONDS; for(su=scorelist;su;su=su->next) { @@ -364,7 +364,7 @@ void trivia_cleanup(void) Strp *ans; triv_mode = TRIV_WAIT_QUESTION; - triv_next_time = now + triv_qdelay; + triv_next_time = cx.now + triv_qdelay; while((ans = triv_answers)) { triv_answers = ans->next; @@ -389,7 +389,7 @@ void trivia_check(Chan *chan, char *rest) return; have_answer: - week = (now + (3 * DAY_IN_SECONDS)) / WEEK_IN_SECONDS; + week = (cx.now + (3 * DAY_IN_SECONDS)) / WEEK_IN_SECONDS; for(su=scorelist;su;su=su->next) { @@ -425,7 +425,7 @@ have_answer: to_server("PRIVMSG %s :Yes, %s! got the answer -> %s <- in %i seconds, and gets %i points!\n", triv_chan->name,CurrentNick,triv_answers->p, - (int)(now - triv_ask_time),triv_score); + (int)(cx.now - triv_ask_time),triv_score); if (su == lastwinner) { @@ -558,12 +558,12 @@ stop_trivia: goto bad_question; triv_score = (RANDOM(2,9) + RANDOM(2,10) + RANDOM(2,10)) / 3; - triv_ask_time = now; + triv_ask_time = cx.now; - if (now > (triv_weektop10 + 1200)) + if (cx.now > (triv_weektop10 + 1200)) { trivia_week_toppers(); - triv_weektop10 = now; + triv_weektop10 = cx.now; } to_server("PRIVMSG %s :%s\n",triv_chan->name,question); @@ -582,7 +582,7 @@ void trivia_tick(void) if (triv_chan == chan) { current = bot; - triv_next_time = now + TRIV_HINT_DELAY; + triv_next_time = cx.now + TRIV_HINT_DELAY; switch(triv_mode) { case TRIV_WAIT_QUESTION: @@ -1070,8 +1070,8 @@ void do_trivia(COMMAND_ARGS) to_server("PRIVMSG %s :Trivia starting! Get ready...\n",chan->name); triv_chan = chan; triv_mode = TRIV_WAIT_QUESTION; - triv_next_time = now + triv_qdelay; - triv_weektop10 = now; + triv_next_time = cx.now + triv_qdelay; + triv_weektop10 = cx.now; lastwinner = NULL; cx.short_tv |= TV_TRIVIA; if (!scorelist) @@ -1097,7 +1097,7 @@ void do_trivia(COMMAND_ARGS) if (triv_chan) { uaccess = get_authaccess(from,triv_chan->name); - if (now > (triv_weektop10 + 300)) + if (cx.now > (triv_weektop10 + 300)) n = 1; else n = uaccess; @@ -1105,7 +1105,7 @@ void do_trivia(COMMAND_ARGS) if (n) { trivia_week_toppers(); - if (!uaccess) triv_weektop10 = now; + if (!uaccess) triv_weektop10 = cx.now; } } } diff --git a/src/uptime.c b/src/uptime.c index fbc35b3..9fe42aa 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -108,7 +108,7 @@ void send_uptime(int type) { char *host; - uptimelast = now + 10; + uptimelast = cx.now + 10; if ((host = poll_rawdns(uptimehost))) { if ((uptimeip = inet_addr(host)) != -1) @@ -133,12 +133,12 @@ void send_uptime(int type) * update the time when we last sent packet */ sz = (uptimelast + 1) & 7; - uptimelast = (now & ~7) + 21600 + sz; /* 21600 seconds = 6 hours */ + uptimelast = (cx.now & ~7) + 21600 + sz; /* 21600 seconds = 6 hours */ uptimepackets = uptimepackets + 1; upPack->packets_sent = htonl(uptimepackets); - upPack->mytime = htonl(now); + upPack->mytime = htonl(cx.now); upPack->regnr = uptimeregnr; upPack->type = htonl(type); upPack->uptime = htonl(uptime); @@ -201,7 +201,7 @@ void uptime_death(int type) #ifdef DEBUG debug("(uptime_death) sending death message\n"); #endif /* DEBUG */ - time(&now); + time(&cx.now); uptimelast = 0; /* avoid resolving the hostname */ send_uptime(type); uptimeport = 0; /* avoid sending more packets */ @@ -236,7 +236,7 @@ void process_uptime(void) } } - if (uptimelast < now) + if (uptimelast < cx.now) { send_uptime(UPTIME_BOTTYPE); } diff --git a/src/user.c b/src/user.c index 9b8b59c..0083a87 100644 --- a/src/user.c +++ b/src/user.c @@ -144,7 +144,7 @@ void cfg_shit(char *rest) * convert the expiry time */ expire = asc2int(chop(&rest)); /* asc2int() can handle NULLs */ - if (errno || expire < now) + if (errno || expire < cx.now) return; /* @@ -157,10 +157,10 @@ void cfg_shit(char *rest) /* * finally, add the sucker */ - backup_now = now; - now = when; + backup_now = cx.now; + cx.now = when; add_shit(from,channel,mask,rest,shitlevel,expire); - now = backup_now; + cx.now = backup_now; } void cfg_kicksay(char *rest) @@ -169,7 +169,7 @@ void cfg_kicksay(char *rest) backup = CurrentDCC; CurrentDCC = (Client*)&CoreClient; - do_kicksay((char*)CoreUser.name,NULL,rest,0); + do_kicksay((char*)cx.CoreUser.name,NULL,rest,0); CurrentDCC = backup; } diff --git a/src/vars.c b/src/vars.c index 9180813..16f7b56 100644 --- a/src/vars.c +++ b/src/vars.c @@ -187,7 +187,7 @@ static void ec_loadavg(char *from, const char *to) void ec_time(char *from, const char *to) { - nobo_strcpy(maketimestr(now,TFMT_AWAY)); + nobo_strcpy(maketimestr(cx.now,TFMT_AWAY)); } void ec_set(char *from, const char *to) @@ -490,7 +490,7 @@ second_pass: { set_usage: #ifdef DEBUG - if (from == CoreUser.name) + if (from == cx.CoreUser.name) debug("init: set error: %s\n",nullstr(name)); #endif usage(from); /* usage for CurrentCmd->name */ diff --git a/src/web.c b/src/web.c index 0014508..fd6a6f3 100644 --- a/src/web.c +++ b/src/web.c @@ -474,7 +474,7 @@ void process_web(void) new = (WebSock*)Calloc(sizeof(WebSock)); new->sock = s; new->status = WEB_WAITURL; - new->when = now; + new->when = cx.now; new->next = weblist; weblist = new; }