Made several functions multithreat aware

This commit is contained in:
Michiel Broek 2006-01-30 22:27:02 +00:00
parent 90bd1a495c
commit 595a6a0322
17 changed files with 280 additions and 234 deletions

View File

@ -6,7 +6,7 @@ v0.83.11 28-Jan-2006
Added logging for possible detection of dialup IBC neighbour Added logging for possible detection of dialup IBC neighbour
address change. address change.
Added experimental restart for changed resolved FQDN. Added experimental restart for changed resolved FQDN.
Made logging multithread aware. Made several functions multithread aware.
v0.83.10 25-Jan-2006 - 28-Jan-2006 v0.83.10 25-Jan-2006 - 28-Jan-2006

View File

@ -62,6 +62,9 @@ int check_calllist(void)
{ {
int i, found, call_work; int i, found, call_work;
struct _alist *tmp; struct _alist *tmp;
char *buf;
buf = calloc(81, sizeof(char));
/* /*
* Check callist, remove obsolete entries. * Check callist, remove obsolete entries.
@ -77,7 +80,8 @@ int check_calllist(void)
} }
} }
if (!found) { if (!found) {
Syslog('c', "Removing slot %d node %s from calllist", i, fido2str(calllist[i].addr, 0x01f)); fido2str_r(calllist[i].addr, 0x01f, buf);
Syslog('c', "Removing slot %d node %s from calllist", i, buf);
memset(&calllist[i], 0, sizeof(tocall)); memset(&calllist[i], 0, sizeof(tocall));
} }
} }
@ -112,7 +116,8 @@ int check_calllist(void)
if (!found) { if (!found) {
for (i = 0; i < MAXTASKS; i++) { for (i = 0; i < MAXTASKS; i++) {
if (!calllist[i].addr.zone) { if (!calllist[i].addr.zone) {
Syslog('c', "Adding %s to calllist slot %d", fido2str(tmp->addr, 0x1f), i); fido2str_r(tmp->addr, 0x1f, buf);
Syslog('c', "Adding %s to calllist slot %d", buf, i);
calllist[i].addr = tmp->addr; calllist[i].addr = tmp->addr;
calllist[i].cst = tmp->cst; calllist[i].cst = tmp->cst;
calllist[i].callmode = tmp->callmode; calllist[i].callmode = tmp->callmode;
@ -138,12 +143,14 @@ int check_calllist(void)
Syslog('c', "---- ----- ----- --- ------- ------- -------- -------- -------- ----------------"); Syslog('c', "---- ----- ----- --- ------- ------- -------- -------- -------- ----------------");
} }
call_work++; call_work++;
fido2str_r(calllist[i].addr, 0x1f, buf);
Syslog('c', "%4d %s %5d %3d %s %s %08x %08x %08x %s", i, calllist[i].calling?"true ":"false", calllist[i].taskpid, Syslog('c', "%4d %s %5d %3d %s %s %08x %08x %08x %s", i, calllist[i].calling?"true ":"false", calllist[i].taskpid,
calllist[i].cst.tryno, callstatus(calllist[i].cst.trystat), callmode(calllist[i].callmode), calllist[i].cst.tryno, callstatus(calllist[i].cst.trystat), callmode(calllist[i].callmode),
calllist[i].moflags, calllist[i].diflags, calllist[i].ipflags, fido2str(calllist[i].addr, 0x1f)); calllist[i].moflags, calllist[i].diflags, calllist[i].ipflags, buf);
} }
} }
free(buf);
return call_work; return call_work;
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Read mailer last call status * Purpose ...............: Read mailer last call status
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -37,10 +37,9 @@
extern struct sysconfig CFG; extern struct sysconfig CFG;
char *stsname(faddr *); void stsname_r(faddr *, char *);
char *stsname(faddr *addr) void stsname_r(faddr *addr, char *buf)
{ {
static char buf[PATH_MAX];
char *p, *domain=NULL, zpref[8]; char *p, *domain=NULL, zpref[8];
int i; int i;
@ -106,26 +105,29 @@ char *stsname(faddr *addr)
if (domain) if (domain)
free(domain); free(domain);
return buf; return;
} }
callstat *getstatus(faddr *addr) void getstatus_r(faddr *addr, callstat *cst)
{ {
static callstat cst;
FILE *fp; FILE *fp;
char *temp;
cst.trytime = 0; cst->trytime = 0;
cst.tryno = 0; cst->tryno = 0;
cst.trystat = 0; cst->trystat = 0;
temp = calloc(PATH_MAX, sizeof(char));
stsname_r(addr, temp);
if ((fp = fopen(stsname(addr), "r"))) { if ((fp = fopen(temp, "r"))) {
fread(&cst, sizeof(callstat), 1, fp); fread(cst, sizeof(callstat), 1, fp);
fclose(fp); fclose(fp);
} }
free(temp);
return &cst; return;
} }

View File

@ -11,6 +11,6 @@ typedef struct _callstat {
} callstat; } callstat;
callstat *getstatus(faddr*); void getstatus_r(faddr *, callstat *);
#endif #endif

View File

@ -472,7 +472,10 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
return 0; return 0;
case 0: case 0:
/* From Paul Vixies cron: */ /* From Paul Vixies cron: */
(void)setsid(); /* It doesn't seem to help */ rc = setsid(); /* It doesn't seem to help */
if (rc == -1)
Syslog('?', "$Launch: setsid()");
close(0); close(0);
if (open("/dev/null", O_RDONLY) != 0) { if (open("/dev/null", O_RDONLY) != 0) {
Syslog('?', "$Launch: \"%s\": reopen of stdin to /dev/null failed", buf); Syslog('?', "$Launch: \"%s\": reopen of stdin to /dev/null failed", buf);
@ -718,7 +721,7 @@ void die(int onsig)
*/ */
count = 30; count = 30;
while (count) { while (count) {
snprintf(temp, 80, "%s", reg_fre()); reg_fre_r(temp);
if (strcmp(temp, "100:0;") == 0) { if (strcmp(temp, "100:0;") == 0) {
Syslog('+', "Good, no more other programs running"); Syslog('+', "Good, no more other programs running");
break; break;
@ -1163,13 +1166,9 @@ void *scheduler(void)
* Reload configuration data if some file is changed. * Reload configuration data if some file is changed.
*/ */
now = time(NULL); now = time(NULL);
#if defined(__OpenBSD__)
localtime_r(&now, &tm); localtime_r(&now, &tm);
gmtime_r(&now, &utm); gmtime_r(&now, &utm);
#else
tm = *localtime(&now);
utm = *gmtime(&now);
#endif
if (tm.tm_min != olddo) { if (tm.tm_min != olddo) {
/* /*
* Each minute we execute this part * Each minute we execute this part

View File

@ -4,7 +4,7 @@
* Purpose ...............: mbtask - Scan mail outbound status * Purpose ...............: mbtask - Scan mail outbound status
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -96,17 +96,15 @@ int load_node(fidoaddr n)
char *size_str(int); void size_str_r(int, char *);
char *size_str(int size) void size_str_r(int size, char *fmt)
{ {
static char fmt[25];
if (size > 1048575) { if (size > 1048575) {
snprintf(fmt, 25, "%dK", size / 1024); snprintf(fmt, 25, "%dK", size / 1024);
} else { } else {
snprintf(fmt, 25, "%d ", size); snprintf(fmt, 25, "%d ", size);
} }
return fmt; return;
} }
@ -119,11 +117,7 @@ void set_next(int hour, int min)
int uhour, umin; int uhour, umin;
now = time(NULL); now = time(NULL);
#if defined(__OpenBSD__)
gmtime_r(&now, &etm); gmtime_r(&now, &etm);
#else
etm = *gmtime(&now);
#endif
uhour = etm.tm_hour; /* For some reason, these intermediate integers are needed */ uhour = etm.tm_hour; /* For some reason, these intermediate integers are needed */
umin = etm.tm_min; umin = etm.tm_min;
@ -185,15 +179,18 @@ char *callmode(int mode)
*/ */
void checkdir(char *boxpath, faddr *fa, char flavor) void checkdir(char *boxpath, faddr *fa, char flavor)
{ {
char *temp; char *temp, *buf;
DIR *dp = NULL; DIR *dp = NULL;
struct dirent *de; struct dirent *de;
struct stat sb; struct stat sb;
struct passwd *pw; struct passwd *pw;
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
buf = calloc(PATH_MAX, sizeof(char));
pw = getpwnam((char *)"mbse"); pw = getpwnam((char *)"mbse");
Syslog('o', "check filebox %s (%s) flavor %c", boxpath, ascfnode(fa, 0xff), flavor); ascfnode_r(fa, 0xff, buf);
Syslog('o', "check filebox %s (%s) flavor %c", boxpath, buf, flavor);
free(buf);
if ((dp = opendir(boxpath)) != NULL) { if ((dp = opendir(boxpath)) != NULL) {
while ((de = readdir(dp))) { while ((de = readdir(dp))) {
@ -258,7 +255,7 @@ int outstat()
{ {
int rc, first = TRUE, T_window, iszmh = FALSE; int rc, first = TRUE, T_window, iszmh = FALSE;
struct _alist *tmp, *old; struct _alist *tmp, *old;
char digit[6], flstr[13], *temp, as[6], be[6], utc[6], flavor, *temp2; char digit[6], flstr[13], *temp, as[6], be[6], utc[6], flavor, *temp2, *fmt, *buf;
time_t now; time_t now;
struct tm tm; struct tm tm;
int uhour, umin, thour, tmin; int uhour, umin, thour, tmin;
@ -280,11 +277,7 @@ int outstat()
itnmask = (*tmpm)->mask; itnmask = (*tmpm)->mask;
} }
now = time(NULL); now = time(NULL);
#if defined(__OpenBSD__) gmtime_r(&now, &tm); // UTC time
gmtime_r(&now, &tm);
#else
tm = *gmtime(&now); /* UTC time */
#endif
uhour = tm.tm_hour; uhour = tm.tm_hour;
umin = tm.tm_min; umin = tm.tm_min;
snprintf(utc, 6, "%02d:%02d", uhour, umin); snprintf(utc, 6, "%02d:%02d", uhour, umin);
@ -671,7 +664,10 @@ int outstat()
* Here we are out of options, clear callflag. * Here we are out of options, clear callflag.
*/ */
if (tmp->callmode == CM_NONE) { if (tmp->callmode == CM_NONE) {
Syslog('!', "No method to call %s available", fido2str(tmp->addr, 0x0f)); buf = calloc(81, sizeof(char));
fido2str_r(tmp->addr, 0x0f, buf);
Syslog('!', "No method to call %s available", buf);
free(buf);
tmp->flavors &= ~F_CALL; tmp->flavors &= ~F_CALL;
} }
} }
@ -687,11 +683,17 @@ int outstat()
/* /*
* Show callresult for this node. * Show callresult for this node.
*/ */
snprintf(temp, PATH_MAX, "%s %8s %08x %08x %08x %08x %5d %s %s %s", flstr, size_str(tmp->size), fmt = calloc(81, sizeof(char));
buf = calloc(81, sizeof(char));
size_str_r(tmp->size, fmt);
fido2str_r(tmp->addr, 0x0f, buf);
snprintf(temp, PATH_MAX, "%s %8s %08x %08x %08x %08x %5d %s %s %s", flstr, fmt,
(unsigned int)tmp->olflags, (unsigned int)tmp->moflags, (unsigned int)tmp->olflags, (unsigned int)tmp->moflags,
(unsigned int)tmp->diflags, (unsigned int)tmp->ipflags, (unsigned int)tmp->diflags, (unsigned int)tmp->ipflags,
tmp->cst.tryno, callstatus(tmp->cst.trystat), callmode(tmp->callmode), fido2str(tmp->addr, 0x0f)); tmp->cst.tryno, callstatus(tmp->cst.trystat), callmode(tmp->callmode), buf);
Syslog('+', "%s", temp); Syslog('+', "%s", temp);
free(fmt);
free(buf);
} /* All nodes scanned. */ } /* All nodes scanned. */
@ -733,7 +735,7 @@ int each(faddr *addr, char flavor, int isflo, char *fname)
struct _alist **tmp; struct _alist **tmp;
struct stat st; struct stat st;
FILE *fp; FILE *fp;
char buf[256], *p; char buf[256], *p, *buf2;
node *nlent; node *nlent;
callstat *cst; callstat *cst;
@ -788,10 +790,12 @@ int each(faddr *addr, char flavor, int isflo, char *fname)
(*tmp)->size = 0L; (*tmp)->size = 0L;
} }
cst = getstatus(addr); cst = malloc(sizeof(callstat));
getstatus_r(addr, cst);
(*tmp)->cst.trytime = cst->trytime; (*tmp)->cst.trytime = cst->trytime;
(*tmp)->cst.tryno = cst->tryno; (*tmp)->cst.tryno = cst->tryno;
(*tmp)->cst.trystat = cst->trystat; (*tmp)->cst.trystat = cst->trystat;
free(cst);
if ((isflo == OUT_FLO) || (isflo == OUT_PKT) || (isflo == OUT_FIL)) if ((isflo == OUT_FLO) || (isflo == OUT_PKT) || (isflo == OUT_FIL))
switch (flavor) { switch (flavor) {
@ -833,7 +837,9 @@ int each(faddr *addr, char flavor, int isflo, char *fname)
p++; p++;
if (stat(p, &st) != 0) { if (stat(p, &st) != 0) {
if (strlen(CFG.dospath)) { if (strlen(CFG.dospath)) {
if (stat(Dos2Unix(p), &st) != 0) { buf2 = calloc(PATH_MAX, sizeof(char));
Dos2Unix_r(p, buf2);
if (stat(buf2, &st) != 0) {
/* /*
* Fileattach dissapeared, maybe * Fileattach dissapeared, maybe
* the node doesn't poll enough and * the node doesn't poll enough and
@ -842,6 +848,7 @@ int each(faddr *addr, char flavor, int isflo, char *fname)
st.st_size = 0L; st.st_size = 0L;
st.st_mtime = time(NULL); st.st_mtime = time(NULL);
} }
free(buf2);
} else { } else {
if (stat(p, &st) != 0) { if (stat(p, &st) != 0) {
st.st_size = 0L; st.st_size = 0L;

View File

@ -90,6 +90,7 @@ char *exe_cmd(char *in)
static char ebuf[19]; static char ebuf[19];
static char *cnt, var1[16]; static char *cnt, var1[16];
int result; int result;
char *buf;
strcpy(ibuf, in); strcpy(ibuf, in);
strncpy(cmd, ibuf, 4); strncpy(cmd, ibuf, 4);
@ -253,7 +254,11 @@ char *exe_cmd(char *in)
* 100:0; * 100:0;
*/ */
if (strncmp(cmd, "CIPM", 4) == 0) { if (strncmp(cmd, "CIPM", 4) == 0) {
return reg_ipm(token); buf = calloc(SS_BUFSIZE, sizeof(char));
reg_ipm_r(token, buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -312,7 +317,11 @@ char *exe_cmd(char *in)
* 100:0; No page active * 100:0; No page active
*/ */
if (strncmp(cmd, "CCKP", 4) == 0) { if (strncmp(cmd, "CCKP", 4) == 0) {
return reg_checkpage(token); buf = calloc(SS_BUFSIZE, sizeof(char));
reg_checkpage_r(token, buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -395,7 +404,11 @@ char *exe_cmd(char *in)
* 100:1,3; Error * 100:1,3; Error
*/ */
if (strncmp(cmd, "DSPC", 4) == 0) { if (strncmp(cmd, "DSPC", 4) == 0) {
return disk_check(token); buf = calloc(SS_BUFSIZE, sizeof(char));
disk_check_r(token, buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -403,7 +416,11 @@ char *exe_cmd(char *in)
* 100:n,data1,..,data10; * 100:n,data1,..,data10;
*/ */
if (strncmp(cmd, "DGFS", 4) == 0) { if (strncmp(cmd, "DGFS", 4) == 0) {
return disk_getfs(); buf = calloc(SS_BUFSIZE, sizeof(char));
disk_getfs_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -442,7 +459,11 @@ char *exe_cmd(char *in)
* 201:1,16; * 201:1,16;
*/ */
if (strncmp(cmd, "GSTA", 4) == 0) { if (strncmp(cmd, "GSTA", 4) == 0) {
return stat_status(); buf = calloc(SS_BUFSIZE, sizeof(char));
stat_status_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -453,7 +474,11 @@ char *exe_cmd(char *in)
if (strncmp(cmd, "GMON", 4) == 0) { if (strncmp(cmd, "GMON", 4) == 0) {
cnt = strtok(token, ","); cnt = strtok(token, ",");
strcpy(var1, strtok(NULL, ";")); strcpy(var1, strtok(NULL, ";"));
return get_reginfo(atoi(var1)); buf = calloc(SS_BUFSIZE, sizeof(char));
get_reginfo_r(atoi(var1), buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -461,7 +486,11 @@ char *exe_cmd(char *in)
* 100:n,data1,..,data10; * 100:n,data1,..,data10;
*/ */
if (strncmp(cmd, "GDST", 4) == 0) { if (strncmp(cmd, "GDST", 4) == 0) {
return disk_getfs(); buf = calloc(SS_BUFSIZE, sizeof(char));
disk_getfs_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -470,7 +499,11 @@ char *exe_cmd(char *in)
* 201:1,16; * 201:1,16;
*/ */
if (strncmp(cmd, "GSYS", 4) == 0) { if (strncmp(cmd, "GSYS", 4) == 0) {
return get_sysinfo(); buf = calloc(SS_BUFSIZE, sizeof(char));
get_sysinfo_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -478,7 +511,11 @@ char *exe_cmd(char *in)
* 100:1,n; * 100:1,n;
*/ */
if (strncmp(cmd, "GLCC", 4) == 0) { if (strncmp(cmd, "GLCC", 4) == 0) {
return get_lastcallercount(); buf = calloc(SS_BUFSIZE, sizeof(char));
get_lastcallercount_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -489,7 +526,11 @@ char *exe_cmd(char *in)
if (strncmp(cmd, "GLCR", 4) == 0) { if (strncmp(cmd, "GLCR", 4) == 0) {
cnt = strtok(token, ","); cnt = strtok(token, ",");
strcpy(var1, strtok(NULL, ";")); strcpy(var1, strtok(NULL, ";"));
return get_lastcallerrec(atoi(var1)); buf = calloc(SS_BUFSIZE, sizeof(char));
get_lastcallerrec_r(atoi(var1), buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
@ -536,7 +577,11 @@ char *exe_cmd(char *in)
* 201:1,16; * 201:1,16;
*/ */
if (strncmp(cmd, "SFRE", 4) == 0) { if (strncmp(cmd, "SFRE", 4) == 0) {
return reg_fre(); buf = calloc(SS_BUFSIZE, sizeof(char));
reg_fre_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -545,7 +590,11 @@ char *exe_cmd(char *in)
* 200:1,16; * 200:1,16;
*/ */
if (strncmp(cmd, "SSEQ", 4) == 0) { if (strncmp(cmd, "SSEQ", 4) == 0) {
return getseq(); buf = calloc(SS_BUFSIZE, sizeof(char));
getseq_r(buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -554,7 +603,11 @@ char *exe_cmd(char *in)
* 200:1,16; * 200:1,16;
*/ */
if (strncmp(cmd, "SEST", 4) == 0) { if (strncmp(cmd, "SEST", 4) == 0) {
return sem_status(token); buf = calloc(SS_BUFSIZE, sizeof(char));
sem_status_r(token, buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -563,7 +616,11 @@ char *exe_cmd(char *in)
* 200:1,16; * 200:1,16;
*/ */
if (strncmp(cmd, "SECR", 4) == 0) { if (strncmp(cmd, "SECR", 4) == 0) {
return sem_create(token); buf = calloc(SS_BUFSIZE, sizeof(char));
sem_create_r(token, buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }
/* /*
@ -572,7 +629,11 @@ char *exe_cmd(char *in)
* 200:1,16; * 200:1,16;
*/ */
if (strncmp(cmd, "SERM", 4) == 0) { if (strncmp(cmd, "SERM", 4) == 0) {
return sem_remove(token); buf = calloc(SS_BUFSIZE, sizeof(char));
sem_remove_r(token, buf);
snprintf(obuf, SS_BUFSIZE, "%s", buf);
free(buf);
return obuf;
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Give status of all filesystems * Purpose ...............: Give status of all filesystems
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -236,11 +236,8 @@ void fill_mfslist(mfs_list **fap, char *mountpoint, char *fstype)
*/ */
char *disk_reset(void) char *disk_reset(void)
{ {
static char buf[10];
disk_reread = TRUE; disk_reread = TRUE;
snprintf(buf, 10, "100:0;"); return (char *)"100:0;";
return buf;
} }
@ -249,9 +246,8 @@ char *disk_reset(void)
* Check free diskspace on all by mbse used filesystems. * Check free diskspace on all by mbse used filesystems.
* The amount of needed space is given in MBytes. * The amount of needed space is given in MBytes.
*/ */
char *disk_check(char *token) void disk_check_r(char *token, char *buf)
{ {
static char buf[SS_BUFSIZE];
mfs_list *tmp; mfs_list *tmp;
unsigned int needed, lowest = 0xffffffff; unsigned int needed, lowest = 0xffffffff;
int rc; int rc;
@ -264,7 +260,7 @@ char *disk_check(char *token)
* Answer Error * Answer Error
*/ */
snprintf(buf, SS_BUFSIZE, "100:1,3"); snprintf(buf, SS_BUFSIZE, "100:1,3");
return buf; return;
} }
if ((rc = pthread_mutex_lock(&a_mutex))) if ((rc = pthread_mutex_lock(&a_mutex)))
@ -283,7 +279,7 @@ char *disk_check(char *token)
} else { } else {
snprintf(buf, SS_BUFSIZE, "100:2,1,%d;", lowest); snprintf(buf, SS_BUFSIZE, "100:2,1,%d;", lowest);
} }
return buf; return;
} }
@ -292,9 +288,8 @@ char *disk_check(char *token)
* This function returns the information of all mounted filesystems, * This function returns the information of all mounted filesystems,
* but no more then 10 filesystems. * but no more then 10 filesystems.
*/ */
char *disk_getfs() void disk_getfs_r(char *buf)
{ {
static char buf[SS_BUFSIZE];
char tt[80], *ans = NULL; char tt[80], *ans = NULL;
mfs_list *tmp; mfs_list *tmp;
int rc, i = 0; int rc, i = 0;
@ -302,7 +297,7 @@ char *disk_getfs()
buf[0] = '\0'; buf[0] = '\0';
if (mfs == NULL) { if (mfs == NULL) {
snprintf(buf, SS_BUFSIZE, "100:0;"); snprintf(buf, SS_BUFSIZE, "100:0;");
return buf; return;
} }
if ((rc = pthread_mutex_lock(&a_mutex))) if ((rc = pthread_mutex_lock(&a_mutex)))
@ -332,7 +327,7 @@ char *disk_getfs()
free(ans); free(ans);
ans = NULL; ans = NULL;
return buf; return;
} }

View File

@ -4,8 +4,8 @@
/* $Id$ */ /* $Id$ */
char *disk_reset(void); /* Reset disk tables */ char *disk_reset(void); /* Reset disk tables */
char *disk_check(char *); /* Check space in Megabytes */ void disk_check_r(char *, char *); /* Check space in Megabytes */
char *disk_getfs(void); /* Get disk status */ void disk_getfs_r(char *); /* Get disk status */
void *disk_thread(void); /* Disk watch thread */ void *disk_thread(void); /* Disk watch thread */
#endif #endif

View File

@ -4,7 +4,7 @@
* Purpose ...............: Give system information * Purpose ...............: Give system information
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -37,10 +37,9 @@
/* /*
* Get BBS System info. * Get BBS System info.
*/ */
char *get_sysinfo(void) void get_sysinfo_r(char *buf)
{ {
FILE *fp; FILE *fp;
static char buf[SS_BUFSIZE];
char *temp; char *temp;
time_t startdate; time_t startdate;
@ -50,51 +49,50 @@ char *get_sysinfo(void)
if ((fp = fopen(temp, "r")) == NULL) { if ((fp = fopen(temp, "r")) == NULL) {
free(temp); free(temp);
return buf; return;
} }
free(temp);
if (fread(&SYSINFO, sizeof(SYSINFO), 1, fp) == 1) { if (fread(&SYSINFO, sizeof(SYSINFO), 1, fp) == 1) {
startdate = SYSINFO.StartDate; startdate = SYSINFO.StartDate;
ctime_r(&startdate, temp);
snprintf(buf, SS_BUFSIZE, "100:7,%d,%d,%d,%d,%d,%s,%s;", SYSINFO.SystemCalls, snprintf(buf, SS_BUFSIZE, "100:7,%d,%d,%d,%d,%d,%s,%s;", SYSINFO.SystemCalls,
SYSINFO.Pots, SYSINFO.ISDN, SYSINFO.Network, SYSINFO.Local, SYSINFO.Pots, SYSINFO.ISDN, SYSINFO.Network, SYSINFO.Local,
ctime(&startdate), clencode(SYSINFO.LastCaller)); temp, clencode(SYSINFO.LastCaller));
} }
free(temp);
fclose(fp); fclose(fp);
return buf; return;
} }
char *get_lastcallercount(void) void get_lastcallercount_r(char *buf)
{ {
static char buf[41];
char *temp; char *temp;
FILE *fp; FILE *fp;
snprintf(buf, 41, "100:1,0;"); snprintf(buf, SS_BUFSIZE, "100:1,0;");
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) { if ((fp = fopen(temp, "r")) == NULL) {
free(temp); free(temp);
return buf; return;
} }
fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp); fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp);
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
snprintf(buf, 41, "100:1,%ld;", ((ftell(fp) - LCALLhdr.hdrsize) / LCALLhdr.recsize)); snprintf(buf, SS_BUFSIZE, "100:1,%ld;", ((ftell(fp) - LCALLhdr.hdrsize) / LCALLhdr.recsize));
fclose(fp); fclose(fp);
free(temp); free(temp);
return buf; return;
} }
char *get_lastcallerrec(int Rec) void get_lastcallerrec_r(int Rec, char *buf)
{ {
static char buf[SS_BUFSIZE];
char *temp, action[9], *name, *city; char *temp, action[9], *name, *city;
FILE *fp; FILE *fp;
@ -103,7 +101,7 @@ char *get_lastcallerrec(int Rec)
snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/lastcall.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) { if ((fp = fopen(temp, "r")) == NULL) {
free(temp); free(temp);
return buf; return;
} }
fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp); fread(&LCALLhdr, sizeof(LCALLhdr), 1, fp);
fseek(fp, ((Rec -1) * LCALLhdr.recsize) + LCALLhdr.hdrsize, SEEK_SET); fseek(fp, ((Rec -1) * LCALLhdr.recsize) + LCALLhdr.hdrsize, SEEK_SET);
@ -140,7 +138,7 @@ char *get_lastcallerrec(int Rec)
free(temp); free(temp);
fclose(fp); fclose(fp);
return buf; return;
} }

View File

@ -4,9 +4,9 @@
/* $Id$ */ /* $Id$ */
char *get_sysinfo(void); /* Get System Info */ void get_sysinfo_r(char *); /* Get System Info */
char *get_lastcallercount(void); /* Get Lastcallers count */ void get_lastcallercount_r(char *); /* Get Lastcallers count */
char *get_lastcallerrec(int); /* Get Lastcaller record */ void get_lastcallerrec_r(int, char *); /* Get Lastcaller record */
#endif #endif

View File

@ -4,7 +4,7 @@
* Purpose ...............: Buffers for registration information. * Purpose ...............: Buffers for registration information.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -396,28 +396,26 @@ int reg_sysop(char *data)
/* /*
* Check for personal message * Check for personal message
*/ */
char *reg_ipm(char *data) void reg_ipm_r(char *data, char *buf)
{ {
char *cnt, *pid, *name, *msg; char *cnt, *pid, *name, *msg;
static char buf[128];
int rec; int rec;
buf[0] = '\0'; buf[0] = '\0';
snprintf(buf, 128, "100:0;"); snprintf(buf, SS_BUFSIZE, "100:0;");
cnt = strtok(data, ","); cnt = strtok(data, ",");
pid = strtok(NULL, ";"); pid = strtok(NULL, ";");
if ((rec = reg_find(pid)) == -1) if ((rec = reg_find(pid)) == -1)
return buf; return;
reginfo[rec].lastcon = (int)time(NULL); reginfo[rec].lastcon = (int)time(NULL);
if (!reginfo[rec].ismsg) if (!reginfo[rec].ismsg)
return buf; return;
buf[0] = '\0';
name = xstrcpy(clencode(reginfo[rec].fname[reginfo[rec].ptr_out])); name = xstrcpy(clencode(reginfo[rec].fname[reginfo[rec].ptr_out]));
msg = xstrcpy(clencode(reginfo[rec].msg[reginfo[rec].ptr_out])); msg = xstrcpy(clencode(reginfo[rec].msg[reginfo[rec].ptr_out]));
snprintf(buf, 128, "100:2,%s,%s;", name, msg); snprintf(buf, SS_BUFSIZE, "100:2,%s,%s;", name, msg);
if (reginfo[rec].ptr_out < RB) if (reginfo[rec].ptr_out < RB)
reginfo[rec].ptr_out++; reginfo[rec].ptr_out++;
else else
@ -429,7 +427,7 @@ char *reg_ipm(char *data)
free(name); free(name);
free(msg); free(msg);
return buf; return;
} }
@ -506,13 +504,10 @@ int reg_spm(char *data)
char *reg_fre(void) void reg_fre_r(char *buf)
{ {
static char buf[80];
int i, users = 0, utils = 0; int i, users = 0, utils = 0;
buf[0] = '\0';
for (i = 1; i < MAXCLIENT; i++) { for (i = 1; i < MAXCLIENT; i++) {
if (reginfo[i].pid) { if (reginfo[i].pid) {
if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) || if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) ||
@ -538,7 +533,7 @@ char *reg_fre(void)
snprintf(buf, 80, "100:1,Running utilities: %02d Active users: %02d;", utils, users); snprintf(buf, 80, "100:1,Running utilities: %02d Active users: %02d;", utils, users);
else else
snprintf(buf, 80, "100:0;"); snprintf(buf, 80, "100:0;");
return buf; return;
} }
@ -548,13 +543,11 @@ char *reg_fre(void)
* must be 1, for the next searches 0. Returns 100:0; if there * must be 1, for the next searches 0. Returns 100:0; if there
* is an error or the end of file is reached. * is an error or the end of file is reached.
*/ */
char *get_reginfo(int first) void get_reginfo_r(int first, char *buf)
{ {
static char buf[256];
char *name, *prg, *city, *doing; char *name, *prg, *city, *doing;
memset(&buf, 0, sizeof(buf)); snprintf(buf, SS_BUFSIZE, "100:0;");
snprintf(buf, 256, "100:0;");
/* /*
* Loop forever until an error occours, eof is reached or * Loop forever until an error occours, eof is reached or
@ -568,21 +561,21 @@ char *get_reginfo(int first)
entrypos++; entrypos++;
if (entrypos == MAXCLIENT) if (entrypos == MAXCLIENT)
return buf; return;
if ((int)reginfo[entrypos].pid != 0) { if ((int)reginfo[entrypos].pid != 0) {
name = xstrcpy(clencode(reginfo[entrypos].uname)); name = xstrcpy(clencode(reginfo[entrypos].uname));
prg = xstrcpy(clencode(reginfo[entrypos].prg)); prg = xstrcpy(clencode(reginfo[entrypos].prg));
city = xstrcpy(clencode(reginfo[entrypos].city)); city = xstrcpy(clencode(reginfo[entrypos].city));
doing = xstrcpy(clencode( reginfo[entrypos].doing)); doing = xstrcpy(clencode( reginfo[entrypos].doing));
snprintf(buf, 256, "100:7,%d,%s,%s,%s,%s,%s,%d;", snprintf(buf, SS_BUFSIZE, "100:7,%d,%s,%s,%s,%s,%s,%d;",
reginfo[entrypos].pid, reginfo[entrypos].tty, reginfo[entrypos].pid, reginfo[entrypos].tty,
name, prg, city, doing, reginfo[entrypos].started); name, prg, city, doing, reginfo[entrypos].started);
free(name); free(name);
free(prg); free(prg);
free(city); free(city);
free(doing); free(doing);
return buf; return;
} }
} }
/* never reached */ /* never reached */
@ -665,24 +658,22 @@ int reg_cancel(char *data)
/* /*
* Check paging status for from mbmon * Check paging status for from mbmon
*/ */
char *reg_checkpage(char *data) void reg_checkpage_r(char *data, char *buf)
{ {
static char buf[128];
int i; int i;
memset(&buf, 0, sizeof(buf));
for (i = 1; i < MAXCLIENT; i++) { for (i = 1; i < MAXCLIENT; i++) {
if (reginfo[i].pid && reginfo[i].paging) { if (reginfo[i].pid && reginfo[i].paging) {
snprintf(buf, 128, "100:3,%d,1,%s;", reginfo[i].pid, clencode(reginfo[i].reason)); snprintf(buf, SS_BUFSIZE, "100:3,%d,1,%s;", reginfo[i].pid, clencode(reginfo[i].reason));
return buf; return;
} }
if (reginfo[i].pid && reginfo[i].haspaged) { if (reginfo[i].pid && reginfo[i].haspaged) {
snprintf(buf, 128, "100:3,%d,0,%s;", reginfo[i].pid, clencode(reginfo[i].reason)); snprintf(buf, SS_BUFSIZE, "100:3,%d,0,%s;", reginfo[i].pid, clencode(reginfo[i].reason));
return buf; return;
} }
} }
snprintf(buf, 128, "100:0;"); snprintf(buf, SS_BUFSIZE, "100:0;");
return buf; return;
} }

View File

@ -46,14 +46,14 @@ int reg_timer(int, char *);
int reg_tty(char *); int reg_tty(char *);
int reg_user(char *); int reg_user(char *);
int reg_silent(char *); /* Set/Reset do not disturb */ int reg_silent(char *); /* Set/Reset do not disturb */
char *reg_ipm(char *); /* Check for personal message */ void reg_ipm_r(char *, char *); /* Check for personal message */
int reg_spm(char *); /* Send personal message */ int reg_spm(char *); /* Send personal message */
char *reg_fre(void); /* Check if system is free */ void reg_fre_r(char *); /* Check if system is free */
char *get_reginfo(int); /* Get registration info */ void get_reginfo_r(int, char *); /* Get registration info */
int reg_sysop(char *); /* Registrate sysop presence */ int reg_sysop(char *); /* Registrate sysop presence */
int reg_page(char *); /* Page sysop for chat */ int reg_page(char *); /* Page sysop for chat */
int reg_cancel(char *); /* Cancel sysop page */ int reg_cancel(char *); /* Cancel sysop page */
char *reg_checkpage(char *); /* Check paging status */ void reg_checkpage_r(char *, char *); /* Check paging status */
int reg_ispaging(char *); /* Check if user with pid paged */ int reg_ispaging(char *); /* Check if user with pid paged */
void reg_sysoptalk(char *); /* Is now talking to the sysop */ void reg_sysoptalk(char *); /* Is now talking to the sysop */

View File

@ -4,7 +4,7 @@
* Purpose ...............: Keep track of server status * Purpose ...............: Keep track of server status
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -151,19 +151,11 @@ void status_write(void)
struct tm ttm; struct tm ttm;
time_t temp; time_t temp;
#if defined(__OpenBSD)
temp = time(NULL); temp = time(NULL);
localtime_r(&temp, &ttm); localtime_r(&temp, &ttm);
yday = ttm.tm_yday; yday = ttm.tm_yday;
temp = (time_t)status.daily; temp = (time_t)status.daily;
localtime_r(&temp, &ttm); localtime_r(&temp, &ttm);
#else
temp = time(NULL);
ttm = *localtime(&temp);
yday = ttm.tm_yday;
temp = (time_t)status.daily;
ttm = *localtime(&temp);
#endif
/* /*
* If we passed to the next day, zero the today counters * If we passed to the next day, zero the today counters
@ -219,11 +211,7 @@ int get_zmh()
time_t Now; time_t Now;
Now = time(NULL); Now = time(NULL);
#if defined(__OpenBSD__)
gmtime_r(&Now, &l_date); gmtime_r(&Now, &l_date);
#else
l_date = *gmtime(&Now);
#endif
snprintf(sstime, 6, "%02d:%02d", l_date.tm_hour, l_date.tm_min); snprintf(sstime, 6, "%02d:%02d", l_date.tm_hour, l_date.tm_min);
if ((strncmp(sstime, TCFG.zmh_start, 5) >= 0) && (strncmp(sstime, TCFG.zmh_end, 5) < 0)) { if ((strncmp(sstime, TCFG.zmh_start, 5) >= 0) && (strncmp(sstime, TCFG.zmh_end, 5) < 0)) {
@ -303,23 +291,20 @@ void stat_inc_cerr()
char *stat_status() void stat_status_r(char *buf)
{ {
static char buf[160];
int srvcnt = 0, chncnt = 0, usrcnt = 0; int srvcnt = 0, chncnt = 0, usrcnt = 0;
srv_list *tmps; srv_list *tmps;
chn_list *tmpc; chn_list *tmpc;
usr_list *tmpu; usr_list *tmpu;
buf[0] = '\0';
for (tmps = servers; tmps; tmps = tmps->next) for (tmps = servers; tmps; tmps = tmps->next)
srvcnt++; srvcnt++;
for (tmpc = channels; tmpc; tmpc = tmpc->next) for (tmpc = channels; tmpc; tmpc = tmpc->next)
chncnt++; chncnt++;
for (tmpu = users; tmpu; tmpu = tmpu->next) for (tmpu = users; tmpu; tmpu = tmpu->next)
usrcnt++; usrcnt++;
snprintf(buf, 160, "100:23,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%2.2f,%u,%d,%d,%d;", snprintf(buf, SS_BUFSIZE, "100:23,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%2.2f,%u,%d,%d,%d;",
status.start, status.laststart, status.daily, status.start, status.laststart, status.daily,
status.startups, status.clients, status.startups, status.clients,
status.total.tot_clt, status.total.peak_clt, status.total.tot_clt, status.total.peak_clt,
@ -328,7 +313,7 @@ char *stat_status()
status.today.s_error, status.today.c_error, status.today.s_error, status.today.c_error,
status.open, get_zmh(), internet, s_do_inet, Processing, Load, status.sequence, status.open, get_zmh(), internet, s_do_inet, Processing, Load, status.sequence,
srvcnt, chncnt, usrcnt); srvcnt, chncnt, usrcnt);
return buf; return;
} }
@ -353,15 +338,12 @@ int stat_bbs_stat()
/* /*
* Get next sequence number * Get next sequence number
*/ */
char *getseq(void) void getseq_r(char *buf)
{ {
static char buf[80];
buf[0] = '\0';
status.sequence++; status.sequence++;
status_write(); status_write();
snprintf(buf, 80, "100:1,%u;", status.sequence); snprintf(buf, 80, "100:1,%u;", status.sequence);
return buf; return;
} }
@ -406,13 +388,11 @@ int sem_set(char *sem, int value)
char *sem_status(char *data) void sem_status_r(char *data, char *buf)
{ {
char *cnt, *sem; char *cnt, *sem;
static char buf[40];
int value; int value;
buf[0] = '\0';
snprintf(buf, 40, "200:1,16;"); snprintf(buf, 40, "200:1,16;");
cnt = strtok(data, ","); cnt = strtok(data, ",");
sem = strtok(NULL, ";"); sem = strtok(NULL, ";");
@ -439,47 +419,45 @@ char *sem_status(char *data)
value = s_do_inet; value = s_do_inet;
} else { } else {
Syslog('s', "sem_status(%s) buf=%s", sem, buf); Syslog('s', "sem_status(%s) buf=%s", sem, buf);
return buf; return;
} }
snprintf(buf, 40, "100:1,%s;", value ? "1":"0"); snprintf(buf, 40, "100:1,%s;", value ? "1":"0");
return buf; return;
} }
char *sem_create(char *data) void sem_create_r(char *data, char *buf)
{ {
static char buf[40];
char *cnt, *sem; char *cnt, *sem;
cnt = strtok(data, ","); cnt = strtok(data, ",");
sem = strtok(NULL, ";"); sem = strtok(NULL, ";");
buf[0] = '\0';
snprintf(buf, 40, "200:1,16;");
if (sem_set(sem, TRUE)) if (sem_set(sem, TRUE))
snprintf(buf, 40, "100:0;"); snprintf(buf, 40, "100:0;");
else
snprintf(buf, 40, "200:1,16;");
return buf; return;
} }
char *sem_remove(char *data) void sem_remove_r(char *data, char *buf)
{ {
static char buf[40];
char *cnt, *sem; char *cnt, *sem;
cnt = strtok(data, ","); cnt = strtok(data, ",");
sem = strtok(NULL, ";"); sem = strtok(NULL, ";");
buf[0] = '\0';
snprintf(buf, 40, "200:1,16;");
if (sem_set(sem, FALSE)) if (sem_set(sem, FALSE))
snprintf(buf, 40, "100:0;"); snprintf(buf, 40, "100:0;");
else
snprintf(buf, 40, "200:1,16;");
return buf; return;
} }

View File

@ -14,15 +14,15 @@ void stat_dec_clients(void); /* Decrease connected clients */
void stat_set_open(int); /* Set BBS open status */ void stat_set_open(int); /* Set BBS open status */
void stat_inc_serr(void); /* Increase syntax error */ void stat_inc_serr(void); /* Increase syntax error */
void stat_inc_cerr(void); /* Increase comms error */ void stat_inc_cerr(void); /* Increase comms error */
char *stat_status(void); /* Return status record */ void stat_status_r(char *); /* Return status record */
int stat_bbs_stat(void); /* Get BBS open status */ int stat_bbs_stat(void); /* Get BBS open status */
char *getseq(void); /* Get next sequence number */ void getseq_r(char *); /* Get next sequence number */
unsigned int gettoken(void); /* Get next sequence number */ unsigned int gettoken(void); /* Get next sequence number */
int get_zmh(void); /* Check Zone Mail Hour */ int get_zmh(void); /* Check Zone Mail Hour */
int sem_set(char *, int); /* Set/Reset semafore */ int sem_set(char *, int); /* Set/Reset semafore */
char *sem_status(char *); /* Get semafore status */ void sem_status_r(char *, char *); /* Get semafore status */
char *sem_create(char *); /* Create semafore */ void sem_create_r(char *, char *); /* Create semafore */
char *sem_remove(char *); /* Remove semafore */ void sem_remove_r(char *, char *); /* Remove semafore */
#endif #endif

View File

@ -404,12 +404,14 @@ int file_size(char *path)
*/ */
time_t file_time(char *path) time_t file_time(char *path)
{ {
static struct stat sb; struct stat sb;
time_t thetime;
if (stat(path, &sb) == -1) if (stat(path, &sb) == -1)
return -1; return -1;
return sb.st_mtime; thetime = sb.st_mtime;
return thetime;
} }
@ -419,7 +421,7 @@ time_t file_time(char *path)
*/ */
char *ascfnode(faddr *a, int fl) char *ascfnode(faddr *a, int fl)
{ {
static char buf[128]; static char buf[64];
buf[0] = '\0'; buf[0] = '\0';
if ((fl & 0x08) && (a->zone)) if ((fl & 0x08) && (a->zone))
@ -435,15 +437,29 @@ char *ascfnode(faddr *a, int fl)
return buf; return buf;
} }
void ascfnode_r(faddr *a, int fl, char *buf)
{
buf[0] = '\0';
if ((fl & 0x08) && (a->zone))
snprintf(buf+strlen(buf), 10, "%u:",a->zone);
if (fl & 0x04)
snprintf(buf+strlen(buf), 10, "%u/",a->net);
if (fl & 0x02)
snprintf(buf+strlen(buf), 10, "%u",a->node);
if ((fl & 0x01) && (a->point))
snprintf(buf+strlen(buf), 10, ".%u",a->point);
if ((fl & 0x10) && (strlen(a->domain)))
snprintf(buf+strlen(buf), 14, "@%s",a->domain);
return;
}
/* /*
* Return ASCII string for node, the bits in 'fl' set the output format. * Return ASCII string for node, the bits in 'fl' set the output format.
*/ */
char *fido2str(fidoaddr a, int fl) void fido2str_r(fidoaddr a, int fl, char *buf)
{ {
static char buf[128];
buf[0] = '\0'; buf[0] = '\0';
if ((fl & 0x08) && (a.zone)) if ((fl & 0x08) && (a.zone))
snprintf(buf+strlen(buf), 10, "%u:",a.zone); snprintf(buf+strlen(buf), 10, "%u:",a.zone);
@ -455,20 +471,17 @@ char *fido2str(fidoaddr a, int fl)
snprintf(buf+strlen(buf), 10, ".%u",a.point); snprintf(buf+strlen(buf), 10, ".%u",a.point);
if ((fl & 0x10) && (strlen(a.domain))) if ((fl & 0x10) && (strlen(a.domain)))
snprintf(buf+strlen(buf), 14, "@%s",a.domain); snprintf(buf+strlen(buf), 14, "@%s",a.domain);
return buf; return;
} }
char *Dos2Unix(char *dosname) void Dos2Unix_r(char *dosname, char *buf2)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
static char buf2[PATH_MAX];
char *p, *q; char *p, *q;
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
memset(&buf2, 0, sizeof(buf2));
snprintf(buf, PATH_MAX, "%s", dosname);
p = buf; p = buf;
if (strlen(CFG.dospath)) { if (strlen(CFG.dospath)) {
@ -487,7 +500,7 @@ char *Dos2Unix(char *dosname)
} }
} }
} }
return buf2; return;
} }
@ -499,17 +512,11 @@ char *dayname(void)
{ {
time_t tt; time_t tt;
struct tm ptm; struct tm ptm;
static char buf[3];
tt = time(NULL); tt = time(NULL);
#if defined(__OpenBSD__)
localtime_r(&tt, &ptm); localtime_r(&tt, &ptm);
#else
ptm = *localtime(&tt);
#endif
snprintf(buf, 3, "%s", dow[ptm.tm_wday]);
return buf; return dow[ptm.tm_wday];
} }

View File

@ -35,8 +35,9 @@ int mkdirs(char *, mode_t);
int file_size(char *); int file_size(char *);
time_t file_time(char *); time_t file_time(char *);
char *ascfnode(faddr *, int); char *ascfnode(faddr *, int);
char *fido2str(fidoaddr, int); void ascfnode_r(faddr *, int, char *);
char *Dos2Unix(char *); void fido2str_r(fidoaddr, int, char *);
void Dos2Unix_r(char *, char *);
char *dayname(void); char *dayname(void);
void InitFidonet(void); void InitFidonet(void);
int SearchFidonet(unsigned short); int SearchFidonet(unsigned short);