diff --git a/configure b/configure index 9b1262f4..4bffb94d 100755 --- a/configure +++ b/configure @@ -4904,7 +4904,7 @@ if test "$SYSTEM" = "NetBSD"; then fi -if test "$SYSTEM" = "FreeBSD"; then +if test "$SYSTEM" = "FreeBSD" || test "$SYSTEM" = "OpenBSD"; then CFLAGS="-pthread $CFLAGS" else echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 diff --git a/mbtask/signame.c b/mbtask/signame.c index 271f86b5..631e55a8 100644 --- a/mbtask/signame.c +++ b/mbtask/signame.c @@ -51,7 +51,7 @@ char SigName[32][16] = { "NOSIGNAL", #elif defined(__PPC__) -char SgName[32][16] = { "NOSIGNAL", +char SigName[32][16] = { "NOSIGNAL", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGIOT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", @@ -64,7 +64,7 @@ char SgName[32][16] = { "NOSIGNAL", #elif defined(__sparc__) -char SgName[32][16] = { "NOSIGNAL", +char SigName[32][16] = { "NOSIGNAL", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGIOT", "SIGEMT", "SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", @@ -76,7 +76,7 @@ char SgName[32][16] = { "NOSIGNAL", #elif defined(__alpha__) -char SgName[32][16] = { "NOSIGNAL", +char SigName[32][16] = { "NOSIGNAL", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", diff --git a/mbtask/taskstat.c b/mbtask/taskstat.c index 576bf1f4..fed6cff5 100644 --- a/mbtask/taskstat.c +++ b/mbtask/taskstat.c @@ -94,44 +94,44 @@ extern int Processing; /* Is system running */ */ void status_init() { - size_t cnt; - int stat_fd; + size_t cnt; + int stat_fd; - sprintf(stat_fn, "%s/var/status.mbsed", getenv("MBSE_ROOT")); + sprintf(stat_fn, "%s/var/status.mbsed", getenv("MBSE_ROOT")); - /* - * First check if this is the very first time we start the show. - * If so, we generate an empty status file with only the start - * date in it. - */ - stat_fd = open(stat_fn, O_RDWR); - if (stat_fd == -1) { - memset((char *)&status, 0, sizeof(status_r)); - status.start = time(NULL); - status.daily = time(NULL); - status.sequence = (unsigned long)time(NULL); - stat_fd = open(stat_fn, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); - cnt = write(stat_fd, &status, sizeof(status_r)); - Syslog('+', "New statusfile created"); - lseek(stat_fd, 0, SEEK_SET); - } - - cnt = read(stat_fd, &status, sizeof(status_r)); - if (cnt != sizeof(status_r)) { - printf("Error reading status file\n"); - exit(MBERR_INIT_ERROR); - } - status.startups++; - status.laststart = time(NULL); - status.clients = 1; /* We are a client ourself */ - s_bbsopen = status.open; - lseek(stat_fd, 0, SEEK_SET); + /* + * First check if this is the very first time we start the show. + * If so, we generate an empty status file with only the start + * date in it. + */ + stat_fd = open(stat_fn, O_RDWR); + if (stat_fd == -1) { + memset((char *)&status, 0, sizeof(status_r)); + status.start = time(NULL); + status.daily = time(NULL); + status.sequence = (unsigned long)time(NULL); + stat_fd = open(stat_fn, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); cnt = write(stat_fd, &status, sizeof(status_r)); - if (cnt != sizeof(status_r)) { - Syslog('?', "$Error rewrite status file\n"); - exit(MBERR_INIT_ERROR); - } - close(stat_fd); + Syslog('+', "New statusfile created"); + lseek(stat_fd, 0, SEEK_SET); + } + + cnt = read(stat_fd, &status, sizeof(status_r)); + if (cnt != sizeof(status_r)) { + printf("Error reading status file\n"); + exit(MBERR_INIT_ERROR); + } + status.startups++; + status.laststart = time(NULL); + status.clients = 1; /* We are a client ourself */ + s_bbsopen = status.open; + lseek(stat_fd, 0, SEEK_SET); + cnt = write(stat_fd, &status, sizeof(status_r)); + if (cnt != sizeof(status_r)) { + Syslog('?', "$Error rewrite status file\n"); + exit(MBERR_INIT_ERROR); + } + close(stat_fd); } @@ -209,109 +209,109 @@ void status_write(void) */ int get_zmh() { - struct tm l_date; - char sstime[6]; - time_t Now; + struct tm l_date; + char sstime[6]; + 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); + l_date = *gmtime(&Now); #endif - sprintf(sstime, "%02d:%02d", l_date.tm_hour, l_date.tm_min); + sprintf(sstime, "%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 (!ZMH) { - CreateSema((char *)"zmh"); - Syslog('!', "Start of Zone Mail Hour"); - ZMH = TRUE; - } - } else { - if (ZMH) { - RemoveSema((char *)"zmh"); - Syslog('!', "End of Zone Mail Hour"); - ZMH = FALSE; - } + if ((strncmp(sstime, TCFG.zmh_start, 5) >= 0) && (strncmp(sstime, TCFG.zmh_end, 5) < 0)) { + if (!ZMH) { + CreateSema((char *)"zmh"); + Syslog('!', "Start of Zone Mail Hour"); + ZMH = TRUE; } - return ZMH; + } else { + if (ZMH) { + RemoveSema((char *)"zmh"); + Syslog('!', "End of Zone Mail Hour"); + ZMH = FALSE; + } + } + return ZMH; } void stat_inc_clients() { - status.clients++; - status.total.tot_clt++; - status.today.tot_clt++; - if (status.clients >= status.total.peak_clt) - status.total.peak_clt = status.clients; - if (status.clients >= status.today.peak_clt) - status.today.peak_clt = status.clients; + status.clients++; + status.total.tot_clt++; + status.today.tot_clt++; + if (status.clients >= status.total.peak_clt) + status.total.peak_clt = status.clients; + if (status.clients >= status.today.peak_clt) + status.today.peak_clt = status.clients; - status_write(); + status_write(); } void stat_dec_clients() { - status.clients--; - status_write(); + status.clients--; + status_write(); } void stat_set_open(int op) { - if (op) { - if (!s_bbsopen) { - Syslog('!', "The bbs is open"); - sem_set((char *)"scanout", TRUE); - } - } else { - if (s_bbsopen) { - Syslog('!', "The bbs is closed"); - } + if (op) { + if (!s_bbsopen) { + Syslog('!', "The bbs is open"); + sem_set((char *)"scanout", TRUE); } - s_bbsopen = status.open = op; - status_write(); + } else { + if (s_bbsopen) { + Syslog('!', "The bbs is closed"); + } + } + s_bbsopen = status.open = op; + status_write(); } void stat_inc_serr() { - status.total.s_error++; - status.today.s_error++; - status_write(); + status.total.s_error++; + status.today.s_error++; + status_write(); } void stat_inc_cerr() { - status.total.c_error++; - status.today.c_error++; - status_write(); + status.total.c_error++; + status.today.c_error++; + status_write(); } char *stat_status() { - static char buf[160]; + static char buf[160]; - buf[0] = '\0'; - sprintf(buf, "100:20,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d,%d,%d,%2.2f,%lu;", - (long)status.start, (long)status.laststart, (long)status.daily, - status.startups, status.clients, - status.total.tot_clt, status.total.peak_clt, - status.total.s_error, status.total.c_error, - status.today.tot_clt, status.today.peak_clt, - status.today.s_error, status.today.c_error, - status.open, get_zmh(), internet, s_do_inet, Processing, Load, status.sequence); - return buf; + buf[0] = '\0'; + sprintf(buf, "100:20,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d,%d,%d,%2.2f,%lu;", + (long)status.start, (long)status.laststart, (long)status.daily, + status.startups, status.clients, + status.total.tot_clt, status.total.peak_clt, + status.total.s_error, status.total.c_error, + status.today.tot_clt, status.today.peak_clt, + status.today.s_error, status.today.c_error, + status.open, get_zmh(), internet, s_do_inet, Processing, Load, status.sequence); + return buf; } @@ -324,11 +324,11 @@ char *stat_status() */ int stat_bbs_stat() { - if (!status.open) - return 1; - if (get_zmh()) - return 2; - return 0; + if (!status.open) + return 1; + if (get_zmh()) + return 2; + return 0; } @@ -338,13 +338,13 @@ int stat_bbs_stat() */ char *getseq(void) { - static char buf[80]; + static char buf[80]; - buf[0] = '\0'; - status.sequence++; - status_write(); - sprintf(buf, "100:1,%lu;", status.sequence); - return buf; + buf[0] = '\0'; + status.sequence++; + status_write(); + sprintf(buf, "100:1,%lu;", status.sequence); + return buf; } diff --git a/mbtask/taskutil.c b/mbtask/taskutil.c index 1656c1ee..28fff6c7 100644 --- a/mbtask/taskutil.c +++ b/mbtask/taskutil.c @@ -267,13 +267,13 @@ char *xstrcat(char *src, char *add) void CreateSema(char *sem) { char temp[PATH_MAX]; - int fd; + FILE *fp; sprintf(temp, "%s/var/sema/%s", getenv("MBSE_ROOT"), sem); if (access(temp, F_OK) == 0) return; - if ((fd = open(temp, O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)) >= 0) - close(fd); + if ((fp = fopen(temp, "w"))) { + fclose(fp); else Syslog('?', "Can't create semafore %s", temp); } @@ -283,11 +283,11 @@ void CreateSema(char *sem) void TouchSema(char *sem) { char temp[PATH_MAX]; - int fd; + FILE *fp; sprintf(temp, "%s/var/sema/%s", getenv("MBSE_ROOT"), sem); - if ((fd = open(temp, O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)) >= 0) { - close(fd); + if ((fp = fopen(temp, "w"))) { + fclose(fp); } else Syslog('?', "Can't touch semafore %s", temp); } @@ -333,6 +333,7 @@ int file_exist(char *path, int mode) } + /* * Make directory tree, the name must end with a / */ @@ -399,6 +400,7 @@ time_t file_time(char *path) } + /* * Return ASCII string for node, the bits in 'fl' set the output format. */ @@ -443,34 +445,36 @@ char *fido2str(fidoaddr a, int fl) return buf; } + + char *Dos2Unix(char *dosname) { - char buf[PATH_MAX]; - static char buf2[PATH_MAX]; - char *p, *q; + char buf[PATH_MAX]; + static char buf2[PATH_MAX]; + char *p, *q; - memset(&buf, 0, sizeof(buf)); - memset(&buf2, 0, sizeof(buf2)); - sprintf(buf, "%s", dosname); - p = buf; + memset(&buf, 0, sizeof(buf)); + memset(&buf2, 0, sizeof(buf2)); + sprintf(buf, "%s", dosname); + p = buf; - if (strlen(CFG.dospath)) { - if (strncasecmp(p, CFG.dospath, strlen(CFG.dospath)) == 0) { - strcpy((char *)buf2, CFG.uxpath); - for (p+=strlen(CFG.dospath), q = buf2 + strlen(buf2); *p; p++, q++) - *q = ((*p) == '\\')?'/':tolower(*p); - *q = '\0'; - p = buf2; - } else { - if (strncasecmp(p, CFG.uxpath, strlen(CFG.uxpath)) == 0) { - for (p+=strlen(CFG.uxpath), q = buf2 + strlen(buf2); *p; p++, q++) - *q = ((*p) == '\\')?'/':tolower(*p); - *q = '\0'; - p = buf2; - } - } + if (strlen(CFG.dospath)) { + if (strncasecmp(p, CFG.dospath, strlen(CFG.dospath)) == 0) { + strcpy((char *)buf2, CFG.uxpath); + for (p+=strlen(CFG.dospath), q = buf2 + strlen(buf2); *p; p++, q++) + *q = ((*p) == '\\')?'/':tolower(*p); + *q = '\0'; + p = buf2; + } else { + if (strncasecmp(p, CFG.uxpath, strlen(CFG.uxpath)) == 0) { + for (p+=strlen(CFG.uxpath), q = buf2 + strlen(buf2); *p; p++, q++) + *q = ((*p) == '\\')?'/':tolower(*p); + *q = '\0'; + p = buf2; + } } - return buf2; + } + return buf2; } @@ -499,33 +503,33 @@ char *dayname(void) void InitFidonet(void) { - memset(&fidonet, 0, sizeof(fidonet)); + memset(&fidonet, 0, sizeof(fidonet)); } int SearchFidonet(unsigned short zone) { - FILE *fil; - char fidonet_fil[PATH_MAX]; - int i; + FILE *fil; + char fidonet_fil[PATH_MAX]; + int i; - sprintf(fidonet_fil, "%s/etc/fidonet.data", getenv("MBSE_ROOT")); - if ((fil = fopen(fidonet_fil, "r")) == NULL) { - return FALSE; - } - fread(&fidonethdr, sizeof(fidonethdr), 1, fil); - - while (fread(&fidonet, fidonethdr.recsize, 1, fil) == 1) { - for (i = 0; i < 6; i++) { - if (zone == fidonet.zone[i]) { - fclose(fil); - return TRUE; - } - } - } - fclose(fil); + sprintf(fidonet_fil, "%s/etc/fidonet.data", getenv("MBSE_ROOT")); + if ((fil = fopen(fidonet_fil, "r")) == NULL) { return FALSE; + } + fread(&fidonethdr, sizeof(fidonethdr), 1, fil); + + while (fread(&fidonet, fidonethdr.recsize, 1, fil) == 1) { + for (i = 0; i < 6; i++) { + if (zone == fidonet.zone[i]) { + fclose(fil); + return TRUE; + } + } + } + fclose(fil); + return FALSE; }