cx.now + ipv6 stuff + december sync

This commit is contained in:
joonicks 2025-12-08 13:51:07 +01:00
parent 758ab577b3
commit e119860be8
33 changed files with 302 additions and 252 deletions

View File

@ -1,9 +1,20 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct in_addr ia; struct in_addr ia;
ia.s_addr = inet_addr("0.0.0.0"); 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); return(0);
} }

16
configure vendored
View File

@ -25,6 +25,7 @@ install=no
silentopt=no silentopt=no
try_libmusl=no try_libmusl=no
no_flto=no no_flto=no
use_fnostrictalias=no
# default optimization goal, speed = -O2, size = -Os # default optimization goal, speed = -O2, size = -Os
optitype=size optitype=size
@ -310,6 +311,8 @@ do
--no-optimize) cc_optimize_opt=no ;; --no-optimize) cc_optimize_opt=no ;;
--optimize=speed) optitype=speed ;; --optimize=speed) optitype=speed ;;
--optimize=size) optitype=size ;; --optimize=size) optitype=size ;;
--use-nostrictalias) use_fnostrictalias=yes ;;
--no-nostrictalias) use_fnostrictalias=no ;;
--use-gnudebug) cc_g_opt=yes ;; --use-gnudebug) cc_g_opt=yes ;;
--no-gnudebug) cc_g_opt=no ;; --no-gnudebug) cc_g_opt=no ;;
--use-warnflag) cc_wall_opt=yes ;; --use-warnflag) cc_wall_opt=yes ;;
@ -591,7 +594,7 @@ if [ -z "$cf_cflags" -a -n "$cf_GNUCC" ]; then
fi fi
fi 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" cc_fnostrictalias="-fno-strict-aliasing"
echo $ac_n "-fno-strict-aliasing "$ac_c echo $ac_n "-fno-strict-aliasing "$ac_c
fi fi
@ -843,6 +846,17 @@ else
fi fi
fi fi
echo $ac_t "$has_inet_addr" 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 rm -f $TESTP
# #

View File

@ -259,7 +259,7 @@ void change_authnick(char *nuh, char *newnuh)
set_mallocdoer(change_authnick); set_mallocdoer(change_authnick);
auth = (Auth*)Calloc(sizeof(Auth) + strlen(newnuh)); auth = (Auth*)Calloc(sizeof(Auth) + strlen(newnuh));
auth->user = oldauth->user; auth->user = oldauth->user;
auth->active = now; auth->active = cx.now;
auth->next = current->authlist; auth->next = current->authlist;
current->authlist = auth; current->authlist = auth;
stringcpy(auth->nuh,newnuh); stringcpy(auth->nuh,newnuh);
@ -349,7 +349,7 @@ int get_authaccess(const char *userhost, const char *channel)
User *user; User *user;
Strp *ump; Strp *ump;
if (userhost == CoreUser.name) if (userhost == cx.CoreUser.name)
return(100); return(100);
if (CurrentDCC && CurrentDCC->user->name == userhost) if (CurrentDCC && CurrentDCC->user->name == userhost)
{ {
@ -391,7 +391,7 @@ int make_auth(const char *userhost, const User *user)
set_mallocdoer(make_auth); set_mallocdoer(make_auth);
auth = (Auth*)Calloc(sizeof(Auth) + strlen(userhost)); auth = (Auth*)Calloc(sizeof(Auth) + strlen(userhost));
auth->user = (User*)user; auth->user = (User*)user;
auth->active = now; auth->active = cx.now;
stringcpy(auth->nuh,userhost); stringcpy(auth->nuh,userhost);
auth->next = current->authlist; auth->next = current->authlist;

View File

@ -82,7 +82,7 @@ void bounce_parse(ircLink *irc, char *message)
if (irc->userLine && irc->nickLine) if (irc->userLine && irc->nickLine)
{ {
to_file(irc->usersock,TEXT_ASK_HANDLE,irc->nick); to_file(irc->usersock,TEXT_ASK_HANDLE,irc->nick);
irc->active = now; irc->active = cx.now;
++irc->status; ++irc->status;
} }
return; return;
@ -135,7 +135,7 @@ void bounce_parse(ircLink *irc, char *message)
{ {
to_file(irc->usersock,TEXT_ASK_SERVER,irc->nick); to_file(irc->usersock,TEXT_ASK_SERVER,irc->nick);
irc->status = BNC_ASK_SERVER; irc->status = BNC_ASK_SERVER;
irc->active = now; irc->active = cx.now;
return; return;
} }
} }
@ -176,7 +176,7 @@ void bounce_parse(ircLink *irc, char *message)
if ((irc->servsock = SockConnect(server,iport,USE_VHOST)) >= 0) if ((irc->servsock = SockConnect(server,iport,USE_VHOST)) >= 0)
{ {
irc->status = BNC_CONNECTING; 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 = (ircLink*)Calloc(sizeof(ircLink)); /* sets all to zero */
irc->next = bnclist; irc->next = bnclist;
bnclist = irc; bnclist = irc;
irc->active = now; irc->active = cx.now;
irc->usersock = s; irc->usersock = s;
--irc->servsock; /* == -1 */ --irc->servsock; /* == -1 */
} }
@ -297,7 +297,7 @@ void process_bounce(void)
debug("(process_bounce) {%i} servsock connected\n",irc->servsock); debug("(process_bounce) {%i} servsock connected\n",irc->servsock);
#endif /* DEBUG */ #endif /* DEBUG */
irc->status = BNC_ACTIVE; irc->status = BNC_ACTIVE;
irc->active = now; irc->active = cx.now;
to_file(irc->servsock,"USER %s\n",irc->userLine); to_file(irc->servsock,"USER %s\n",irc->userLine);
if (to_file(irc->servsock,"NICK %s\n",irc->nickLine) < 0) 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)) if (FD_ISSET(irc->servsock,&read_fds))
{ {
irc->active = now; irc->active = cx.now;
while((p = sockread(irc->servsock,irc->servmem,message))) while((p = sockread(irc->servsock,irc->servmem,message)))
{ {
if (to_file(irc->usersock,FMT_PLAINLINE,message) < 0) if (to_file(irc->usersock,FMT_PLAINLINE,message) < 0)
@ -338,7 +338,7 @@ void process_bounce(void)
pp = &bnclist; pp = &bnclist;
while((irc = *pp)) 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 #ifdef DEBUG
debug("(process_bounce) {%i} {%i} BNC_DEAD or timeout, removing...\n",irc->usersock,irc->servsock); debug("(process_bounce) {%i} {%i} BNC_DEAD or timeout, removing...\n",irc->usersock,irc->servsock);

View File

@ -45,7 +45,7 @@ void check_idlekick(void)
limit = chan->setting[INT_IKT].int_var; limit = chan->setting[INT_IKT].int_var;
if (limit == 0) if (limit == 0)
continue; continue;
timeout = (now - (60 * limit)); timeout = (cx.now - (60 * limit));
for(cu=chan->users;cu;cu=cu->next) for(cu=chan->users;cu;cu=cu->next)
{ {
cu->flags &= ~CU_KSWARN; /* remove KS warnings */ 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 (!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) 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)); new = (ChanUser*)Calloc(sizeof(ChanUser) + strlen(userhost));
/* Calloc sets it all to zero */ /* Calloc sets it all to zero */
new->idletime = now; new->idletime = cx.now;
new->next = CurrentChan->users; new->next = CurrentChan->users;
CurrentChan->users = new; CurrentChan->users = new;
stringcpy(new->userhost,userhost); 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); 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) for(cu=chan->users;cu;cu=cu->next)
{ {
if (n >= (now - cu->idletime)) if (n >= (cx.now - cu->idletime))
continue; continue;
table_buffer("%s\r %s\t%s",idle2str(cu->idletime,TRUE),cu->nick,cu->userhost); table_buffer("%s\r %s\t%s",idle2str(cu->idletime,TRUE),cu->nick,cu->userhost);
} }

View File

@ -97,7 +97,7 @@
@DEF_DCCFILE@ @DEF_DCCFILE@
#define DCC_PUBLICFILES "public/" #define DCC_PUBLICFILES "public/"
#define DCC_PUBLICINCOMING DCC_PUBLICFILES "incoming/" #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 * REDIRECT: send command output from certain commands to a different target
@ -316,8 +316,8 @@
#define AWAYFORM "AWAY :%s (since %s)\n" #define AWAYFORM "AWAY :%s (since %s)\n"
#define KILLSOCKTIMEOUT 30 #define KILLSOCK_TIMEOUT 30
#define WAITTIMEOUT 30 #define WAIT_TIMEOUT 30
#define NICKFLOODTIME 120 /* 240 second window for floods ( 240 / 2 = 120 ) */ #define NICKFLOODTIME 120 /* 240 second window for floods ( 240 / 2 = 120 ) */

View File

@ -41,7 +41,7 @@ int conf_callback(char *line)
fix_config_line(line); fix_config_line(line);
on_msg((char*)CoreUser.name,getbotnick(current),line); on_msg((char*)cx.CoreUser.name,getbotnick(current),line);
return(FALSE); return(FALSE);
} }
@ -79,7 +79,7 @@ void readcfgfile(void)
CurrentShit = NULL; CurrentShit = NULL;
CurrentChan = NULL; CurrentChan = NULL;
CurrentDCC = (Client*)&CoreClient; CurrentDCC = (Client*)&CoreClient;
CurrentUser = (User*)&CoreUser; CurrentUser = (User*)&cx.CoreUser;
readline(in,&conf_callback); /* readline closes in */ readline(in,&conf_callback); /* readline closes in */
@ -527,7 +527,7 @@ int try_server(Server *sp, char *hostname)
hostname = sp->name; hostname = sp->name;
} }
sp->lastattempt = now; sp->lastattempt = cx.now;
sp->usenum++; sp->usenum++;
#ifdef RAWDNS #ifdef RAWDNS
@ -544,7 +544,7 @@ int try_server(Server *sp, char *hostname)
{ {
current->server = sp->ident; current->server = sp->ident;
current->connect = CN_DNSLOOKUP; current->connect = CN_DNSLOOKUP;
current->conntry = now; current->conntry = cx.now;
rawdns(hostname); rawdns(hostname);
return(0); return(0);
} }
@ -557,7 +557,7 @@ int try_server(Server *sp, char *hostname)
} }
current->away = FALSE; current->away = FALSE;
current->connect = CN_TRYING; current->connect = CN_TRYING;
current->activity = current->conntry = now; current->activity = current->conntry = cx.now;
*current->modes = 0; *current->modes = 0;
return(current->sock); return(current->sock);
} }
@ -572,7 +572,7 @@ void connect_to_server(void)
* This should prevent the bot from chewing up too * This should prevent the bot from chewing up too
* much CPU when it fails to connect to ANYWHERE * 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? * Is this the proper action if there is no serverlist?
@ -623,7 +623,7 @@ void connect_to_server(void)
sptry = NULL; sptry = NULL;
for(sp=serverlist;sp;sp=sp->next) for(sp=serverlist;sp;sp=sp->next)
{ {
if (sp->lastattempt == now) if (sp->lastattempt == cx.now)
continue; continue;
if (sgroup && (stringcasecmp(sgroup,sp->group) != 0)) if (sgroup && (stringcasecmp(sgroup,sp->group) != 0))
continue; continue;
@ -633,8 +633,8 @@ void connect_to_server(void)
if (sp->err == 0 || sp->err == SP_ERRCONN) if (sp->err == 0 || sp->err == SP_ERRCONN)
sptry = sp; sptry = sp;
else else
if ((sp->err == SP_THROTTLED && (sp->lastattempt + 45) < now) || /* retry throttled after 45 seconds */ if ((sp->err == SP_THROTTLED && (sp->lastattempt + 45) < cx.now) || /* retry throttled after 45 seconds */
(sp->err == SP_KLINED && (sp->lastattempt + 86400) < now)) /* retry Klined after a day */ (sp->err == SP_KLINED && (sp->lastattempt + 86400) < cx.now)) /* retry Klined after a day */
sptry = sp; sptry = sp;
} }
/* /*
@ -689,7 +689,7 @@ void register_with_server(void)
(ident) ? ident : BOTLOGIN, (ident) ? ident : BOTLOGIN,
(ircname) ? ircname : VERSION); (ircname) ? ircname : VERSION);
current->connect = CN_CONNECTED; 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 //using that struct, calculate when the next time will be
//start by determining what the time is now //start by determining what the time is now
thistime = now; thistime = cx.now;
//which second is it //which second is it
thissecond = thistime % 60; thissecond = thistime % 60;
@ -886,19 +886,19 @@ void update(SequenceTime *this)
int tt,th; int tt,th;
int x,n; int x,n;
tt = now / 600; /* current 10-minute period */ tt = cx.now / 600; /* current 10-minute period */
th = tt / 6; /* current hour */ th = tt / 6; /* current hour */
#ifdef DEBUG #ifdef DEBUG
x = 0; x = 0;
if (tt != this->tenminute) if (tt != this->tenminute)
{ {
debug("(update) running: ten minute updates [%i]",tt); debug("(update) running: ten minute update [%i]",tt);
x++; x++;
} }
if (th != this->hour) if (th != this->hour)
{ {
debug("%shour updates [%i]",(x) ? ", " : "(update) running: ",th); debug("%shour update [%i]",(x) ? ", " : "(update) running: ",th);
x++; x++;
} }
if (x) if (x)
@ -913,10 +913,10 @@ void update(SequenceTime *this)
if (current->rejoin) if (current->rejoin)
{ {
if ((now - current->lastrejoin) > REJOIN_DELAY) if ((cx.now - current->lastrejoin) > REJOIN_DELAY)
{ {
current->rejoin = FALSE; current->rejoin = FALSE;
current->lastrejoin = now; current->lastrejoin = cx.now;
} }
cx.short_tv |= TV_REJOIN; cx.short_tv |= TV_REJOIN;
} }
@ -957,18 +957,18 @@ void update(SequenceTime *this)
check_dynamode(chan); check_dynamode(chan);
#endif /* DYNAMODE */ #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))) if (stringcmp(getbotnick(current),getbotwantnick(current)))
to_server("NICK %s\n",getbotwantnick(current)); to_server("NICK %s\n",getbotwantnick(current));
check_idlekick(); check_idlekick();
if ((x = current->setting[INT_AAWAY].int_var) && current->away == FALSE) 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); 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; current->away = TRUE;
} }
} }
@ -1085,7 +1085,7 @@ void process_server_input(void)
current->vhost_type |= VH_WINGATE_FAIL; current->vhost_type |= VH_WINGATE_FAIL;
} }
current->connect = CN_WINGATEWAIT; current->connect = CN_WINGATEWAIT;
current->conntry = now; current->conntry = cx.now;
current->heartbeat = 0; current->heartbeat = 0;
return; return;
} }
@ -1119,7 +1119,7 @@ get_line:
} }
} }
#endif /* WINGATE */ #endif /* WINGATE */
current->conntry = now; current->conntry = cx.now;
current->heartbeat = 0; current->heartbeat = 0;
parse_server_input(linebuf); parse_server_input(linebuf);
goto get_line; goto get_line;
@ -1135,7 +1135,7 @@ get_line:
} }
/* server has been quiet for too long */ /* 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 #ifdef DEBUG
debug("[PSI] {%i} server has been quiet for too long (%is)...\n",current->sock,SERVERSILENCETIMEOUT); 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 */ /* server has been quiet for WAY too long */
if (current->conntry + (SERVERSILENCETIMEOUT*2) <= now) if (current->conntry + (SERVERSILENCETIMEOUT*2) <= cx.now)
{ {
#ifdef DEBUG #ifdef DEBUG
debug("[PSI] {%i} server has been quiet for WAY too long (%is), forcing reconnect...\n",current->sock,SERVERSILENCETIMEOUT*2); 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) if (uname(&un) == 0)
table_buffer(TEXT_HOSTINFO,h,un.sysname,un.release,un.machine); table_buffer(TEXT_HOSTINFO,h,un.sysname,un.release,un.machine);
#endif /* HOSTINFO */ #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_BOTSTARTED,maketimestr(uptime,TFMT_FULL));
table_buffer(TEXT_BOTUPTIME,idle2str(uptime,FALSE)); table_buffer(TEXT_BOTUPTIME,idle2str(uptime,FALSE));
table_buffer(TEXT_BOTVERSION,VERSION,SRCDATE); table_buffer(TEXT_BOTVERSION,VERSION,SRCDATE);
@ -1527,7 +1527,7 @@ do_server_einval:
return; return;
} }
sp = add_server(server,iport,pass,group); /* add_server has no failure mode */ 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; return;
current->nextserver = sp->ident; current->nextserver = sp->ident;
@ -1564,10 +1564,10 @@ void do_away(COMMAND_ARGS)
to_server("AWAY\n"); to_server("AWAY\n");
to_user(from,TEXT_NOLONGERAWAY); to_user(from,TEXT_NOLONGERAWAY);
current->away = FALSE; current->away = FALSE;
current->activity = now; current->activity = cx.now;
return; return;
} }
to_server(AWAYFORM,rest,maketimestr(now,TFMT_AWAY)); to_server(AWAYFORM,rest,maketimestr(cx.now,TFMT_AWAY));
to_user(from,TEXT_NOWSETAWAY); to_user(from,TEXT_NOWSETAWAY);
current->away = TRUE; current->away = TRUE;
} }
@ -1622,7 +1622,7 @@ void do_nick(COMMAND_ARGS)
current = add_bot(guid,nick); current = add_bot(guid,nick);
if (!sigmaster) if (!sigmaster)
sigmaster = guid; sigmaster = guid;
if (from == CoreUser.name) if (from == cx.CoreUser.name)
return; return;
} }
else else
@ -1640,7 +1640,7 @@ void do_nick(COMMAND_ARGS)
void do_time(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) void do_upontime(COMMAND_ARGS)

View File

@ -128,7 +128,7 @@ int dcc_sendfile(char *target, char *filename)
client->sock = s; client->sock = s;
client->user = NULL; client->user = NULL;
client->flags = DCC_WAIT|DCC_ASYNC|DCC_SEND; client->flags = DCC_WAIT|DCC_ASYNC|DCC_SEND;
client->lasttime = now; client->lasttime = cx.now;
client->whom = stringcpy(client->filename,filename) + 1; client->whom = stringcpy(client->filename,filename) + 1;
stringcpy(client->whom,target); stringcpy(client->whom,target);
@ -216,7 +216,7 @@ void parse_dcc(Client *client)
else else
{ {
client->flags = DCC_SEND; client->flags = DCC_SEND;
client->start = now; client->start = cx.now;
dcc_pushfile(client,0); dcc_pushfile(client,0);
} }
#endif /* DCC_FILE */ #endif /* DCC_FILE */
@ -250,7 +250,7 @@ void parse_dcc(Client *client)
if (write(client->sock,&where,4) == -1) if (write(client->sock,&where,4) == -1)
return; return;
client->lasttime = now; client->lasttime = cx.now;
if (oc == client->fileend) if (oc == client->fileend)
{ {
@ -266,7 +266,7 @@ void parse_dcc(Client *client)
{ {
uint32_t where; uint32_t where;
client->lasttime = now; client->lasttime = cx.now;
s = client->inputcount; s = client->inputcount;
oc = read(client->sock,(client->sockdata+s),(4-s)); oc = read(client->sock,(client->sockdata+s),(4-s));
if ((oc < 1) && (errno != EINTR) && (errno != EAGAIN)) if ((oc < 1) && (errno != EINTR) && (errno != EAGAIN))
@ -319,7 +319,7 @@ void parse_dcc(Client *client)
/* /*
* DCC input flood protection * DCC input flood protection
*/ */
s = now - client->lasttime; s = cx.now - client->lasttime;
if (s > 10) if (s > 10)
{ {
client->inputcount = strlen(ptr); client->inputcount = strlen(ptr);
@ -338,7 +338,7 @@ void parse_dcc(Client *client)
*/ */
CurrentShit = NULL; CurrentShit = NULL;
CurrentChan = NULL; CurrentChan = NULL;
client->lasttime = now; client->lasttime = cx.now;
CurrentDCC = client; CurrentDCC = client;
CurrentUser = client->user; CurrentUser = client->user;
stringcpy(CurrentNick,CurrentUser->name); stringcpy(CurrentNick,CurrentUser->name);
@ -390,7 +390,7 @@ void process_dcc(void)
partyline_banner(client); partyline_banner(client);
} }
else else
if ((client->flags & DCC_WAIT) && ((now - client->lasttime) >= WAITTIMEOUT)) if ((client->flags & DCC_WAIT) && ((cx.now - client->lasttime) >= WAIT_TIMEOUT))
{ {
#ifdef DEBUG #ifdef DEBUG
debug("(process_dcc) connection timed out (%s)\n", debug("(process_dcc) connection timed out (%s)\n",
@ -400,7 +400,7 @@ void process_dcc(void)
} }
#ifdef DCC_FILE #ifdef DCC_FILE
else else
if ((client->flags & DCC_SEND) && ((now - client->lasttime) >= DCC_FILETIMEOUT)) if ((client->flags & DCC_SEND) && ((cx.now - client->lasttime) >= DCCFILE_TIMEOUT))
{ {
#ifdef DEBUG #ifdef DEBUG
debug("(process_dcc) {%i} DCC %s stalled (%s), closing connection\n", debug("(process_dcc) {%i} DCC %s stalled (%s), closing connection\n",
@ -412,7 +412,7 @@ void process_dcc(void)
#endif /* DCC_FILE */ #endif /* DCC_FILE */
#ifdef TELNET #ifdef TELNET
else 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; client->flags = DCC_DELETE;
} }
@ -529,7 +529,7 @@ void ctcp_dcc(char *from, char *to, char *rest)
client->fileend = filesz; client->fileend = filesz;
client->sock = s; client->sock = s;
client->flags = DCC_WAIT|DCC_SEND|DCC_RECV; 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; client->whom = stringcpy(client->filename,filename) + 1;
stringcpy(client->whom,from); stringcpy(client->whom,from);
@ -588,7 +588,7 @@ void ctcp_dcc(char *from, char *to, char *rest)
client->sock = x; client->sock = x;
client->user = user; client->user = user;
client->flags = DCC_WAIT|DCC_ASYNC; client->flags = DCC_WAIT|DCC_ASYNC;
client->lasttime = now; client->lasttime = cx.now;
client->next = current->clientlist; client->next = current->clientlist;
current->clientlist = client; current->clientlist = client;
} }
@ -732,9 +732,9 @@ void on_ctcp(char *from, char *to, char *rest)
{ {
for(mul=0;mul<CTCP_SLOTS;mul++) for(mul=0;mul<CTCP_SLOTS;mul++)
{ {
if (ctcp_slot[mul] < now) if (ctcp_slot[mul] < cx.now)
{ {
ctcp_slot[mul] = now + CTCP_TIMEOUT; ctcp_slot[mul] = cx.now + CTCP_TIMEOUT;
break; break;
} }
} }
@ -778,7 +778,7 @@ void do_ping_ctcp(COMMAND_ARGS)
{ {
if (CurrentCmd->name == C_PING || !stringcasecmp(rest,"PING")) if (CurrentCmd->name == 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; return;
} }
if (*rest) if (*rest)

View File

@ -36,6 +36,8 @@
#define boolstr(x) (x) ? "TRUE" : "FALSE" #define boolstr(x) (x) ? "TRUE" : "FALSE"
#define UNKNOWNSTR "(unknown)"
const char tabs[20] = "\t\t\t\t\t\t\t\t\t\t"; const char tabs[20] = "\t\t\t\t\t\t\t\t\t\t";
const struct const struct
@ -245,7 +247,7 @@ struct
#ifdef URLCAPTURE #ifdef URLCAPTURE
{ urlcapture, "urlcapture" CORE_SE }, { urlcapture, "urlcapture" CORE_SE },
#endif /* URLCAPTURE */ #endif /* URLCAPTURE */
{ 0, "(unknown)" }, { 0, UNKNOWNSTR },
{ NULL, }}; { NULL, }};
#ifdef HOSTINFO #ifdef HOSTINFO
@ -406,7 +408,7 @@ const char *strdef(const DEFstruct *dtab, int num)
if (dtab[i].id == num) if (dtab[i].id == num)
return(dtab[i].idstr); return(dtab[i].idstr);
} }
return("UNKNOWN"); return(UNKNOWNSTR);
} }
void memreset(void) void memreset(void)
@ -458,7 +460,7 @@ const char *proc_getname(void *addr)
if (ProcList[i].func == addr) if (ProcList[i].func == addr)
return(ProcList[i].name); return(ProcList[i].name);
} }
return("(unknown)"); return(UNKNOWNSTR);
} }
const char *proc_lookup(void *addr, int size) const char *proc_lookup(void *addr, int size)
@ -1422,7 +1424,7 @@ int wrap_debug(void)
backup_dodebug = dodebug; backup_dodebug = dodebug;
backup_fd = debug_fd; 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) if ((fd = open(fname,O_WRONLY|O_CREAT|O_TRUNC,NEWFILEMODE)) < 0)
return(0); return(0);
debug_fd = fd; debug_fd = fd;

View File

@ -289,7 +289,7 @@ void parse_query(int psz, dnsQuery *query)
#endif /* DEBUG */ #endif /* DEBUG */
if (dns->cname) if (dns->cname)
Free((char**)&dns->cname); Free((char**)&dns->cname);
dns->when = now + 30; dns->when = cx.now + 30;
set_mallocdoer(parse_query); set_mallocdoer(parse_query);
dns->cname = stringdup(token2); dns->cname = stringdup(token2);
} }
@ -302,7 +302,7 @@ void parse_query(int psz, dnsQuery *query)
if (dns->auth && !stringcasecmp(dns->auth->hostname,token)) if (dns->auth && !stringcasecmp(dns->auth->hostname,token))
{ {
dns->auth->ip.s_addr = ip->s_addr; dns->auth->ip.s_addr = ip->s_addr;
dns->when = now + 60; dns->when = cx.now + 60;
#ifdef DEBUG #ifdef DEBUG
debug("(parse_query) a auth: %s = %s\n",token,inet_ntoa(*ip)); debug("(parse_query) a auth: %s = %s\n",token,inet_ntoa(*ip));
#endif /* DEBUG */ #endif /* DEBUG */
@ -311,7 +311,7 @@ void parse_query(int psz, dnsQuery *query)
if (!stringcasecmp(dns->host,token) || (dns->cname && !stringcasecmp(dns->cname,token))) if (!stringcasecmp(dns->host,token) || (dns->cname && !stringcasecmp(dns->cname,token)))
{ {
dns->ip.s_addr = ip->s_addr; dns->ip.s_addr = ip->s_addr;
dns->when = now + 3600; dns->when = cx.now + 3600;
#ifdef DEBUG #ifdef DEBUG
debug("(parse_query) a: %s = %s\n",token,inet_ntoa(*ip)); debug("(parse_query) a: %s = %s\n",token,inet_ntoa(*ip));
#endif /* DEBUG */ #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); debug("(parse_query) %i: asking %s who is `%s'\n",dns->id,inet_ntoa(sai.sin_addr),src);
#endif /* DEBUG */ #endif /* DEBUG */
sz = make_query(packet,src); sz = make_query(packet,src);
dns->when = now + 60; dns->when = cx.now + 60;
sai.sin_family = AF_INET; sai.sin_family = AF_INET;
sai.sin_port = htons(53); sai.sin_port = htons(53);
((dnsQuery*)packet)->qid = htons(dns->id); ((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); debug("(parse_query) %i: asking %s who is `%s' (CNAME question)\n",dns->id,inet_ntoa(sai.sin_addr),dns->cname);
#endif /* DEBUG */ #endif /* DEBUG */
sz = make_query(packet,dns->cname); sz = make_query(packet,dns->cname);
dns->when = now + 60; dns->when = cx.now + 60;
sai.sin_family = AF_INET; sai.sin_family = AF_INET;
sai.sin_port = htons(53); sai.sin_port = htons(53);
((dnsQuery*)packet)->qid = htons(dns->id); ((dnsQuery*)packet)->qid = htons(dns->id);
@ -572,7 +572,7 @@ void rawdns(const char *hostname)
item = (dnsList*)Calloc(sizeof(dnsList) + strlen(hostname)); item = (dnsList*)Calloc(sizeof(dnsList) + strlen(hostname));
stringcpy(item->host,hostname); stringcpy(item->host,hostname);
item->id = ntohs(query->qid); item->id = ntohs(query->qid);
item->when = now + 30; item->when = cx.now + 30;
item->next = dnslist; item->next = dnslist;
dnslist = item; dnslist = item;
@ -611,7 +611,7 @@ restart:
pdns = &dnslist; pdns = &dnslist;
while(*pdns) while(*pdns)
{ {
if ((*pdns)->when < now) if ((*pdns)->when < cx.now)
{ {
dns = *pdns; dns = *pdns;
if (dns->cname) if (dns->cname)

View File

@ -92,7 +92,7 @@ void *Calloc(int size)
exit(1); exit(1);
} }
mmep->size = size; mmep->size = size;
mmep->when = now; mmep->when = cx.now;
mmep->doer = mallocdoer; mmep->doer = mallocdoer;
mallocdoer = NULL; mallocdoer = NULL;
return((void*)mmep->area+4); return((void*)mmep->area+4);
@ -405,7 +405,7 @@ char *idle2str(time_t when, int small)
char *dst; char *dst;
int n,z[4]; int n,z[4];
when = now - when; when = cx.now - when;
z[0] = when / 86400; z[0] = when / 86400;
z[1] = (when -= z[0] * 86400) / 3600; 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"); debug("testpath %s -> result %s\n",argv[1],(r) ? "TRUE" : "FALSE");
} }
time(&now); time(&cx.now);
for(r=0;r<10;r++) 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("\nmaketimestr %s\n",maketimestr(when,TFMT_LOG));
debug("maketimestr %s\n",maketimestr(when,TFMT_FULL)); debug("maketimestr %s\n",maketimestr(when,TFMT_FULL));
debug("maketimestr %s\n",maketimestr(when,TFMT_AWAY)); debug("maketimestr %s\n",maketimestr(when,TFMT_AWAY));

View File

@ -44,16 +44,22 @@ struct CoreData /* Collect core data all in one place */
time_t now; time_t now;
time_t system_uptime; time_t system_uptime;
Mech *current; Mech *current;
char *from;
char *to;
char *rest;
char *rest_end; char *rest_end;
char *chop_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 socksmodified;
int hisock; int hisock;
int short_tv; int short_tv;
User CoreUser;
User LocalBot;
}; };
BEG struct CoreData cx; BEG struct CoreData cx;
#define now cx.now
#define current cx.current #define current cx.current
#define DEFAULTCMDCHAR '-' #define DEFAULTCMDCHAR '-'
@ -130,9 +136,6 @@ BEG const OnMsg *CurrentCmd MDEF(NULL);
BEG User *cfgUser MDEF(NULL); BEG User *cfgUser MDEF(NULL);
BEG const char *global_from 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 * generic output buffer, can be used as buffer in any `leaf' function
@ -458,7 +461,7 @@ const Strp CMA =
ShortClient CoreClient = ShortClient CoreClient =
{ {
NULL, /* next */ NULL, /* next */
(User*)&CoreUser, /* user */ (User*)&cx.CoreUser, /* user */
-1, /* socket */ -1, /* socket */
0, /* flags */ 0, /* flags */
0, /* inputcount */ 0, /* inputcount */
@ -489,8 +492,6 @@ struct
extern const uchar tolowertab[]; extern const uchar tolowertab[];
extern const uchar nickcmptab[]; extern const uchar nickcmptab[];
extern const uchar attrtab[]; extern const uchar attrtab[];
extern const User xxCoreUser;
extern const User xxLocalBot;
extern ShortClient CoreClient; extern ShortClient CoreClient;
extern ShortChan CoreChan; extern ShortChan CoreChan;

View File

@ -229,7 +229,7 @@ void usage_command(char *to, const char *arg)
char *pt; char *pt;
int i; 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; return;
for(i=0;ulist[i].command;i++) for(i=0;ulist[i].command;i++)
{ {

View File

@ -79,7 +79,7 @@ int monitor_fs(const char *file)
set_mallocdoer(monitor_fs); set_mallocdoer(monitor_fs);
fnew = Calloc(sizeof(FileMon) + strlen(file)); fnew = Calloc(sizeof(FileMon) + strlen(file));
fnew->fd = ino; fnew->fd = ino;
fnew->nospam = now; fnew->nospam = cx.now;
stringcpy(fnew->filename,file); stringcpy(fnew->filename,file);
fnew->next = filemonlist; fnew->next = filemonlist;
@ -254,9 +254,9 @@ void process_monitor(void)
#endif /* DEBUG */ #endif /* DEBUG */
if ((ivent->mask & IN_CLOSE_WRITE) == IN_CLOSE_WRITE) if ((ivent->mask & IN_CLOSE_WRITE) == IN_CLOSE_WRITE)
return; return;
if (fmon->nospam > now-30) if (fmon->nospam > (cx.now - 30))
return; return;
fmon->nospam = now; fmon->nospam = cx.now;
send_global(SPYSTR_SYSMON,"Alert: file ``%s'' was touched",fmon->filename); send_global(SPYSTR_SYSMON,"Alert: file ``%s'' was touched",fmon->filename);
} }
} }

View File

@ -679,7 +679,7 @@ int killsock(int sock)
{ {
set_mallocdoer(killsock); set_mallocdoer(killsock);
ks = (KillSock*)Calloc(sizeof(KillSock)); ks = (KillSock*)Calloc(sizeof(KillSock));
ks->time = now; ks->time = cx.now;
ks->sock = sock; ks->sock = sock;
ks->next = killsocks; ks->next = killsocks;
killsocks = ks; killsocks = ks;
@ -731,7 +731,7 @@ int killsock(int sock)
if ((n == 0) || ((n == -1) && (errno != EAGAIN))) if ((n == 0) || ((n == -1) && (errno != EAGAIN)))
remove_ks(ks); remove_ks(ks);
} }
if ((now - ks->time) > KILLSOCKTIMEOUT) if ((cx.now - ks->time) > KILLSOCK_TIMEOUT)
remove_ks(ks); remove_ks(ks);
ks = ksnext; ks = ksnext;
} }

View File

@ -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 = (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->t = t;
ir->when = now; ir->when = cx.now;
pt = stringcat(ir->from,from) + 1; pt = stringcat(ir->from,from) + 1;
if (nick) if (nick)

View File

@ -209,7 +209,7 @@ struct
int sig_hup_callback(char *line) 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); return(FALSE);
} }
@ -221,7 +221,7 @@ void do_sighup(void)
CurrentShit = NULL; CurrentShit = NULL;
CurrentChan = NULL; CurrentChan = NULL;
CurrentUser = (User*)&CoreUser; CurrentUser = (User*)&cx.CoreUser;
CurrentDCC = (Client*)&CoreClient; CurrentDCC = (Client*)&CoreClient;
*CurrentNick = 0; *CurrentNick = 0;
@ -321,7 +321,7 @@ void sig_usr1(int crap)
*/ */
void sig_usr2(int crap) void sig_usr2(int crap)
{ {
time(&now); time(&cx.now);
debug("(sigusr2)\n"); debug("(sigusr2)\n");
signal(SIGUSR2,sig_usr2); signal(SIGUSR2,sig_usr2);
@ -420,7 +420,7 @@ void sig_abrt(int crap)
*/ */
void sig_bus(int crap) void sig_bus(int crap)
{ {
time(&now); time(&cx.now);
respawn++; respawn++;
if (respawn > 10) if (respawn > 10)
@ -438,27 +438,42 @@ void sig_bus(int crap)
/* /*
* SIGSEGV shows no mercy, cant schedule it. * 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 <sys/ucontext.h> #include <sys/ucontext.h>
void sig_segv(int crap, siginfo_t *si, void *uap) void sig_segv(int sig, siginfo_t *si, void *context)
{ {
mcontext_t *mctx; ucontext_t *crashcontext = (ucontext_t*)context;
greg_t *rsp,*rip; /* general registers */ char *sp,*ip; /* general registers */
time(&now);
startup = STARTUP_SIGSEGV; startup = STARTUP_SIGSEGV;
debug("(sigsegv) trying to access "mx_pfmt"\n",(mx_ptr)si->si_addr); #if defined(__x86_64__)
mctx = &((ucontext_t *)uap)->uc_mcontext; ip = (char*)crashcontext->uc_mcontext.gregs[16];
rsp = &mctx->gregs[15]; /* RSP, 64-bit stack pointer */ sp = (char*)crashcontext->uc_mcontext.gregs[15];
rip = &mctx->gregs[16]; /* RIP, 64-bit instruction pointer */ #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) sig_segv() = "mx_pfmt"\n",(mx_ptr)sig_segv);
debug("(sigsegv) do_crash() = "mx_pfmt"\n",(mx_ptr)do_crash); debug("(sigsegv) do_crash() = "mx_pfmt"\n",(mx_ptr)do_crash);
if (debug_on_exit) if (debug_on_exit)
{ {
time(&cx.now);
run_debug(); run_debug();
debug_on_exit = FALSE; debug_on_exit = FALSE;
} }
@ -472,11 +487,11 @@ void sig_segv(int crap, siginfo_t *si, void *uap)
/* NOT REACHED */ /* 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) void sig_segv(int signum)
{ {
time(&now); startup = STARTUP_SIGSEGV;
#ifdef DEBUG #ifdef DEBUG
if (debug_on_exit) if (debug_on_exit)
@ -495,7 +510,7 @@ void sig_segv(int signum)
/* NOT REACHED */ /* NOT REACHED */
} }
#endif /* else defined(__linux__) && defined(__x86_64__) && defined(DEBUG) && !defined(__STRICT_ANSI__) */ #endif /* else defined(__linux__) && defined(DEBUG) && !defined(__STRICT_ANSI__) */
/* /*
* SIGTERM * SIGTERM
@ -506,8 +521,6 @@ void sig_term(int signum)
exit(0); exit(0);
#endif /* __profiling__ */ #endif /* __profiling__ */
time(&now);
#ifdef DEBUG #ifdef DEBUG
debug("(sigterm)\n"); debug("(sigterm)\n");
#endif /* DEBUG */ #endif /* DEBUG */
@ -532,13 +545,13 @@ void mainloop(void)
time_t last_update; time_t last_update;
last_update = now; last_update = cx.now;
/* /*
* init update times so that they dont all run right away * init update times so that they dont all run right away
*/ */
this.tenminute = now / 600; this.tenminute = cx.now / 600;
this.hour = now / 3600; this.hour = cx.now / 3600;
/* /*
* The Main Loop * The Main Loop
@ -564,9 +577,9 @@ mainloop:
/* /*
* check for regular updates * check for regular updates
*/ */
if (last_update != now) if (last_update != cx.now)
{ {
last_update = now; last_update = cx.now;
update(&this); update(&this);
} }
@ -610,7 +623,7 @@ mainloop:
if ((sp = find_server(current->server))) if ((sp = find_server(current->server)))
{ {
if ((now - current->conntry) > ctimeout) if ((cx.now - current->conntry) > ctimeout)
{ {
#ifdef DEBUG #ifdef DEBUG
debug("(doit) RAWDNS timed out (%s)\n",sp->name); debug("(doit) RAWDNS timed out (%s)\n",sp->name);
@ -636,27 +649,27 @@ mainloop:
{ {
if (current->connect == CN_SPINNING) if (current->connect == CN_SPINNING)
{ {
if ((now - current->conntry) >= 60) if ((cx.now - current->conntry) >= 60)
connect_to_server(); connect_to_server();
} }
else else
{ {
doit_jumptonext: doit_jumptonext:
cx.short_tv |= TV_SERVCONNECT; cx.short_tv |= TV_SERVCONNECT;
if ((now - current->conntry) >= 2) if ((cx.now - current->conntry) >= 2)
connect_to_server(); connect_to_server();
} }
} }
#else /* ! RAWDNS */ #else /* ! RAWDNS */
if (current->connect == CN_SPINNING) if (current->connect == CN_SPINNING)
{ {
if ((now - current->conntry) >= 60) if ((cx.now - current->conntry) >= 60)
connect_to_server(); connect_to_server();
} }
else else
{ {
cx.short_tv |= TV_SERVCONNECT; cx.short_tv |= TV_SERVCONNECT;
if ((now - current->conntry) >= 2) if ((cx.now - current->conntry) >= 2)
connect_to_server(); connect_to_server();
} }
#endif /* RAWDNS */ #endif /* RAWDNS */
@ -676,7 +689,7 @@ doit_jumptonext:
if ((current->connect == CN_TRYING) || (current->connect == CN_CONNECTED)) if ((current->connect == CN_TRYING) || (current->connect == CN_CONNECTED))
{ {
cx.short_tv |= TV_SERVCONNECT; cx.short_tv |= TV_SERVCONNECT;
if ((now - current->conntry) > ctimeout) if ((cx.now - current->conntry) > ctimeout)
{ {
#ifdef DEBUG #ifdef DEBUG
debug("(doit) {%i} Connection timed out\n",current->sock); debug("(doit) {%i} Connection timed out\n",current->sock);
@ -756,7 +769,7 @@ restart_dcc:
/* /*
* Update current time * Update current time
*/ */
time(&now); time(&cx.now);
for(current=botlist;current;current=current->next) for(current=botlist;current;current=current->next)
{ {
@ -765,8 +778,8 @@ restart_dcc:
* it is important that the check is done before anything * it is important that the check is done before anything
* else that could potentially send output to the server! * else that could potentially send output to the server!
*/ */
if (current->sendq_time < now) if (current->sendq_time < cx.now)
current->sendq_time = now; current->sendq_time = cx.now;
} }
for(current=botlist;current;current=current->next) for(current=botlist;current;current=current->next)
@ -796,10 +809,10 @@ restart_dcc:
*/ */
if (current->setting[TOG_NOIDLE].int_var) if (current->setting[TOG_NOIDLE].int_var)
{ {
if ((now - current->lastantiidle) > PINGSENDINTERVAL) if ((cx.now - current->lastantiidle) > PINGSENDINTERVAL)
{ {
to_server("PRIVMSG * :0\n"); 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 * 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; qm = current->sendq;
to_server(FMT_PLAINLINE,qm->p); to_server(FMT_PLAINLINE,qm->p);
@ -890,7 +903,7 @@ restart_die:
#endif #endif
#ifdef TRIVIA #ifdef TRIVIA
if (triv_next_time && (now >= triv_next_time)) if (triv_next_time && (cx.now >= triv_next_time))
trivia_tick(); trivia_tick();
#endif /* TRIVIA */ #endif /* TRIVIA */
@ -918,8 +931,9 @@ void parse_commandline(int argc, char **argv, char **envp)
#ifdef NEWBIE #ifdef NEWBIE
int n = 0; int n = 0;
#endif #endif
memset(&cx,0,sizeof(cx));
uptime = time(&now); uptime = time(&cx.now);
startup = STARTUP_NORMALSTART; startup = STARTUP_NORMALSTART;
if ((getuid() == 0) || (geteuid() == 0)) if ((getuid() == 0) || (geteuid() == 0))
@ -936,7 +950,7 @@ void parse_commandline(int argc, char **argv, char **envp)
cx.system_uptime = st.st_ctime; cx.system_uptime = st.st_ctime;
} }
srand(now+getpid()); srand(cx.now + getpid());
/* /*
* Code to detect and recover after a RESET * 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; ia_default.s_addr = LOCALHOST_ULONG;
#endif /* RAWDNS */ #endif /* RAWDNS */
memset(&__internal_users,0,sizeof(User)*2); cx.CoreUser.x.x.access = 100;
CoreUser.x.x.access = 100; cx.LocalBot.x.x.access = 200;
LocalBot.x.x.access = 200; cx.LocalBot.x.x.aop = 1;
LocalBot.x.x.aop = 1; cx.LocalBot.chan = cx.CoreUser.chan = (Strp*)&CMA;
LocalBot.chan = CoreUser.chan = (Strp*)&CMA;
readcfgfile(); readcfgfile();
@ -1259,7 +1272,7 @@ void parse_commandline(int argc, char **argv, char **envp)
#endif /* CTCP */ #endif /* CTCP */
#ifdef BOTNET #ifdef BOTNET
last_autolink = now + 30 + (rand() >> 27); /* + 0-31 seconds */ last_autolink = cx.now + 30 + (rand() >> 27); /* + 0-31 seconds */
#endif /* BOTNET */ #endif /* BOTNET */
if (mechresetenv) if (mechresetenv)

View File

@ -294,7 +294,7 @@ int connect_to_bot(NetCfg *cfg)
bn->sock = s; bn->sock = s;
bn->status = BN_CONNECT; bn->status = BN_CONNECT;
bn->when = now; bn->when = cx.now;
bn->guid = cfg->guid; bn->guid = cfg->guid;
bn->next = botnetlist; bn->next = botnetlist;
@ -487,7 +487,7 @@ void basicAuth(BotNet *bn, char *rest)
debug("(basicAuth) bn->tick = 0\n"); debug("(basicAuth) bn->tick = 0\n");
#endif /* DEBUG */ #endif /* DEBUG */
bn->tick = 0; 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) void basicAuthOK(BotNet *bn, char *rest)
@ -501,7 +501,7 @@ void basicAuthOK(BotNet *bn, char *rest)
debug("(basicAuthOK) bn->tick = 0\n"); debug("(basicAuthOK) bn->tick = 0\n");
#endif /* DEBUG */ #endif /* DEBUG */
bn->tick = 0; 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) void basicBanner(BotNet *bn, char *rest)
@ -619,7 +619,7 @@ void basicBanner(BotNet *bn, char *rest)
/* /*
* update timestamp * update timestamp
*/ */
bn->when = now; bn->when = cx.now;
/* /*
* if the remote bot initiated the connection we need a valid pass from them * 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->addsession = 0;
bn->tick++; bn->tick++;
to_file(bn->sock,"UT%i\n",bn->tick); to_file(bn->sock,"UT%i\n",bn->tick);
bn->tick_last = now; bn->tick_last = cx.now;
break; break;
case '*': case '*':
case '#': case '#':
@ -1428,7 +1428,7 @@ void botnet_newsock(void)
bn->sock = s; bn->sock = s;
bn->status = BN_UNKNOWN; bn->status = BN_UNKNOWN;
bn->lsid = rand(); bn->lsid = rand();
bn->when = now; bn->when = cx.now;
bn->next = botnetlist; bn->next = botnetlist;
botnetlist = bn; botnetlist = bn;
@ -1436,7 +1436,7 @@ void botnet_newsock(void)
/* /*
* crude... but, should work * crude... but, should work
*/ */
last_autolink = now + AUTOLINK_DELAY; last_autolink = cx.now + AUTOLINK_DELAY;
} }
/* /*
@ -1466,9 +1466,9 @@ void select_botnet(void)
/* /*
* autolink * 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) if (autolink_cfg)
autolink_cfg = autolink_cfg->next; autolink_cfg = autolink_cfg->next;
@ -1513,12 +1513,12 @@ void process_botnet(void)
/* /*
* usersharing tick, 10 minute period * 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 #ifdef DEBUG
debug("(process_botnet) {%i} periodic ushare tick\n",bn->sock); debug("(process_botnet) {%i} periodic ushare tick\n",bn->sock);
#endif /* DEBUG */ #endif /* DEBUG */
bn->tick_last = now; bn->tick_last = cx.now;
to_file(bn->sock,"UT%i\n",bn->tick); to_file(bn->sock,"UT%i\n",bn->tick);
} }
@ -1542,7 +1542,7 @@ void process_botnet(void)
else else
{ {
bn->status = BN_BANNERSENT; bn->status = BN_BANNERSENT;
bn->when = now; bn->when = cx.now;
} }
/* write_fds is only set for sockets where reading is not needed */ /* write_fds is only set for sockets where reading is not needed */
continue; 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 #ifdef DEBUG
debug("(process_botnet) {%i} Life is good; but not for this guy (guid == %i). Timeout!\n", debug("(process_botnet) {%i} Life is good; but not for this guy (guid == %i). Timeout!\n",
@ -1698,7 +1698,7 @@ usage:
pp = &cfg->next; pp = &cfg->next;
} }
if (CurrentUser == &CoreUser || mode == '+') if (CurrentUser == &cx.CoreUser || mode == '+')
{ {
if (cfg) if (cfg)
{ {

View File

@ -63,7 +63,7 @@ int catch_note(char *from, char *to, char *rest)
append_strp(&u->note,rest); append_strp(&u->note,rest);
return(TRUE); return(TRUE);
} }
if ((now - n->start) > 120) if ((cx.now - n->start) > 120)
{ {
*pp = n->next; *pp = n->next;
Free((char**)&n); Free((char**)&n);
@ -99,7 +99,7 @@ void do_note(COMMAND_ARGS)
set_mallocdoer(do_note); set_mallocdoer(do_note);
n = Calloc(sizeof(Note) + StrlenX(from,to,u->name,NULL)); n = Calloc(sizeof(Note) + StrlenX(from,to,u->name,NULL));
n->start = now; n->start = cx.now;
n->next = notelist; n->next = notelist;
notelist = n; notelist = n;
@ -110,7 +110,7 @@ void do_note(COMMAND_ARGS)
/* /*
* add a note header * 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); append_strp(&u->note,header);
} }

View File

@ -168,7 +168,7 @@ void on_kick(char *from, char *rest)
if (victim) if (victim)
{ {
#ifdef SEEN #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 */ #endif /* SEEN */
/* /*
@ -300,7 +300,7 @@ void on_nick(char *from, char *newnick)
sprintf(newnuh,"%s!%s",newnick,getuh(from)); sprintf(newnuh,"%s!%s",newnick,getuh(from));
#ifdef SEEN #ifdef SEEN
make_seen(CurrentNick,from,newnick,NULL,now,SEEN_NEWNICK); make_seen(CurrentNick,from,newnick,NULL,cx.now,SEEN_NEWNICK);
#endif /* SEEN */ #endif /* SEEN */
/* /*
@ -358,9 +358,9 @@ void on_nick(char *from, char *newnick)
if ((maxcount = chan->setting[INT_NCL].int_var) < 2) if ((maxcount = chan->setting[INT_NCL].int_var) < 2)
continue; 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; cu->action_num[INDEX_NICK] = 1;
} }
else 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; has_cc = TRUE;
} }
@ -634,7 +634,7 @@ recheck_alias:
/* /*
* list of last LASTCMDSIZE commands * list of last LASTCMDSIZE commands
*/ */
if (from != CoreUser.name) if (from != cx.CoreUser.name)
{ {
Free(&current->lastcmds[LASTCMDSIZE-1]); Free(&current->lastcmds[LASTCMDSIZE-1]);
for(j=LASTCMDSIZE-2;j>=0;j--) for(j=LASTCMDSIZE-2;j>=0;j--)
@ -646,13 +646,13 @@ recheck_alias:
if (CurrentUser) if (CurrentUser)
{ {
sprintf(current->lastcmds[0],"[%s] %s\r%s[%-3i]\t(*%s)", 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); (CurrentUser->x.x.access),pt);
} }
else else
{ {
sprintf(current->lastcmds[0],"[%s] %s\r%s[---]\t(*%s)", 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(); check_shit();
update_modes(chan); update_modes(chan);
if (current->spy & SPYF_STATUS) if (current->spy & SPYF_STATUS && doer)
send_spy(SPYSTR_STATUS,"Given op on %s, set by %s",chan->name,nick); send_spy(SPYSTR_STATUS,"Given op on %s, set by %s",chan->name,doer->nick);
} }
} }
/* -o */ else /* -o */ else
@ -897,7 +897,7 @@ modeloop:
#ifdef IRCD_EXTENSIONS #ifdef IRCD_EXTENSIONS
Ban *newban; 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 == 'I') newban->imode = TRUE;
if (*mode == 'e') newban->emode = TRUE; if (*mode == 'e') newban->emode = TRUE;
/* /*
@ -905,7 +905,7 @@ modeloop:
*/ */
break; break;
#else /* IRCD_EXTENSIONS */ #else /* IRCD_EXTENSIONS */
make_ban(&chan->banlist,from,parm,now); make_ban(&chan->banlist,from,parm,cx.now);
#endif /* IRCD_EXTENSIONS */ #endif /* IRCD_EXTENSIONS */
/* /*
* skip protection checks if the doer is myself or another known bot * skip protection checks if the doer is myself or another known bot

View File

@ -67,7 +67,7 @@ void parse_invite(char *from, char *rest)
if ((i >= JOINLEVEL) && (i < BOTLEVEL)) if ((i >= JOINLEVEL) && (i < BOTLEVEL))
{ {
join_channel(chan,NULL); 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 = chan->stats;
stats->userseconds = 0; stats->userseconds = 0;
stats->users = 0; stats->users = 0;
stats->lastuser = now; stats->lastuser = cx.now;
stats->flags |= CSTAT_PARTIAL; stats->flags |= CSTAT_PARTIAL;
} }
#endif /* STATS */ #endif /* STATS */
@ -151,7 +151,7 @@ void parse_join(char *from, char *rest)
*/ */
if (is_bot(from)) if (is_bot(from))
{ {
CurrentUser = (User*)&LocalBot; CurrentUser = (User*)&cx.LocalBot;
CurrentShit = NULL; CurrentShit = NULL;
} }
else else
@ -259,7 +259,7 @@ void parse_notice(char *from, char *rest)
if (!stringcasecmp(ctcp,"PING") && ((pingtime = get_number(rest)) != -1)) if (!stringcasecmp(ctcp,"PING") && ((pingtime = get_number(rest)) != -1))
{ {
send_spy(SPYSTR_STATUS,"[CTCP PING Reply From %s] %i second(s)", send_spy(SPYSTR_STATUS,"[CTCP PING Reply From %s] %i second(s)",
CurrentNick,(int)(now - pingtime)); CurrentNick,(int)(cx.now - pingtime));
} }
else else
{ {
@ -333,7 +333,7 @@ void parse_part(char *from, char *rest)
#endif /* STATS */ #endif /* STATS */
#ifdef SEEN #ifdef SEEN
make_seen(nick,from,channel,NULL,now,SEEN_PARTED); make_seen(nick,from,channel,NULL,cx.now,SEEN_PARTED);
#endif /* SEEN */ #endif /* SEEN */
remove_chanuser(chan,nick); remove_chanuser(chan,nick);
@ -391,7 +391,7 @@ void parse_privmsg(char *from, char *rest)
{ {
if ((cu = find_chanuser(CurrentChan,from))) if ((cu = find_chanuser(CurrentChan,from)))
{ {
cu->idletime = now; cu->idletime = cx.now;
if (cu->shit) if (cu->shit)
return; return;
CurrentUser = cu->user; CurrentUser = cu->user;
@ -457,7 +457,7 @@ void parse_quit(char *from, char *rest)
nickcpy(CurrentNick,from); nickcpy(CurrentNick,from);
#ifdef SEEN #ifdef SEEN
make_seen(CurrentNick,from,rest,NULL,now,SEEN_QUIT); make_seen(CurrentNick,from,rest,NULL,cx.now,SEEN_QUIT);
#endif /* SEEN */ #endif /* SEEN */
#ifdef FASTNICK #ifdef FASTNICK
@ -557,8 +557,8 @@ void parse_251(char *from, char *rest)
{ {
if (!stringcasecmp(sp->name,from) || !stringcasecmp(sp->realname,from)) if (!stringcasecmp(sp->name,from) || !stringcasecmp(sp->realname,from))
{ {
sp->lastconnect = now; sp->lastconnect = cx.now;
current->ontime = now; current->ontime = cx.now;
current->server = sp->ident; current->server = sp->ident;
} }
} }
@ -985,7 +985,7 @@ void parse_352(char *from, char *rest)
#ifdef DEBUG #ifdef DEBUG
debug("(parse_352) setting as local bot: %s (%s)\n",nuh,channel); debug("(parse_352) setting as local bot: %s (%s)\n",nuh,channel);
#endif /* DEBUG */ #endif /* DEBUG */
chan->users->user = (User*)&LocalBot; chan->users->user = (User*)&cx.LocalBot;
chan->users->shit = NULL; chan->users->shit = NULL;
} }
else else
@ -1048,7 +1048,7 @@ void parse_367(char *from, char *rest)
banfrom = "?"; banfrom = "?";
if ((bantime = get_number(rest)) == -1) if ((bantime = get_number(rest)) == -1)
bantime = now; bantime = cx.now;
make_ban(&chan->banlist,banfrom,banmask,bantime); make_ban(&chan->banlist,banfrom,banmask,bantime);
} }
@ -1068,12 +1068,12 @@ void parse_376(char *from, char *rest)
{ {
if (*sp->realname == 0) if (*sp->realname == 0)
stringcpy_n(sp->realname,from,NAMELEN); stringcpy_n(sp->realname,from,NAMELEN);
sp->lastconnect = now; sp->lastconnect = cx.now;
} }
if (current->connect != CN_ONLINE) if (current->connect != CN_ONLINE)
{ {
current->connect = CN_ONLINE; current->connect = CN_ONLINE;
current->ontime = now; current->ontime = cx.now;
to_server("WHOIS %s\n",getbotnick(current)); to_server("WHOIS %s\n",getbotnick(current));
if ((mode = current->setting[STR_UMODES].str_var)) if ((mode = current->setting[STR_UMODES].str_var))
to_server("MODE %s %s\n",getbotnick(current),mode); to_server("MODE %s %s\n",getbotnick(current),mode);
@ -1228,7 +1228,7 @@ void parse_346(char *from, char *rest)
banfrom = "?"; banfrom = "?";
if ((bantime = get_number(rest)) == -1) if ((bantime = get_number(rest)) == -1)
bantime = now; bantime = cx.now;
new = make_ban(&chan->banlist,banfrom,banmask,bantime); new = make_ban(&chan->banlist,banfrom,banmask,bantime);
new->imode = TRUE; new->imode = TRUE;
@ -1258,7 +1258,7 @@ void parse_348(char *from, char *rest)
banfrom = "?"; banfrom = "?";
if ((bantime = get_number(rest)) == -1) if ((bantime = get_number(rest)) == -1)
bantime = now; bantime = cx.now;
new = make_ban(&chan->banlist,banfrom,banmask,bantime); new = make_ban(&chan->banlist,banfrom,banmask,bantime);
new->emode = TRUE; new->emode = TRUE;

View File

@ -55,7 +55,7 @@ check_telnet_malloc:
client->fileno = -1; client->fileno = -1;
#endif /* DCC_FILE */ #endif /* DCC_FILE */
client->flags = DCC_TELNETPASS; client->flags = DCC_TELNETPASS;
client->lasttime = now; client->lasttime = cx.now;
client->next = current->clientlist; client->next = current->clientlist;
current->clientlist = client; current->clientlist = client;
#ifdef DEBUG #ifdef DEBUG
@ -119,12 +119,12 @@ void partyline_banner(Client *client)
char tmp[MSGLEN]; char tmp[MSGLEN];
client->flags = DCC_ACTIVE; client->flags = DCC_ACTIVE;
client->lasttime = now; client->lasttime = cx.now;
sprintf(tmp,"[%s] %s[%i] has connected", sprintf(tmp,"[%s] %s[%i] has connected",
getbotnick(current),client->user->name,(int)client->user->x.x.access); 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; client->flags = DCC_DELETE;
return; return;
@ -170,7 +170,7 @@ void dcc_chat(char *from)
client->user = user; client->user = user;
client->sock = sock; client->sock = sock;
client->flags = DCC_WAIT; client->flags = DCC_WAIT;
client->lasttime = now; client->lasttime = cx.now;
client->next = current->clientlist; client->next = current->clientlist;
current->clientlist = client; current->clientlist = client;
@ -244,8 +244,8 @@ void do_whom(COMMAND_ARGS)
table_buffer(TEXT_WHOMSELFLINE,getbotnick(bot),(bot == current) ? "(me)" : "b200",stt); table_buffer(TEXT_WHOMSELFLINE,getbotnick(bot),(bot == current) ? "(me)" : "b200",stt);
for(client=bot->clientlist;client;client=client->next) for(client=bot->clientlist;client;client=client->next)
{ {
m = (now - client->lasttime) / 60; m = (cx.now - client->lasttime) / 60;
s = (now - client->lasttime) % 60; s = (cx.now - client->lasttime) % 60;
table_buffer(TEXT_WHOMUSERLINE, table_buffer(TEXT_WHOMUSERLINE,
#ifdef TELNET #ifdef TELNET
client->user->name,client->user->x.x.access,(client->flags & DCC_TELNET) ? "telnet" : "DCC",m,s); client->user->name,client->user->x.x.access,(client->flags & DCC_TELNET) ? "telnet" : "DCC",m,s);

View File

@ -117,7 +117,7 @@ void push_kicks(Chan *chan)
qKick *kick; qKick *kick;
int n; int n;
n = (current->sendq_time - now); n = (current->sendq_time - cx.now);
while(n < 6) while(n < 6)
{ {
if ((kick = chan->kicklist) == NULL) if ((kick = chan->kicklist) == NULL)
@ -243,7 +243,7 @@ void push_modes(Chan *chan, int lowpri)
char *dstflag,*dstparm,lastmode; char *dstflag,*dstparm,lastmode;
int n,maxmodes; int n,maxmodes;
n = (current->sendq_time - now); n = (current->sendq_time - cx.now);
loop: loop:
maxmodes = current->setting[INT_MODES].int_var; maxmodes = current->setting[INT_MODES].int_var;
@ -378,9 +378,9 @@ int check_mass(Chan *chan, ChanUser *doer, int type)
break; 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] = 0;
} }
++(doer->action_num[num]); ++(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]; 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; return;
v[1] = (v[1] < 5) ? 5 : (v[1] > 50) ? 50 : v[1]; v[1] = (v[1] < 5) ? 5 : (v[1] > 50) ? 50 : v[1];
v[2] = (v[2] < 1) ? 1 : (v[2] > 50) ? 50 : v[2]; v[2] = (v[2] < 1) ? 1 : (v[2] > 50) ? 50 : v[2];
chan->lastlimit = now; chan->lastlimit = cx.now;
n = 0; n = 0;
for(cu=chan->users;cu;cu=cu->next) for(cu=chan->users;cu;cu=cu->next)
@ -550,11 +550,11 @@ void process_chanbans(void)
for (current=botlist;current;current=current->next) for (current=botlist;current;current=current->next)
{ {
if (current->lastchanban > (now - 10)) if (current->lastchanban > (cx.now - 10))
{ {
#ifdef DEBUG #ifdef DEBUG
debug("(process_chanbans) skipping %s (%i), (lastchanban (%lu) > now - 10 (%lu)\n", 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 */ #endif /* DEBUG */
continue; 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->flags &= ~CU_CHANBAN;
selcu->lastwhois = now; selcu->lastwhois = cx.now;
current->lastchanban = now; current->lastchanban = cx.now;
pp = &current->sendq; pp = &current->sendq;
while(*pp) while(*pp)
@ -715,7 +715,7 @@ void check_kicksay(Chan *chan, ChanUser *doer, char *text)
mask = format_uh(get_nuh(doer),FUH_USERHOST); mask = format_uh(get_nuh(doer),FUH_USERHOST);
if (action > 2) 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)) if (!(doer->flags & CU_BANNED))
{ {

View File

@ -100,7 +100,7 @@ char *recover_client(char *env)
found_user: found_user:
if (to_file(fd,"[%s] [%s] %s[%i] has connected (reset recover)\n", 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); close(fd);
return(p); return(p);
@ -115,7 +115,7 @@ found_user:
#else #else
client->flags = DCC_ACTIVE; client->flags = DCC_ACTIVE;
#endif /* TELNET */ #endif /* TELNET */
client->lasttime = now; client->lasttime = cx.now;
client->next = current->clientlist; client->next = current->clientlist;
current->clientlist = client; current->clientlist = client;
@ -240,7 +240,7 @@ char *recover_server(char *env)
current->reset = 1; current->reset = 1;
current->sock = fd; current->sock = fd;
current->connect = CN_ONLINE; current->connect = CN_ONLINE;
current->ontime = now; current->ontime = cx.now;
#ifdef IRCD_EXTENSIONS #ifdef IRCD_EXTENSIONS
current->ircx_flags = ircx; current->ircx_flags = ircx;
#endif /* IRCD_EXTENSIONS */ #endif /* IRCD_EXTENSIONS */

View File

@ -142,11 +142,11 @@ void send_ison(void)
* dont send nicks to ISON too often * dont send nicks to ISON too often
*/ */
period = current->setting[INT_ISONDELAY].int_var; period = current->setting[INT_ISONDELAY].int_var;
x = now - current->lastnotify; x = cx.now - current->lastnotify;
if ((x < period) || (lock_ison && (x < 600))) if ((x < period) || (lock_ison && (x < 600)))
return; return;
current->lastnotify = now; current->lastnotify = cx.now;
/* /*
* the nature of the code makes it so that the first NULL is * 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)) if (!nickcmp(nf->nick,nick))
{ {
nf->checked = now; nf->checked = cx.now;
/* /*
* /whois user to get user@host + realname * /whois user to get user@host + realname
*/ */
@ -228,14 +228,14 @@ void catch_ison(char *rest)
{ {
if (nf->checked == 1) if (nf->checked == 1)
{ {
nf->checked = now; nf->checked = cx.now;
if (nf->status >= NF_WHOIS) if (nf->status >= NF_WHOIS)
{ {
/* /*
* close the log entry for this online period * close the log entry for this online period
*/ */
if (nf->log && nf->log->signon && !nf->log->signoff) 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 * 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); set_mallocdoer(catch_whois);
nlog = (nfLog*)Calloc(sizeof(nfLog) + Strlen2(userhost,realname)); // realname is never NULL nlog = (nfLog*)Calloc(sizeof(nfLog) + Strlen2(userhost,realname)); // realname is never NULL
nlog->signon = now; nlog->signon = cx.now;
nlog->next = nf->log; nlog->next = nf->log;
nf->log = nlog; nf->log = nlog;
nlog->realname = stringcat(nlog->userhost,userhost) + 1; nlog->realname = stringcat(nlog->userhost,userhost) + 1;
@ -390,7 +390,7 @@ void write_notifylog(void)
for(nlog=nf->log;nlog;nlog=nlog->next) for(nlog=nf->log;nlog;nlog=nlog->next)
{ {
to_file(fd,"%s %lu %lu %s :%s\n",nf->nick,nlog->signon, 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); nlog->userhost,nlog->realname);
} }
} }
@ -530,7 +530,7 @@ void nfshow_brief(Notify *nf)
if (nf->log && nf->log->signoff) if (nf->log && nf->log->signoff)
{ {
s = mem; s = mem;
when = now - nf->log->signoff; when = cx.now - nf->log->signoff;
d = when / 86400; d = when / 86400;
h = (when -= d * 86400) / 3600; h = (when -= d * 86400) / 3600;
m = (when -= h * 3600) / 60; m = (when -= h * 3600) / 60;
@ -654,7 +654,7 @@ int write_seenlist(void)
for(seen=seenlist;seen;seen=seen->next) for(seen=seenlist;seen;seen=seen->next)
{ {
if ((seen->when - now) > (86400 * SEEN_TIME)) if ((seen->when - cx.now) > (86400 * SEEN_TIME))
continue; continue;
else else
{ {
@ -696,7 +696,7 @@ int read_seenlist_callback(char *rest)
pa = chop(&rest); pa = chop(&rest);
pb = rest; pb = rest;
if ((now - when) < (SEEN_TIME * 86400)) if ((cx.now - when) < (SEEN_TIME * 86400))
{ {
/* if (pa && !*pa) /* if (pa && !*pa)
pa = NULL; chop() doesnt return empty strings */ pa = NULL; chop() doesnt return empty strings */
@ -868,7 +868,7 @@ void do_seen(COMMAND_ARGS)
} }
else else
{ {
when = now - seen->when; when = cx.now - seen->when;
d = when / 86400; d = when / 86400;
h = (when -= d * 86400) / 3600; h = (when -= d * 86400) / 3600;
m = (when -= h * 3600) / 60; m = (when -= h * 3600) / 60;

View File

@ -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 = (Shit*)Calloc(sizeof(Shit) + StrlenX(from,chan,mask,reason,NULL));
shit->action = axs; shit->action = axs;
shit->time = now; shit->time = cx.now;
shit->expire = expire; shit->expire = expire;
shit->next = current->shitlist; 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); remove_shit(save);
save = NULL; save = NULL;
@ -332,10 +332,10 @@ void do_shit(COMMAND_ARGS)
#ifdef DEBUG #ifdef DEBUG
debug("(do_shit) adding %s to %s (Level %i)\n",nuh,channel,shitlevel); debug("(do_shit) adding %s to %s (Level %i)\n",nuh,channel,shitlevel);
#endif /* DEBUG */ #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_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(); check_shit();
} }

View File

@ -89,13 +89,13 @@ void send_spy(const char *src, const char *format, ...)
if (src != SPYSTR_RAWIRC) if (src != SPYSTR_RAWIRC)
continue; continue;
if (spy->data.delay > now) if (spy->data.delay > cx.now)
continue; continue;
/* dont use four-char server messages such as "PING :..." */ /* dont use four-char server messages such as "PING :..." */
if (format[5] == ':') if (format[5] == ':')
continue; continue;
/* create delay until next */ /* 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, sprintf(mysalt,
#ifdef SHACRYPT #ifdef SHACRYPT
@ -103,7 +103,7 @@ void send_spy(const char *src, const char *format, ...)
#else #else
"$1$%04x", "$1$%04x",
#endif /* SHACRYPT */ #endif /* SHACRYPT */
(uint32_t)(now & 0xFFFF)); (uint32_t)(cx.now & 0xFFFF));
/* SHA512 internal returns NULL if strlen(format) > 256 */ /* SHA512 internal returns NULL if strlen(format) > 256 */
stringcpy_n(mydata,format,120); stringcpy_n(mydata,format,120);
@ -189,7 +189,7 @@ void send_spy(const char *src, const char *format, ...)
if (spy->t_src == SPY_STATUS) if (spy->t_src == SPY_STATUS)
{ {
spysrc = maketimestr(now,TFMT_CLOCK); spysrc = maketimestr(cx.now,TFMT_CLOCK);
} }
else else
spysrc = spy->src; spysrc = spy->src;
@ -229,7 +229,7 @@ void send_spy(const char *src, const char *format, ...)
case SPY_FILE: case SPY_FILE:
if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0) 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); close(fd);
} }
} }
@ -539,7 +539,7 @@ void stats_loghour(Chan *chan, char *filename, int hour)
if (!(stats = chan->stats)) if (!(stats = chan->stats))
return; return;
when = (now - (now % 3600)); when = (cx.now - (cx.now % 3600));
if ((fd = open(filename,O_WRONLY|O_APPEND|O_CREAT,NEWFILEMODE)) >= 0) 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->users++;
stats->userpeak = stats->users; stats->userpeak = stats->users;
stats->userlow = stats->users; stats->userlow = stats->users;
stats->lastuser = now; stats->lastuser = cx.now;
stats->flags = CSTAT_PARTIAL; stats->flags = CSTAT_PARTIAL;
} }
/* /*
* add (number of users until now * seconds since last user entered/left) * 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) */ stats->users += plusminus; /* can be both negative (-1), zero (0) and positive (+1) */
if (stats->userpeak < stats->users) if (stats->userpeak < stats->users)

View File

@ -502,6 +502,9 @@ typedef struct Spy
} Spy; } Spy;
typedef struct sockaddr_in sai_v4;
typedef struct sockaddr_in6 sai_v6;
typedef struct Server typedef struct Server
{ {
struct Server *next; struct Server *next;
@ -514,6 +517,11 @@ typedef struct Server
time_t lastattempt; time_t lastattempt;
time_t maxontime; time_t maxontime;
char ipv;
union {
sai_v4 ipv4;
sai_v6 ipv6;
} resolved;
char realname[NAMEBUF]; char realname[NAMEBUF];
char name[NAMEBUF]; char name[NAMEBUF];
char pass[PASSBUF]; char pass[PASSBUF];
@ -537,6 +545,7 @@ typedef struct Mech
uint16_t guid; /* globally uniqe ID */ uint16_t guid; /* globally uniqe ID */
int connect; int connect;
int sock; int sock;
char ipv; /* ip version */
struct in_addr ip; /* for DCC */ struct in_addr ip; /* for DCC */
int server; /* ident of my current server */ int server; /* ident of my current server */
int nextserver; int nextserver;

View File

@ -216,7 +216,7 @@ void trivia_week_toppers(void)
int i,x; int i,x;
chosen[0] = NULL; 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) for(su=scorelist;su;su=su->next)
{ {
@ -364,7 +364,7 @@ void trivia_cleanup(void)
Strp *ans; Strp *ans;
triv_mode = TRIV_WAIT_QUESTION; triv_mode = TRIV_WAIT_QUESTION;
triv_next_time = now + triv_qdelay; triv_next_time = cx.now + triv_qdelay;
while((ans = triv_answers)) while((ans = triv_answers))
{ {
triv_answers = ans->next; triv_answers = ans->next;
@ -389,7 +389,7 @@ void trivia_check(Chan *chan, char *rest)
return; return;
have_answer: 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) 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", 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, 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) if (su == lastwinner)
{ {
@ -558,12 +558,12 @@ stop_trivia:
goto bad_question; goto bad_question;
triv_score = (RANDOM(2,9) + RANDOM(2,10) + RANDOM(2,10)) / 3; 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(); trivia_week_toppers();
triv_weektop10 = now; triv_weektop10 = cx.now;
} }
to_server("PRIVMSG %s :%s\n",triv_chan->name,question); to_server("PRIVMSG %s :%s\n",triv_chan->name,question);
@ -582,7 +582,7 @@ void trivia_tick(void)
if (triv_chan == chan) if (triv_chan == chan)
{ {
current = bot; current = bot;
triv_next_time = now + TRIV_HINT_DELAY; triv_next_time = cx.now + TRIV_HINT_DELAY;
switch(triv_mode) switch(triv_mode)
{ {
case TRIV_WAIT_QUESTION: case TRIV_WAIT_QUESTION:
@ -1070,8 +1070,8 @@ void do_trivia(COMMAND_ARGS)
to_server("PRIVMSG %s :Trivia starting! Get ready...\n",chan->name); to_server("PRIVMSG %s :Trivia starting! Get ready...\n",chan->name);
triv_chan = chan; triv_chan = chan;
triv_mode = TRIV_WAIT_QUESTION; triv_mode = TRIV_WAIT_QUESTION;
triv_next_time = now + triv_qdelay; triv_next_time = cx.now + triv_qdelay;
triv_weektop10 = now; triv_weektop10 = cx.now;
lastwinner = NULL; lastwinner = NULL;
cx.short_tv |= TV_TRIVIA; cx.short_tv |= TV_TRIVIA;
if (!scorelist) if (!scorelist)
@ -1097,7 +1097,7 @@ void do_trivia(COMMAND_ARGS)
if (triv_chan) if (triv_chan)
{ {
uaccess = get_authaccess(from,triv_chan->name); uaccess = get_authaccess(from,triv_chan->name);
if (now > (triv_weektop10 + 300)) if (cx.now > (triv_weektop10 + 300))
n = 1; n = 1;
else else
n = uaccess; n = uaccess;
@ -1105,7 +1105,7 @@ void do_trivia(COMMAND_ARGS)
if (n) if (n)
{ {
trivia_week_toppers(); trivia_week_toppers();
if (!uaccess) triv_weektop10 = now; if (!uaccess) triv_weektop10 = cx.now;
} }
} }
} }

View File

@ -108,7 +108,7 @@ void send_uptime(int type)
{ {
char *host; char *host;
uptimelast = now + 10; uptimelast = cx.now + 10;
if ((host = poll_rawdns(uptimehost))) if ((host = poll_rawdns(uptimehost)))
{ {
if ((uptimeip = inet_addr(host)) != -1) if ((uptimeip = inet_addr(host)) != -1)
@ -133,12 +133,12 @@ void send_uptime(int type)
* update the time when we last sent packet * update the time when we last sent packet
*/ */
sz = (uptimelast + 1) & 7; 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; uptimepackets = uptimepackets + 1;
upPack->packets_sent = htonl(uptimepackets); upPack->packets_sent = htonl(uptimepackets);
upPack->mytime = htonl(now); upPack->mytime = htonl(cx.now);
upPack->regnr = uptimeregnr; upPack->regnr = uptimeregnr;
upPack->type = htonl(type); upPack->type = htonl(type);
upPack->uptime = htonl(uptime); upPack->uptime = htonl(uptime);
@ -201,7 +201,7 @@ void uptime_death(int type)
#ifdef DEBUG #ifdef DEBUG
debug("(uptime_death) sending death message\n"); debug("(uptime_death) sending death message\n");
#endif /* DEBUG */ #endif /* DEBUG */
time(&now); time(&cx.now);
uptimelast = 0; /* avoid resolving the hostname */ uptimelast = 0; /* avoid resolving the hostname */
send_uptime(type); send_uptime(type);
uptimeport = 0; /* avoid sending more packets */ 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); send_uptime(UPTIME_BOTTYPE);
} }

View File

@ -144,7 +144,7 @@ void cfg_shit(char *rest)
* convert the expiry time * convert the expiry time
*/ */
expire = asc2int(chop(&rest)); /* asc2int() can handle NULLs */ expire = asc2int(chop(&rest)); /* asc2int() can handle NULLs */
if (errno || expire < now) if (errno || expire < cx.now)
return; return;
/* /*
@ -157,10 +157,10 @@ void cfg_shit(char *rest)
/* /*
* finally, add the sucker * finally, add the sucker
*/ */
backup_now = now; backup_now = cx.now;
now = when; cx.now = when;
add_shit(from,channel,mask,rest,shitlevel,expire); add_shit(from,channel,mask,rest,shitlevel,expire);
now = backup_now; cx.now = backup_now;
} }
void cfg_kicksay(char *rest) void cfg_kicksay(char *rest)
@ -169,7 +169,7 @@ void cfg_kicksay(char *rest)
backup = CurrentDCC; backup = CurrentDCC;
CurrentDCC = (Client*)&CoreClient; CurrentDCC = (Client*)&CoreClient;
do_kicksay((char*)CoreUser.name,NULL,rest,0); do_kicksay((char*)cx.CoreUser.name,NULL,rest,0);
CurrentDCC = backup; CurrentDCC = backup;
} }

View File

@ -187,7 +187,7 @@ static void ec_loadavg(char *from, const char *to)
void ec_time(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) void ec_set(char *from, const char *to)
@ -490,7 +490,7 @@ second_pass:
{ {
set_usage: set_usage:
#ifdef DEBUG #ifdef DEBUG
if (from == CoreUser.name) if (from == cx.CoreUser.name)
debug("init: set error: %s\n",nullstr(name)); debug("init: set error: %s\n",nullstr(name));
#endif #endif
usage(from); /* usage for CurrentCmd->name */ usage(from); /* usage for CurrentCmd->name */

View File

@ -474,7 +474,7 @@ void process_web(void)
new = (WebSock*)Calloc(sizeof(WebSock)); new = (WebSock*)Calloc(sizeof(WebSock));
new->sock = s; new->sock = s;
new->status = WEB_WAITURL; new->status = WEB_WAITURL;
new->when = now; new->when = cx.now;
new->next = weblist; new->next = weblist;
weblist = new; weblist = new;
} }