Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 1ec09440 authored by deuce's avatar deuce

Update timestr() to take the time_t by value, not by reference.

Remove time32str()
parent de0c44e2
......@@ -308,7 +308,7 @@ char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
if(!strcmp(sp,"EVENT")) {
if(event_time==0)
return("<none>");
return(timestr(&event_time));
return(timestr(event_time));
}
/* LASTCALL */
......@@ -439,7 +439,7 @@ char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
}
if(!strcmp(sp,"LASTON"))
return(timestr(&useron.laston));
return(timestr(useron.laston));
if(!strcmp(sp,"LASTDATEON"))
return(unixtodstr(&cfg,useron.laston,str));
......@@ -508,7 +508,7 @@ char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
return(unixtodstr(&cfg,ns_time,str));
if(!strcmp(sp,"NEWFILETIME"))
return(timestr(&ns_time));
return(timestr(ns_time));
/* MAXDL */
......@@ -961,7 +961,7 @@ char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
if(!strcmp(sp,"MSG_SUBJECT") && current_msg!=NULL)
return(current_msg->subj==NULL ? nulstr : current_msg->subj);
if(!strcmp(sp,"MSG_DATE") && current_msg!=NULL)
return(time32str((time32_t *)&current_msg->hdr.when_written.time));
return(timestr(current_msg->hdr.when_written.time));
if(!strcmp(sp,"MSG_TIMEZONE") && current_msg!=NULL)
return(smb_zonestr(current_msg->hdr.when_written.zone,NULL));
if(!strcmp(sp,"MSG_ATTR") && current_msg!=NULL) {
......
......@@ -1315,7 +1315,7 @@ void sbbs_t::nodemsg()
,username(&cfg,usernumber,tmp),usernumber);
sprintf(buf,text[TelegramFmt]
,thisnode.misc&NODE_ANON ? text[UNKNOWN_USER] : useron.alias
,timestr(&now));
,timestr(now));
i=0;
logbuf[0]=0;
while(online && i<5) {
......
......@@ -213,7 +213,7 @@ ulong sbbs_t::gettimeleft(bool handle_out_of_time)
timeleft=event_time-now;
if(!(sys_status&SS_EVENT)) {
lprintf(LOG_NOTICE,"Node %d Time reduced (to %s) due to upcoming event (%s) on %s"
,cfg.node_num,sectostr(timeleft,tmp),event_code,timestr(&event_time));
,cfg.node_num,sectostr(timeleft,tmp),event_code,timestr(event_time));
sys_status|=SS_EVENT;
}
}
......@@ -234,7 +234,7 @@ ulong sbbs_t::gettimeleft(bool handle_out_of_time)
logline(nulstr,"Ran out of time");
SAVELINE;
if(sys_status&SS_EVENT)
bprintf(text[ReducedTime],timestr(&event_time));
bprintf(text[ReducedTime],timestr(event_time));
bputs(text[TimesUp]);
if(!(sys_status&(SS_EVENT|SS_USERON)) && useron.cdt>=100L*1024L
&& !(cfg.sys_misc&SM_NOCDTCVT)) {
......
......@@ -150,20 +150,13 @@ char* DLLCALL hhmmtostr(scfg_t* cfg, struct tm* tm, char* str)
/* Generates a 24 character ASCII string that represents the time_t pointer */
/* Used as a replacement for ctime() */
/****************************************************************************/
char* DLLCALL time32str(scfg_t *cfg, time32_t *intime, char *str)
{
time_t tmptime=*intime;
return(timestr(cfg,&tmptime,str));
}
char* DLLCALL timestr(scfg_t* cfg, time_t *intime, char* str)
char* DLLCALL timestr(scfg_t* cfg, time_t intime, char* str)
{
char* mer;
uchar hour;
struct tm tm;
if(localtime_r(intime,&tm)==NULL) {
if(localtime_r(&intime,&tm)==NULL) {
strcpy(str,"Invalid Time");
return(str);
}
......
......@@ -409,10 +409,10 @@ int sbbs_t::exec_function(csi_t *csi)
bputs(" for files ");
if(*(csi->ip-1)==CS_FILE_FIND_OLD_UPLOADS) {
l=FI_OLDUL;
bprintf("uploaded before %s\r\n",timestr(&ns_time)); }
bprintf("uploaded before %s\r\n",timestr(ns_time)); }
else if(*(csi->ip-1)==CS_FILE_FIND_OLD) { /* go by download date */
l=FI_OLD;
bprintf("not downloaded since %s\r\n",timestr(&ns_time)); }
bprintf("not downloaded since %s\r\n",timestr(ns_time)); }
else if(*(csi->ip-1)==CS_FILE_FIND_OFFLINE) {
l=FI_OFFLINE;
bputs("not online...\r\n"); }
......
......@@ -532,7 +532,7 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
lp=getintvar(csi,*(int32_t *)csi->ip);
csi->ip+=4; /* Skip int variable name */
if(pp && lp) {
strcpy(str,time32str(lp));
strcpy(str,timestr(*lp));
*pp=copystrvar(csi,*pp,str); }
return(0);
case DATE_STR:
......
......@@ -71,9 +71,9 @@ void sbbs_t::fileinfo(file_t* f)
bprintf(text[FiDescription],f->desc);
bprintf(text[FiUploadedBy],f->misc&FM_ANON ? text[UNKNOWN_USER] : f->uler);
if(f->date)
bprintf(text[FiFileDate],time32str(&f->date));
bprintf(text[FiDateUled],time32str(&f->dateuled));
bprintf(text[FiDateDled],f->datedled ? time32str(&f->datedled) : "Never");
bprintf(text[FiFileDate],timestr(f->date));
bprintf(text[FiDateUled],timestr(f->dateuled));
bprintf(text[FiDateDled],f->datedled ? timestr(f->datedled) : "Never");
bprintf(text[FiTimesDled],f->timesdled);
if(f->size!=-1L)
bprintf(text[FiTransferTime],sectostr(f->timetodl,tmp));
......
......@@ -153,7 +153,7 @@ void sbbs_t::show_msghdr(smbmsg_t* msg)
bprintf(text[MsgFromNet],smb_netaddr(&msg->from_net));
}
bprintf(text[MsgDate]
,time32str((time32_t *)&msg->hdr.when_written.time)
,timestr(msg->hdr.when_written.time)
,smb_zonestr(msg->hdr.when_written.zone,NULL));
CRLF;
......@@ -163,7 +163,7 @@ void sbbs_t::show_msghdr(smbmsg_t* msg)
sender=(char *)msg->hfield_dat[i];
if(msg->hfield[i].type==FORWARDED && sender)
bprintf(text[ForwardedFrom],sender
,time32str((time32_t *)msg->hfield_dat[i])); }
,timestr(*(time32_t *)msg->hfield_dat[i])); }
/* Debug stuff
if(SYSOP) {
......@@ -231,7 +231,7 @@ void sbbs_t::msgtotxt(smbmsg_t* msg, char *str, int header, int tails)
if(msg->from_net.addr)
fprintf(out," (%s)",smb_netaddr(&msg->from_net));
fprintf(out,"\r\nDate : %.24s %s"
,time32str((time32_t *)&msg->hdr.when_written.time)
,timestr(msg->hdr.when_written.time)
,smb_zonestr(msg->hdr.when_written.zone,NULL));
fprintf(out,"\r\n\r\n"); }
......
......@@ -221,8 +221,8 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
SAVELINE;
attr(LIGHTGRAY);
now=time(NULL);
bprintf(text[TiLogon],timestr(&logontime));
bprintf(text[TiNow],timestr(&now));
bprintf(text[TiLogon],timestr(logontime));
bprintf(text[TiNow],timestr(now));
bprintf(text[TiTimeon]
,sectostr(now-logontime,tmp));
bprintf(text[TiTimeLeft]
......
......@@ -912,7 +912,7 @@ js_timestr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
else
JS_ValueToInt32(cx,argv[0],&i);
t=i;
timestr(cfg,&t,str);
timestr(cfg,t,str);
if((js_str = JS_NewStringCopyZ(cx, str))==NULL)
return(JS_FALSE);
......
......@@ -53,7 +53,7 @@ extern "C" BOOL DLLCALL hacklog(scfg_t* cfg, char* prot, char* user, char* text,
sprintf(hdr,"SUSPECTED %s HACK ATTEMPT from %s on %.24s\r\nUsing port %u at %s [%s]\r\nDetails: "
,prot
,user
,timestr(cfg,&now,tstr)
,timestr(cfg,now,tstr)
,addr->sin_port
,host
,inet_ntoa(addr->sin_addr)
......@@ -94,7 +94,7 @@ extern "C" BOOL DLLCALL spamlog(scfg_t* cfg, char* prot, char* action
sprintf(hdr,"SUSPECTED %s SPAM %s on %.24s\r\nHost: %s [%s]\r\nFrom: %.128s %s\r\nReason: "
,prot
,action
,timestr(cfg,&now,tstr)
,timestr(cfg,now,tstr)
,host
,ip_addr
,from
......@@ -115,7 +115,7 @@ void sbbs_t::logentry(char *code, char *entry)
char str[512];
now=time(NULL);
sprintf(str,"Node %2d %s\r\n %s",cfg.node_num,timestr(&now),entry);
sprintf(str,"Node %2d %s\r\n %s",cfg.node_num,timestr(now),entry);
logline(code,str);
}
......@@ -366,7 +366,7 @@ void sbbs_t::errorlog(char *text)
errorlog_inside=0;
return; }
sprintf(hdr,"%s Node %2d: %s #%d"
,timestr(&now),cfg.node_num,useron.alias,useron.number);
,timestr(now),cfg.node_num,useron.alias,useron.number);
write(file,hdr,strlen(hdr));
write(file,crlf,2);
write(file,text,strlen(text));
......
......@@ -494,7 +494,7 @@ bool sbbs_t::logon()
}
if(sys_status&SS_EVENT)
bprintf(text[ReducedTime],timestr(&event_time));
bprintf(text[ReducedTime],timestr(event_time));
getnodedat(cfg.node_num,&thisnode,1);
thisnode.misc&=~(NODE_AOFF|NODE_POFF);
if(useron.chat&CHAT_NOACT)
......@@ -604,7 +604,7 @@ ulong sbbs_t::logonstats()
if((tm.tm_mday>update_tm.tm_mday && tm.tm_mon==update_tm.tm_mon)
|| tm.tm_mon>update_tm.tm_mon || tm.tm_year>update_tm.tm_year) {
sprintf(str,"New Day - Prev: %s ",timestr(&update_t));
sprintf(str,"New Day - Prev: %s ",timestr(update_t));
logentry("!=",str);
sys_status|=SS_DAILY; /* New Day !!! */
......
......@@ -141,7 +141,7 @@ void sbbs_t::telluser(smbmsg_t* msg)
if(n>cfg.sys_nodes) {
now=time(NULL);
sprintf(str,text[UserReadYourMail]
,useron.alias,timestr(&now));
,useron.alias,timestr(now));
putsmsg(&cfg,usernumber,str); }
}
......
......@@ -2565,7 +2565,7 @@ static void smtp_thread(void* arg)
safe_snprintf(str,sizeof(str)
,"\7\1n\1hOn %.24s\r\n\1m%s \1n\1msent you e-mail from: "
"\1h%s\1n\r\n"
,time32str(&scfg,&newmsg.hdr.when_imported.time,tmp)
,timestr(&scfg,newmsg.hdr.when_imported.time,tmp)
,sender,sender_addr);
if(!newmsg.idx.to) { /* Forwarding */
strcat(str,"\1mand it was automatically forwarded to: \1h");
......
......@@ -2401,7 +2401,7 @@ void event_thread(void* arg)
,sbbs->cfg.event[i]->node,sbbs->cfg.event[i]->code);
eprintf(LOG_DEBUG,"%s event last run: %s (0x%08lx)"
,sbbs->cfg.event[i]->code
,time32str(&sbbs->cfg, &sbbs->cfg.event[i]->last, str)
,timestr(&sbbs->cfg, sbbs->cfg.event[i]->last, str)
,sbbs->cfg.event[i]->last);
lastnodechk=0; /* really last event time check */
start=time(NULL);
......
......@@ -163,7 +163,7 @@ ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
p=(char *)msg->hfield_dat[i];
if(msg->hfield[i].type==FORWARDED && p) {
sprintf(str,"Forwarded from %s on %s%c",p
,time32str((time32_t *)msg->hfield_dat[i])
,timestr(*(time32_t *)msg->hfield_dat[i])
,QWK_NEWLINE);
fwrite(str,strlen(str),1,qwk_fp);
size+=strlen(str);
......
......@@ -86,7 +86,7 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode)
SAFECOPY(touser,from);
msgattr=(ushort)(remsg->hdr.attr&MSG_PRIVATE);
sprintf(top,text[RegardingByToOn],title,from,remsg->to
,time32str((time32_t *)&remsg->hdr.when_written.time)
,timestr(remsg->hdr.when_written.time)
,smb_zonestr(remsg->hdr.when_written.zone,NULL));
} else {
title[0]=0;
......
......@@ -384,7 +384,7 @@ void sbbs_t::readmail(uint usernumber, int which)
sprintf(str2,text[Regarding],msg.subj);
else /* Reply to other */
sprintf(str2,text[RegardingByOn],msg.subj,msg.from
,time32str((time32_t *)&msg.hdr.when_written.time));
,timestr(msg.hdr.when_written.time));
p=strrchr(str,'@');
if(p) { /* name @addr */
......
......@@ -119,9 +119,9 @@ void sbbs_t::msghdr(smbmsg_t* msg)
/* fixed fields */
bprintf("%-16.16s %s %s\r\n","when_written"
,time32str((time32_t *)&msg->hdr.when_written.time), smb_zonestr(msg->hdr.when_written.zone,NULL));
,timestr(msg->hdr.when_written.time), smb_zonestr(msg->hdr.when_written.zone,NULL));
bprintf("%-16.16s %s %s\r\n","when_imported"
,time32str((time32_t *)&msg->hdr.when_imported.time), smb_zonestr(msg->hdr.when_imported.zone,NULL));
,timestr(msg->hdr.when_imported.time), smb_zonestr(msg->hdr.when_imported.zone,NULL));
bprintf("%-16.16s %04Xh\r\n","type" ,msg->hdr.type);
bprintf("%-16.16s %04Xh\r\n","version" ,msg->hdr.version);
bprintf("%-16.16s %04Xh\r\n","attr" ,msg->hdr.attr);
......@@ -143,12 +143,12 @@ void sbbs_t::msghdr(smbmsg_t* msg)
if(msg->hdr.times_downloaded)
bprintf("%-16.16s %lu\r\n" ,"times_downloaded" ,msg->hdr.times_downloaded);
if(msg->hdr.last_downloaded)
bprintf("%-16.16s %s\r\n" ,"last_downloaded" ,time32str((time32_t *)&msg->hdr.last_downloaded));
bprintf("%-16.16s %s\r\n" ,"last_downloaded" ,timestr(msg->hdr.last_downloaded));
/* convenience integers */
if(msg->expiration)
bprintf("%-16.16s %s\r\n" ,"expiration"
,time32str((time32_t *)&msg->expiration));
,timestr(msg->expiration));
if(msg->priority)
bprintf("%-16.16s %lu\r\n" ,"priority" ,msg->priority);
if(msg->cost)
......@@ -813,7 +813,7 @@ int sbbs_t::scanposts(uint subnum, long mode, char *find)
break;
sprintf(str2,text[Regarding]
,msg.subj
,time32str((time32_t *)&msg.hdr.when_written.time));
,timestr(msg.hdr.when_written.time));
if(msg.from_net.addr==NULL)
strcpy(str,msg.from);
else if(msg.from_net.type==NET_FIDO)
......
......@@ -438,8 +438,7 @@ public:
bool gettimeleft_inside;
/* str.cpp */
char* time32str(time32_t *intime);
char* timestr(time_t *intime);
char* timestr(time_t intime);
char timestr_output[60];
void userlist(long mode);
size_t gettmplt(char *outstr, char *tmplt, long mode);
......@@ -869,8 +868,7 @@ extern "C" {
DLLEXPORT char * DLLCALL unixtodstr(scfg_t*, time_t, char *str);
DLLEXPORT char * DLLCALL sectostr(uint sec, char *str);
DLLEXPORT char * DLLCALL hhmmtostr(scfg_t* cfg, struct tm* tm, char* str);
DLLEXPORT char * DLLCALL time32str(scfg_t* cfg, time32_t *intime, char* str);
DLLEXPORT char * DLLCALL timestr(scfg_t* cfg, time_t *intime, char* str);
DLLEXPORT char * DLLCALL timestr(scfg_t* cfg, time_t intime, char* str);
DLLEXPORT when_t DLLCALL rfc822date(char* p);
DLLEXPORT char * DLLCALL msgdate(when_t when, char* buf);
......
......@@ -55,7 +55,7 @@ void sbbs_t::scandirs(long mode)
return; }
if(ch!='A') {
if(mode&FL_ULTIME) { /* New file scan */
bprintf(text[NScanHdr],timestr(&ns_time));
bprintf(text[NScanHdr],timestr(ns_time));
str[0]=0; }
else if(mode==FL_NO_HDR) { /* Search for a string */
if(!getfilespec(tmp))
......@@ -117,7 +117,7 @@ void sbbs_t::scanalldirs(long mode)
if(!usrlibs) return;
k=0;
if(mode&FL_ULTIME) { /* New file scan */
bprintf(text[NScanHdr],timestr(&ns_time));
bprintf(text[NScanHdr],timestr(ns_time));
str[0]=0; }
else if(mode==FL_NO_HDR) { /* Search for a string */
if(!getfilespec(tmp))
......
......@@ -247,7 +247,7 @@ void sbbs_t::new_scan_ptr_cfg()
if(t>(long)l)
l=t;
bprintf(text[SubPtrLstFmt],j+1,cfg.sub[usrsub[i][j]]->lname
,timestr(&t),nulstr); }
,timestr(t),nulstr); }
SYNC;
mnemonics(text[WhichOrAll]);
s=getkeys("AQ",usrsubs[i]);
......
......@@ -510,14 +510,13 @@ char *binstr(uchar *buf, ushort length)
/* Generates a 24 character ASCII string that represents the time_t pointer */
/* Used as a replacement for ctime() */
/****************************************************************************/
char *my_timestr(time32_t *intime)
char *my_timestr(time_t intime)
{
static char str[256];
char mer[3],hour;
struct tm *gm;
time_t tt=*intime;
gm=localtime(&tt);
gm=localtime(&intime);
if(gm==NULL) {
strcpy(str,"Invalid Time");
return(str);
......@@ -560,7 +559,7 @@ void dumpindex(ulong start, ulong count)
printf("%4lu %04hX %04hX %04Xh %04Xh %06X %s\n"
,idx.number,idx.from,idx.to,idx.subj,idx.attr
,idx.offset,my_timestr(&idx.time));
,idx.offset,my_timestr(idx.time));
l++;
}
}
......@@ -626,7 +625,7 @@ void dump_hashes(void)
printf("%-10s: %lu\n", "Number", hash.number);
printf("%-10s: %s\n", "Source", smb_hashsourcetype(hash.source));
printf("%-10s: %lu\n", "Length", hash.length);
printf("%-10s: %s\n", "Time", my_timestr(&hash.time));
printf("%-10s: %s\n", "Time", my_timestr(hash.time));
printf("%-10s: %x\n", "Flags", hash.flags);
if(hash.flags&SMB_HASH_CRC16)
printf("%-10s: %04x\n", "CRC-16", hash.crc16);
......@@ -1338,7 +1337,7 @@ void readmsgs(ulong start)
if(msg.from_net.type)
printf(" (%s)",smb_netaddr(&msg.from_net));
printf("\nDate : %.24s %s"
,my_timestr(&msg.hdr.when_written.time)
,my_timestr(msg.hdr.when_written.time)
,smb_zonestr(msg.hdr.when_written.zone,NULL));
printf("\n\n");
......
......@@ -578,7 +578,7 @@ bool sbbs_t::inputnstime(time_t *dt)
char str[256];
bputs(text[NScanDate]);
bputs(timestr(dt));
bputs(timestr(*dt));
CRLF;
if(localtime_r(dt,&tm)==NULL) {
errormsg(WHERE,ERR_CHK,"time ptr",0);
......@@ -836,13 +836,7 @@ bool sbbs_t::trashcan(char *insearchof, char *name)
return(result);
}
char* sbbs_t::time32str(time32_t *intime)
{
time_t intime32=*intime;
return(::timestr(&cfg,&intime32,timestr_output));
}
char* sbbs_t::timestr(time_t *intime)
char* sbbs_t::timestr(time_t intime)
{
return(::timestr(&cfg,intime,timestr_output));
}
......
......@@ -219,7 +219,7 @@ void sbbs_t::temp_xfer()
t=fdate(g.gl_pathv[i]);
bprintf("%-25s %15s %s\r\n",getfname(g.gl_pathv[i])
,ultoac(flength(g.gl_pathv[i]),tmp)
,timestr(&t));
,timestr(t));
files++;
bytes+=flength(g.gl_pathv[i]);
}
......@@ -412,7 +412,7 @@ ulong sbbs_t::create_filelist(char *name, long mode)
return(0); }
k=0;
if(mode&FL_ULTIME) {
sprintf(str,"New files since: %s\r\n",timestr(&ns_time));
sprintf(str,"New files since: %s\r\n",timestr(ns_time));
write(file,str,strlen(str)); }
for(i=j=d=0;i<usrlibs;i++) {
for(j=0;j<usrdirs[i];j++,d++) {
......
......@@ -2446,7 +2446,7 @@ BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host
return(FALSE);
fprintf(fp,"\n; %s %s by %s on %s\n"
,prot,reason,username,timestr(cfg,&now,tstr));
,prot,reason,username,timestr(cfg,now,tstr));
if(host!=NULL)
fprintf(fp,"; Hostname: %s\n",host);
......
......@@ -1170,7 +1170,7 @@ void sbbs_t::automsg()
sprintf(tmp,"%.80s",text[Anonymous]);
else
sprintf(tmp,"%s #%d",useron.alias,useron.number);
sprintf(str,text[AutoMsgBy],tmp,timestr(&now));
sprintf(str,text[AutoMsgBy],tmp,timestr(now));
strcat(str," ");
write(file,str,strlen(str));
write(file,buf,strlen(buf));
......
......@@ -1760,7 +1760,7 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
getnodedat(cfg.node_num,&thisnode,0);
now=time(NULL);
sprintf(str,hungupstr,useron.alias,cfg.xtrn[thisnode.aux-1]->name
,timestr(&now));
,timestr(now));
write(file,str,strlen(str));
close(file);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment