From 054987b52570b554655ce4ff2d9bc94f75b943b8 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 10 Feb 2002 15:57:05 +0000 Subject: [PATCH] Added OS and CPU nameing functions --- ChangeLog | 3 +++ lib/common.h | 3 +++ lib/structs.h | 1 + lib/strutil.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ mbcico/respfreq.c | 4 ++-- mbfido/areamgr.c | 15 +++++++-------- mbfido/bounce.c | 3 +-- mbfido/filemgr.c | 13 ++++++------- mbfido/forward.c | 3 ++- mbfido/mbaff.c | 12 ------------ mbfido/mbfido.c | 12 ------------ mbfido/mbmsg.c | 13 ------------- mbfido/msgutil.c | 3 +-- mbfido/ping.c | 3 +-- mbfido/post.c | 3 +-- mbfido/rfc2ftn.c | 2 +- mbsebbs/email.c | 5 +---- mbsebbs/mball.c | 2 +- mbsebbs/msgutil.c | 12 +----------- mbsebbs/pinfo.c | 10 +--------- mbsetup/mbsetup.c | 10 +--------- 21 files changed, 79 insertions(+), 98 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6119be38..ea21a95d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4591,4 +4591,7 @@ v0.33.20 10-Feb-2002 Added structures for area maintenance with area lists. + common.a: + Added 2 functions to return the OS name and CPU family. + Added a function to return the right tearline. diff --git a/lib/common.h b/lib/common.h index 033d2033..8e2e3e9a 100644 --- a/lib/common.h +++ b/lib/common.h @@ -538,6 +538,9 @@ char *GetLocalHMS(void); char *StrDateMDY(time_t *); char *StrDateDMY(time_t); char *GetDateDMY(void); +char *OsName(void); +char *OsCPU(void); +char *TearLine(void); diff --git a/lib/structs.h b/lib/structs.h index 9c0b00fa..0f2275f8 100644 --- a/lib/structs.h +++ b/lib/structs.h @@ -35,6 +35,7 @@ #define Max_passlen 14 /* Define maximum passwd length */ + /***************************************************************************** * * Global typedefs. diff --git a/lib/strutil.c b/lib/strutil.c index 32285610..e30a1acb 100644 --- a/lib/strutil.c +++ b/lib/strutil.c @@ -334,3 +334,48 @@ char *GetDateDMY() } +char *OsName() +{ +#ifdef __linux__ + return (char *)"Linux"; +#elif __FreeBSD__ + return (char *)"FreeBSD"; +#elif __NetBSD__ + return (char *)"NetBSD"; +#else + return (char *)"Unknown"; +#endif +} + + + +char *OsCPU() +{ +#ifdef __i386__ + return (char *)"i386"; +#elif __PPC__ + return (char *)"PPC"; +#elif __sparc__ + return (char *)"Sparc"; +#elif __alpha__ + return (char *)"Alpha"; +#else + return (char *)"Unknown"; +#endif +} + + + +/* + * Return universal tearline, note if OS and CPU are + * unknow, the tearline is already 39 characters. + */ +char *TearLine() +{ + static char tearline[41]; + + sprintf(tearline, "--- MBSE BBS v%s (%s-%s)", VERSION, OsName(), OsCPU()); + return tearline; +} + + diff --git a/mbcico/respfreq.c b/mbcico/respfreq.c index 5f10ad84..076e6897 100644 --- a/mbcico/respfreq.c +++ b/mbcico/respfreq.c @@ -546,7 +546,7 @@ file_list *respmagic(char *cmd) /* must free(cmd) before exit */ } fputs(buf, fp); } - fprintf(fp, "\r--- mbcico v%s\r", VERSION); + fprintf(fp, "\r%s\r", TearLine()); free(buf); } fwrite(&zeroes, 1, 3, fp); @@ -622,7 +622,7 @@ static void attach_report(file_list **fl) fclose(fp); } - add_report((char *)"\r--- mbcico v%s\r", VERSION); + add_report((char *)"\r%s\r", TearLine()); sprintf(tmpfn, "%s/tmp/%08lX.rpl", getenv((char *)"MBSE_ROOT"), (unsigned long)sequencer()); if ((fp = fopen(tmpfn,"w"))) { diff --git a/mbfido/areamgr.c b/mbfido/areamgr.c index 82b15fa2..b26e7c93 100644 --- a/mbfido/areamgr.c +++ b/mbfido/areamgr.c @@ -53,7 +53,6 @@ * External declarations */ extern int do_quiet; -extern char *tearline; @@ -125,7 +124,7 @@ void A_Help(faddr *t, char *replyid) fprintf(fp, " -GENERAL\r"); fprintf(fp, " %%QUERY\r"); fprintf(fp, " %%LIST\r\r"); - fprintf(fp, "%s\r", tearline); + fprintf(fp, "%s\r", TearLine()); CloseMail(fp, t); net_out++; } else @@ -231,7 +230,7 @@ void A_Query(faddr *t, char *replyid) fprintf(qp, " P - The message area is temporary paused\r"); fprintf(qp, " C - You are cutoff from this area\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -338,7 +337,7 @@ void A_List(faddr *t, char *replyid, int Notify) fprintf(qp, " P - The message area is temporary paused\r"); fprintf(qp, " C - You are cutoff from this area\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -452,7 +451,7 @@ void A_Flow(faddr *t, char *replyid, int Notify) fprintf(qp, "Con means:\r"); fprintf(qp, " C - You connected to this area\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -493,7 +492,7 @@ void A_Status(faddr *t, char *replyid) fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(fp, "%s\r", tearline); + fprintf(fp, "%s\r", TearLine()); CloseMail(fp, t); net_out++; } else @@ -599,7 +598,7 @@ void A_Unlinked(faddr *t, char *replyid) fprintf(qp, " P - The message area is temporary paused\r"); fprintf(qp, " C - You are cutoff from this area\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -1068,7 +1067,7 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla } fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "%s\r", tearline); + fprintf(np, "%s\r", TearLine()); CloseMail(np, t); net_out++; } else diff --git a/mbfido/bounce.c b/mbfido/bounce.c index 64e95b50..2e4b23a5 100644 --- a/mbfido/bounce.c +++ b/mbfido/bounce.c @@ -53,7 +53,6 @@ * External declarations */ extern int do_quiet; -extern char *tearline; @@ -135,7 +134,7 @@ int Bounce(faddr *f, faddr *t, FILE *fp, char *reason) } fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "%s\r", tearline); + fprintf(np, "%s\r", TearLine()); Now = time(NULL) - (gmt_offset((time_t)0) * 60); rc = postnetmail(np, from, f, NULL, (char *)"Bounced message", Now, 0x0000, FALSE); tidy_faddr(from); diff --git a/mbfido/filemgr.c b/mbfido/filemgr.c index cc01707e..039cc287 100644 --- a/mbfido/filemgr.c +++ b/mbfido/filemgr.c @@ -52,7 +52,6 @@ * External declarations */ extern int do_quiet; -extern char *tearline; @@ -124,7 +123,7 @@ void F_Help(faddr *t, char *replyid) fprintf(fp, " %%QUERY\r"); fprintf(fp, " %%LIST\r\r"); - fprintf(fp, "%s\r", tearline); + fprintf(fp, "%s\r", TearLine()); CloseMail(fp, t); net_out++; } else @@ -226,7 +225,7 @@ void F_Query(faddr *t, char *replyid) fprintf(qp, " S - You may send files in this area\r"); fprintf(qp, " P - The file area is temporary paused\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -329,7 +328,7 @@ void F_List(faddr *t, char *replyid, int Notify) fprintf(qp, " S - You may send files in this area\r"); fprintf(qp, " P - The file area is temporary paused\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -379,7 +378,7 @@ void F_Status(faddr *t, char *replyid) fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(fp, "%s\r", tearline); + fprintf(fp, "%s\r", TearLine()); CloseMail(fp, t); net_out++; } else @@ -481,7 +480,7 @@ void F_Unlinked(faddr *t, char *replyid) fprintf(qp, " S - You may send files in this area\r"); fprintf(qp, " P - The file area is temporary paused\r\r"); fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", tearline); + fprintf(qp, "%s\r", TearLine()); CloseMail(qp, t); net_out++; free(temp); @@ -942,7 +941,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla } fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "%s\r", tearline); + fprintf(np, "%s\r", TearLine()); CloseMail(np, t); net_out++; } else diff --git a/mbfido/forward.c b/mbfido/forward.c index 93df6b53..23113584 100644 --- a/mbfido/forward.c +++ b/mbfido/forward.c @@ -44,6 +44,7 @@ + void ForwardFile(fidoaddr Node, fa_list *sbl) { char *subject = NULL, *temp, *fwdfile = NULL, *ticfile = NULL, fname[PATH_MAX]; @@ -150,7 +151,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl) fprintf(net, "\r\r"); fprintf(net, "With regards, %s\r\r", CFG.sysop_name); fprintf(net, "... %s\r\r", Cookie()); - fprintf(net, "--- MBSE BBS %s\r", VERSION); + fprintf(net, "%s\r", TearLine()); CloseMail(net, fido2faddr(Node)); } else { WriteError("$Can't create netmail"); diff --git a/mbfido/mbaff.c b/mbfido/mbaff.c index ebcace7e..b884e0df 100644 --- a/mbfido/mbaff.c +++ b/mbfido/mbaff.c @@ -48,7 +48,6 @@ extern int do_quiet; /* Supress screen output */ extern int show_log; /* Show logging */ time_t t_start; /* Start time */ time_t t_end; /* End time */ -char *tearline; /* Standard tearline */ @@ -83,7 +82,6 @@ void die(int onsig) colour(7, 0); printf("\n"); } - free(tearline); ExitClient(onsig); } @@ -107,16 +105,6 @@ int main(int argc, char **argv) Miy = t->tm_mon; umask(002); - tearline = calloc(41, sizeof(char *)); -#ifdef __linux__ - sprintf(tearline, "--- MBSE BBS v%s (Linux)", VERSION); -#elif __FreeBSD__ - sprintf(tearline, "--- MBSE BBS v%s (FreeBSD)", VERSION); -#elif __NetBSD__ - sprintf(tearline, "--- MBSE BBS v%s (NetBSD)", VERSION); -#else - sprintf(tearline, "--- MBSE BBS v%s (Unknown)", VERSION); -#endif /* * Catch all signals we can, and ignore the rest. diff --git a/mbfido/mbfido.c b/mbfido/mbfido.c index a1bb1aff..c765c74c 100644 --- a/mbfido/mbfido.c +++ b/mbfido/mbfido.c @@ -93,7 +93,6 @@ time_t t_end; /* End time */ int packets = 0; /* Tossed packets */ int packets_ok = 0; /* Tossed packets Ok. */ char *envptr = NULL; -char *tearline; /* Standard tearline for mail */ extern int net_in, net_imp, net_out, net_bad; extern int echo_in, echo_imp, echo_out, echo_bad, echo_dupe; @@ -242,7 +241,6 @@ void die(int onsig) if (!do_quiet) colour(7, 0); - free(tearline); ExitClient(onsig); } @@ -305,16 +303,6 @@ int main(int argc, char **argv) Miy = t->tm_mon; umask(002); - tearline = calloc(41, sizeof(char *)); -#ifdef __linux__ - sprintf(tearline, "--- MBSE BBS v%s (Linux)", VERSION); -#elif __FreeBSD__ - sprintf(tearline, "--- MBSE BBS v%s (FreeBSD)", VERSION); -#elif __NetBSD__ - sprintf(tearline, "--- MBSE BBS v%s (NetBSD)", VERSION); -#else - sprintf(tearline, "--- MBSE BBS v%s (Unknown)", VERSION); -#endif /* * Catch all the signals we can, and ignore the rest. diff --git a/mbfido/mbmsg.c b/mbfido/mbmsg.c index 0ad3a900..432be590 100644 --- a/mbfido/mbmsg.c +++ b/mbfido/mbmsg.c @@ -58,7 +58,6 @@ int msg_del = 0; /* Deleted messages */ int msg_link = 0; /* Linked messages */ int processed = FALSE; /* Did process something */ int oldmask; -char *tearline; /* Standard tearline */ @@ -96,17 +95,6 @@ int main(int argc, char **argv) oldmask = umask(007); t_start = time(NULL); - tearline = calloc(41, sizeof(char *)); -#ifdef __linux__ - sprintf(tearline, "--- MBSE BBS v%s (Linux)", VERSION); -#elif __FreeBSD__ - sprintf(tearline, "--- MBSE BBS v%s (FreeBSD)", VERSION); -#elif __NetBSD__ - sprintf(tearline, "--- MBSE BBS v%s (NetBSD)", VERSION); -#else - sprintf(tearline, "--- MBSE BBS v%s (Unknown)", VERSION); -#endif - /* * Catch all signals we can, and ignore or catch them */ @@ -256,7 +244,6 @@ void die(int onsig) colour(7, 0); printf("\r \n"); } - free(tearline); ExitClient(onsig); } diff --git a/mbfido/msgutil.c b/mbfido/msgutil.c index cc3e4a11..05526584 100644 --- a/mbfido/msgutil.c +++ b/mbfido/msgutil.c @@ -41,7 +41,6 @@ extern int do_quiet; /* Supress screen output */ -extern char *tearline; /* @@ -157,7 +156,7 @@ void Msg_Bot(fidoaddr UseAka, char *Org) sprintf(temp, "With regards, %s", CFG.sysop_name); MsgText_Add2(temp); MsgText_Add2((char *)""); - MsgText_Add2(tearline); + MsgText_Add2(TearLine()); if (UseAka.point) sprintf(aka, "(%d:%d/%d.%d)", UseAka.zone, UseAka.net, UseAka.node, UseAka.point); diff --git a/mbfido/ping.c b/mbfido/ping.c index cc6a08ca..cad9070e 100644 --- a/mbfido/ping.c +++ b/mbfido/ping.c @@ -53,7 +53,6 @@ * External declarations */ extern int do_quiet; -extern char *tearline; @@ -134,7 +133,7 @@ int Ping(faddr *f, faddr *t, FILE *fp, int intransit) fprintf(np, "======================================================================\r"); fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "%s\r", tearline); + fprintf(np, "%s\r", TearLine()); Now = time(NULL) - (gmt_offset((time_t)0) * 60); rc = postnetmail(np, from, f, NULL, (char *)"Re: Ping", Now, 0x0000, FALSE); tidy_faddr(from); diff --git a/mbfido/post.c b/mbfido/post.c index 2a0a0863..3458130f 100644 --- a/mbfido/post.c +++ b/mbfido/post.c @@ -41,7 +41,6 @@ extern int do_quiet; /* Supress screen output */ -extern char *tearline; @@ -211,7 +210,7 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor) */ aka = calloc(40, sizeof(char)); MsgText_Add2((char *)""); - MsgText_Add2(tearline); + MsgText_Add2(TearLine()); if (msgs.Aka.point) sprintf(aka, "(%d:%d/%d.%d)", msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node, msgs.Aka.point); diff --git a/mbfido/rfc2ftn.c b/mbfido/rfc2ftn.c index 75b158ef..8155dfa1 100644 --- a/mbfido/rfc2ftn.c +++ b/mbfido/rfc2ftn.c @@ -699,7 +699,7 @@ int rfc2ftn(FILE *fp, faddr *recipient) else charwrite(p,ofp); } else - fprintf(ofp,"--- MBSE BBSv.%s\n",VERSION); + fprintf(ofp,"%s\n", TearLine()); if ((p = hdr((char *)"X-FTN-Origin",msg))) { if (*(q=p+strlen(p)-1) == '\n') diff --git a/mbsebbs/email.c b/mbsebbs/email.c index 6e9463b3..9d4306f2 100644 --- a/mbsebbs/email.c +++ b/mbsebbs/email.c @@ -310,16 +310,13 @@ int Save_Email(int IsReply) } else Msg.ReplyCRC = 0xffffffff; - /* * Add message text */ for (i = 1; i < Line; i++) { MsgText_Add2(Message[i]); } - - sprintf(temp, "--- MBSE BBS v%s (Linux)", VERSION); - MsgText_Add2(temp); + MsgText_Add2(TearLine()); /* * Save if to disk diff --git a/mbsebbs/mball.c b/mbsebbs/mball.c index 19747597..cc7df310 100644 --- a/mbsebbs/mball.c +++ b/mbsebbs/mball.c @@ -436,7 +436,7 @@ void Masterlist() MidLine((char *)"", fp, TRUE); MidLine((char *)"", np, TRUE); - sprintf(temp, "Created by MBSE BBS v%s (Linux) at %s", VERSION, StrDateDMY(t_start)); + sprintf(temp, "Created by MBSE BBS v%s (%s-%s) at %s", VERSION, OsName(), OsCPU(), StrDateDMY(t_start)); MidLine(temp, fp, TRUE); MidLine(temp, np, TRUE); diff --git a/mbsebbs/msgutil.c b/mbsebbs/msgutil.c index a868015d..9ab3863d 100644 --- a/mbsebbs/msgutil.c +++ b/mbsebbs/msgutil.c @@ -274,17 +274,7 @@ void Add_Footkludges(int Quote) MsgText_Add2(temp); MsgText_Add2((char *)""); } - -#ifdef __linux__ - sprintf(temp, "--- MBSE BBS v%s (Linux)", VERSION); -#elif __FreeBSD__ - sprintf(temp, "--- MBSE BBS v%s (FreeBSD)", VERSION); -#elif __NetBSD__ - sprintf(temp, "--- MBSE BBS v%s (NetBSD)", VERSION); -#else - sprintf(temp, "--- MBSE BBS v%s (Unknown)", VERSION); -#endif - MsgText_Add2(temp); + MsgText_Add2(TearLine()); if ((msgs.Type == ECHOMAIL) || (msgs.Type == LIST)) { /* RANDOM ORIGIN LINES IMPLEMENTEREN */ diff --git a/mbsebbs/pinfo.c b/mbsebbs/pinfo.c index 653b3525..7f18863e 100644 --- a/mbsebbs/pinfo.c +++ b/mbsebbs/pinfo.c @@ -91,15 +91,7 @@ void cr(void) wl(a); ls(a); -#ifdef __linux__ - sprintf(temp, "MBSE Bulletin Board System %s (Linux)", VERSION); -#elif __FreeBSD__ - sprintf(temp, "MBSE Bulletin Board System %s (FreeBSD)", VERSION); -#elif __NetBSD__ - sprintf(temp, "MBSE Bulletin Board System %s (NetBSD)", VERSION); -#else - sprintf(temp, "MBSE Bulletin Board System %s (Unknown OS)", VERSION); -#endif + sprintf(temp, "MBSE Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU()); pout(14, 0, padleft(temp, 76, ' ')); rs(a); wl(a); diff --git a/mbsetup/mbsetup.c b/mbsetup/mbsetup.c index ae483867..a2705af3 100644 --- a/mbsetup/mbsetup.c +++ b/mbsetup/mbsetup.c @@ -136,15 +136,7 @@ void soft_info(void) temp = calloc(81, sizeof(char)); clr_index(); set_color(YELLOW, BLACK); -#ifdef __linux__ - center_addstr( 6, (char *)"MBSE BBS (Linux)"); -#elif __FreeBSD__ - center_addstr( 6, (char *)"MBSE BBS (FreeBSD)"); -#elif __NetBSD__ - center_addstr( 6, (char *)"MBSE BBS (NetBSD)"); -#else - center_addstr( 6, (char *)"MBSE BBS (Unknown)"); -#endif + center_addstr( 6, (char *)"MBSE BBS (%s-%s)", OsName(), OsCPU()); set_color(WHITE, BLACK); center_addstr( 8, (char *)COPYRIGHT); set_color(YELLOW, BLACK);