Code cleanup for ports

This commit is contained in:
Michiel Broek 2005-01-07 21:46:24 +00:00
parent e5457c6187
commit 8149bb99f6
10 changed files with 66 additions and 55 deletions

View File

@ -7,14 +7,17 @@ v0.71.1 28-Nov-2004
Compiles more or less on x86_64, there are issues with utmp Compiles more or less on x86_64, there are issues with utmp
and struct lastlog and struct lastlog
Compiles on NetBSD i386. Compiles on NetBSD i386.
Compiles in Alpha. Compiles on Alpha.
Doesn't compile on Mac OS X.
upgrade: upgrade:
Make sure you remove everything related to bbslist menus from Make sure you remove everything related to bbslist menus from
your menus and txtfiles. your menus and txtfiles.
general: general:
Added port to OpenBSD, is under test. Added port to OpenBSD, is under test (and doesn't work).
Code cleanup so that compile stops on unknown OSes and CPUs
instead of missing code parts.
mbsebbs: mbsebbs:
The creation of the mailout semafore is now after the hangup The creation of the mailout semafore is now after the hangup

View File

@ -1278,16 +1278,7 @@ struct menufile {
unsigned int xMaxSecurity; unsigned int xMaxSecurity;
char DoorName[15]; /* Door name */ char DoorName[15]; /* Door name */
char TypeDesc[30]; /* Menu Type Description */ char TypeDesc[30]; /* Menu Type Description */
#ifdef __i386__ #ifdef WORDS_BIGENDIAN
unsigned AutoExec : 1; /* Auto Exec Menu Type */
unsigned NoDoorsys : 1; /* Suppress door.sys */
unsigned Y2Kdoorsys : 1; /* Write Y2K style door.sys */
unsigned Comport : 1; /* Vmodem comport mode */
unsigned NoSuid : 1; /* Execute door nosuid */
unsigned NoPrompt : 1; /* No prompt after door */
unsigned SingleUser : 1; /* Single user door */
unsigned HideDoor : 1; /* Hide door from lists */
#else
/* All bits swapped */ /* All bits swapped */
unsigned HideDoor : 1; /* Hide door from lists */ unsigned HideDoor : 1; /* Hide door from lists */
unsigned SingleUser : 1; /* Single user door */ unsigned SingleUser : 1; /* Single user door */
@ -1297,6 +1288,15 @@ struct menufile {
unsigned Y2Kdoorsys : 1; /* Write Y2K style door.sys */ unsigned Y2Kdoorsys : 1; /* Write Y2K style door.sys */
unsigned NoDoorsys : 1; /* Suppress door.sys */ unsigned NoDoorsys : 1; /* Suppress door.sys */
unsigned AutoExec : 1; /* Auto Exec Menu Type */ unsigned AutoExec : 1; /* Auto Exec Menu Type */
#else
unsigned AutoExec : 1; /* Auto Exec Menu Type */
unsigned NoDoorsys : 1; /* Suppress door.sys */
unsigned Y2Kdoorsys : 1; /* Write Y2K style door.sys */
unsigned Comport : 1; /* Vmodem comport mode */
unsigned NoSuid : 1; /* Execute door nosuid */
unsigned NoPrompt : 1; /* No prompt after door */
unsigned SingleUser : 1; /* Single user door */
unsigned HideDoor : 1; /* Hide door from lists */
#endif #endif
long xUnused; long xUnused;
int HiForeGnd; /* High ForeGround color */ int HiForeGnd; /* High ForeGround color */

View File

@ -344,7 +344,7 @@ char *OsName()
#elif __OpenBSD__ #elif __OpenBSD__
return (char *)"OpenBSD"; return (char *)"OpenBSD";
#else #else
return (char *)"Unknown"; #error "Unknown target OS"
#endif #endif
} }
@ -365,7 +365,7 @@ char *OsCPU()
#elif __hppa__ #elif __hppa__
return (char *)"HPPA"; return (char *)"HPPA";
#else #else
return (char *)"Unknown"; #error "Unknown CPU"
#endif #endif
} }

View File

@ -406,30 +406,35 @@ void soft_info(void)
clr_index(); clr_index();
set_color(YELLOW, BLACK); set_color(YELLOW, BLACK);
#ifdef __linux__
#if defined(__linux__)
p = xstrcpy((char *)"MBSE BBS (GNU/Linux"); p = xstrcpy((char *)"MBSE BBS (GNU/Linux");
#elif __FreeBSD__ #elif defined(__FreeBSD__)
p = xstrcpy((char *)"MBSE BBS (FreeBSD"); p = xstrcpy((char *)"MBSE BBS (FreeBSD");
#elif __NetBSD__ #elif defined(__NetBSD__)
p = xstrcpy((char *)"MBSE BBS (NetBSD"); p = xstrcpy((char *)"MBSE BBS (NetBSD");
#elif __OpenBSD__ #elif defined(__OpenBSD__)
p = xstrcpy((char *)"MBSE BBS (OpenBSD"); p = xstrcpy((char *)"MBSE BBS (OpenBSD");
#else #else
p = xstrcpy((char *)"MBSE BBS (Unknown"); #error "Unknown OS"
#endif #endif
#ifdef __i386__
#if defined(__i386__)
p = xstrcat(p, (char *)" i386)"); p = xstrcat(p, (char *)" i386)");
#elif __PPC__ #elif defined(__x86_64__)
p = xstrcat(p, (char *)" x86-64");
#elif defined(__PPC__) || defined(__ppc__)
p = xstrcat(p, (char *)" PPC)"); p = xstrcat(p, (char *)" PPC)");
#elif __sparc__ #elif defined(__sparc__)
p = xstrcat(p, (char *)" Sparc)"); p = xstrcat(p, (char *)" Sparc)");
#elif __alpha__ #elif defined(__alpha__)
p = xstrcat(p, (char *)" Alpha)"); p = xstrcat(p, (char *)" Alpha)");
#elif __hppa__ #elif defined(__hppa__)
p = xstrcat(p, (char *)" HPPA)"); p = xstrcat(p, (char *)" HPPA)");
#else #else
p = xstrcat(p, (char *)" Unknown)"); #error "Unknown CPU"
#endif #endif
center_addstr( 6, p); center_addstr( 6, p);
free(p); free(p);
set_color(WHITE, BLACK); set_color(WHITE, BLACK);

View File

@ -1691,14 +1691,14 @@ int global_doc(FILE *fp, FILE *toc, int page)
if (uname(&utsbuf) == 0) { if (uname(&utsbuf) == 0) {
add_webtable(wp, (char *)"Node name", utsbuf.nodename); add_webtable(wp, (char *)"Node name", utsbuf.nodename);
fprintf(fp, " Node name %s\n", utsbuf.nodename); fprintf(fp, " Node name %s\n", utsbuf.nodename);
#ifdef __USE_GNU #if defined(__USE_GNU)
add_webtable(wp, (char *)"Domain name", utsbuf.domainname); add_webtable(wp, (char *)"Domain name", utsbuf.domainname);
fprintf(fp, " Domain name %s\n", utsbuf.domainname); fprintf(fp, " Domain name %s\n", utsbuf.domainname);
#else #elif defined(__linux__)
#ifdef __linux__
add_webtable(wp, (char *)"Domain name", utsbuf.__domainname); add_webtable(wp, (char *)"Domain name", utsbuf.__domainname);
fprintf(fp, " Domain name %s\n", utsbuf.__domainname); fprintf(fp, " Domain name %s\n", utsbuf.__domainname);
#endif #else
#error "Don't know utsbuf.domainname on this OS"
#endif #endif
sprintf(temp, "%s %s", utsbuf.sysname, utsbuf.release); sprintf(temp, "%s %s", utsbuf.sysname, utsbuf.release);
add_webtable(wp, (char *)"Operating system", temp); add_webtable(wp, (char *)"Operating system", temp);

View File

@ -140,17 +140,16 @@ int CountTtyinfo(void)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
memset(&ttyinfo, 0, sizeof(ttyinfo)); memset(&ttyinfo, 0, sizeof(ttyinfo));
sprintf(ttyinfo.comment, "ISDN line %d", i+1); sprintf(ttyinfo.comment, "ISDN line %d", i+1);
#ifdef __linux__ #if defined(__linux__)
sprintf(ttyinfo.tty, "ttyI%d", i); sprintf(ttyinfo.tty, "ttyI%d", i);
#endif #elif defined(__FreeBSD__)
#ifdef __FreeBSD__
sprintf(ttyinfo.tty, "cuaia%d", i); sprintf(ttyinfo.tty, "cuaia%d", i);
#endif #elif defined(__NetBSD__)
#ifdef __NetBSD__
sprintf(ttyinfo.tty, "ttyi%c", i + 'a'); // NetBSD on a Sparc, how about PC's? sprintf(ttyinfo.tty, "ttyi%c", i + 'a'); // NetBSD on a Sparc, how about PC's?
#endif #elif defined(__OpenBSD__)
#ifdef __OpenBSD__
sprintf(ttyinfo.tty, "cuaia%d", i); // I think this is wrong! sprintf(ttyinfo.tty, "cuaia%d", i); // I think this is wrong!
#else
#error "Don't know the tty name for ISDN on this OS"
#endif #endif
sprintf(ttyinfo.speed, "64 kbits"); sprintf(ttyinfo.speed, "64 kbits");
sprintf(ttyinfo.flags, "XA,X75,CM"); sprintf(ttyinfo.flags, "XA,X75,CM");
@ -166,17 +165,16 @@ int CountTtyinfo(void)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
memset(&ttyinfo, 0, sizeof(ttyinfo)); memset(&ttyinfo, 0, sizeof(ttyinfo));
sprintf(ttyinfo.comment, "Modem line %d", i+1); sprintf(ttyinfo.comment, "Modem line %d", i+1);
#ifdef __linux__ #if defined(__linux__)
sprintf(ttyinfo.tty, "ttyS%d", i); sprintf(ttyinfo.tty, "ttyS%d", i);
#endif #elif defined(__FreeBSD__)
#ifdef __FreeBSD__
sprintf(ttyinfo.tty, "cuaa%d", i); sprintf(ttyinfo.tty, "cuaa%d", i);
#endif #elif defined(__NetBSD__)
#ifdef __NetBSD__
sprintf(ttyinfo.tty, "tty%c", i + 'a'); // NetBSD on a Sparc, how about PC's? sprintf(ttyinfo.tty, "tty%c", i + 'a'); // NetBSD on a Sparc, how about PC's?
#endif #elif defined(__OpenBSD__)
#ifdef __OpenBSD__
sprintf(ttyinfo.tty, "tty0%d", i); sprintf(ttyinfo.tty, "tty0%d", i);
#else
#error "Don't know the tty name of the serial ports on this OS"
#endif #endif
sprintf(ttyinfo.speed, "33.6 kbits"); sprintf(ttyinfo.speed, "33.6 kbits");
sprintf(ttyinfo.flags, "CM,XA,V32B,V42B,V34"); sprintf(ttyinfo.flags, "CM,XA,V32B,V42B,V34");

View File

@ -149,12 +149,12 @@ void load_maincfg(void)
*/ */
sprintf(CFG.bbs_name, "MBSE BBS"); sprintf(CFG.bbs_name, "MBSE BBS");
uname((struct utsname *)&un); uname((struct utsname *)&un);
#ifdef __USE_GNU #if defined(__USE_GNU)
sprintf(CFG.sysdomain, "%s.%s", un.nodename, un.domainname); sprintf(CFG.sysdomain, "%s.%s", un.nodename, un.domainname);
#else #elif defined(__linux__)
#ifdef __linux__
sprintf(CFG.sysdomain, "%s.%s", un.nodename, un.__domainname); sprintf(CFG.sysdomain, "%s.%s", un.nodename, un.__domainname);
#endif #else
#error "Don't know un.domainname on this OS"
#endif #endif
sprintf(CFG.comment, "MBSE BBS development"); sprintf(CFG.comment, "MBSE BBS development");
sprintf(CFG.origin, "MBSE BBS. Made in the Netherlands"); sprintf(CFG.origin, "MBSE BBS. Made in the Netherlands");
@ -1107,6 +1107,8 @@ void *scheduler(void)
} }
fclose(fp); fclose(fp);
} }
#else
#error "Don't know how to get the loadaverage on this OS"
#endif #endif
if (Load >= TCFG.maxload) { if (Load >= TCFG.maxload) {
if (!LOADhi) { if (!LOADhi) {

View File

@ -49,7 +49,7 @@ char SigName[32][16] = { "NOSIGNAL",
"SIGIO", "SIGPWR", "SIGUNUSED"}; "SIGIO", "SIGPWR", "SIGUNUSED"};
#elif defined(__PPC__) #elif defined(__PPC__) || defined(__ppc__)
char SigName[32][16] = { "NOSIGNAL", char SigName[32][16] = { "NOSIGNAL",
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",

View File

@ -363,6 +363,8 @@ void update_diskstat(void)
* XxxxBSD has the info in the statfs structure. * XxxxBSD has the info in the statfs structure.
*/ */
tmp->ro = (sfs.f_flags & MNT_RDONLY); tmp->ro = (sfs.f_flags & MNT_RDONLY);
#else
#error "Don't know how to get sfs read-only status"
#endif #endif
} }
} }
@ -385,6 +387,8 @@ void add_path(char *lpath)
struct statfs *mntbuf; struct statfs *mntbuf;
long mntsize; long mntsize;
int i; int i;
#else
#error "Don't know how to get mount paths"
#endif #endif
if (strlen(lpath) == 0) { if (strlen(lpath) == 0) {

View File

@ -221,8 +221,7 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
#else #else
syslog(LOG_WARNING, "Don't know how to add a user on this OS"); #error "Don't know how to add a user on this OS"
exit(1);
#endif #endif
sprintf(shell, "%s/bin/mbsebbs", getenv("MBSE_ROOT")); sprintf(shell, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
@ -239,8 +238,7 @@ int main(int argc, char *argv[])
args[8] = shell; args[8] = shell;
args[9] = argv[2]; args[9] = argv[2];
args[10] = NULL; args[10] = NULL;
#endif #elif defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
args[1] = (char *)"-c"; args[1] = (char *)"-c";
args[2] = argv[3]; args[2] = argv[3];
args[3] = (char *)"-d"; args[3] = (char *)"-d";
@ -252,8 +250,7 @@ int main(int argc, char *argv[])
args[9] = (char *)"-m"; args[9] = (char *)"-m";
args[10] = argv[2]; args[10] = argv[2];
args[11] = NULL; args[11] = NULL;
#endif #elif defined(__FreeBSD__)
#ifdef __FreeBSD__
args[1] = (char *)"useradd"; args[1] = (char *)"useradd";
args[2] = argv[2]; args[2] = argv[2];
args[3] = (char *)"-c"; args[3] = (char *)"-c";
@ -265,6 +262,8 @@ int main(int argc, char *argv[])
args[9] = (char *)"-s"; args[9] = (char *)"-s";
args[10] = shell; args[10] = shell;
args[11] = NULL; args[11] = NULL;
#else
#error "Don't know how to add a user on this OS"
#endif #endif
if (execute(args, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty") != 0) { if (execute(args, (char *)"/dev/tty", (char *)"/dev/tty", (char *)"/dev/tty") != 0) {