diff --git a/ChangeLog b/ChangeLog index 95d025dc..4f9cb182 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ $Id$ - WARNING, users of Sparc and HP-PA systems should not edit bbs menus now! + WARNING, users of Sparc and HP-PA systems should be carefull, some + menus might not work. All other users on Intel machines (99,9% I think) can use this version. @@ -106,6 +107,7 @@ v0.37.01 14-Jan-2003. Fixed whoson list to display user real names and handles again. Fixed send online message to send to user real names, handles and unix names again. + The menus are machine endian independant. examples: The English and Dutch templates are updated to show the new diff --git a/examples/Makefile b/examples/Makefile index 0b56b4eb..7adff458 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -3,13 +3,9 @@ include ../Makefile.global -SRCS = endian.c -HDRS = endian.h -OBJS = endian.o -OTHER = Makefile header.txt footer.txt menus-le.tar menus-be.tar \ - txtfiles-en.tar templates-en.tar \ +OTHER = Makefile header.txt footer.txt \ + menus-en.tar txtfiles-en.tar templates-en.tar \ menus-es.tar txtfiles-es.tar templates-es.tar \ - menus-en.tar \ templates-de.tar \ templates-nl.tar @@ -18,13 +14,10 @@ OTHER = Makefile header.txt footer.txt menus-le.tar menus-be.tar \ .c.o: ${CC} ${CFLAGS} ${INCLUDES} ${DEFINES} -c $< -all: endian +all: -endian: ${OBJS} ${LIBS} - ${CC} -o endian ${OBJS} ${LIBS} - strip endian -install: all +install: @if [ ! -f ${ETCDIR}/header.txt ]; then \ ${INSTALL} -c -o ${OWNER} -g ${GROUP} -m 0644 header.txt ${ETCDIR} ; \ echo "${INSTALL} -c -o ${OWNER} -g ${GROUP} -m 0644 header.txt ${ETCDIR}" ; \ @@ -34,8 +27,8 @@ install: all echo "${INSTALL} -c -o ${OWNER} -g ${GROUP} -m 0644 footer.txt ${ETCDIR}" ; \ fi @if [ ! -f ${PREFIX}/english/menus/main.mnu ]; then \ - tar xfC menus-`./endian`.tar ${PREFIX}/english/menus ; \ - echo "tar xfC menus-`./endian`.tar ${PREFIX}/english/menus" ; \ + tar xfC menus-en.tar ${PREFIX}/english/menus ; \ + echo "tar xfC menus-en.tar ${PREFIX}/english/menus" ; \ echo "Installed default English menus" ; \ fi @if [ ! -f ${PREFIX}/english/txtfiles/main.ans ]; then \ @@ -69,7 +62,7 @@ install: all fi clean: - rm -f endian *.o *.h~ *.c~ core filelist Makefile.bak + rm -f *.h~ *.c~ core filelist Makefile.bak filelist: Makefile BASE=`pwd`; \ @@ -100,5 +93,4 @@ depend: # DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT # Dependencies generated by make depend -endian.o: endian.h # End of generated dependencies diff --git a/examples/endian.c b/examples/endian.c deleted file mode 100644 index 7a40a2e0..00000000 --- a/examples/endian.c +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************** - * - * $Id$ - * Purpose ...............: Check little/big-endian for install of the menus. - * - ***************************************************************************** - * Copyright (C) 1997-2002 - * - * Michiel Broek FIDO: 2:280/2802 - * Beekmansbos 10 - * 1971 BV IJmuiden - * the Netherlands - * - * This file is part of MBSE BBS. - * - * This BBS is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * MB BBS is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with MB BBS; see the file COPYING. If not, write to the Free - * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - *****************************************************************************/ - - -#include -#include -#include "endian.h" - -int main(void) -{ - - /* - * First test BYTE_ORDER - */ -#ifdef BYTE_ORDER - if (BYTE_ORDER == 1234) { - printf("le"); - } else if (BYTE_ORDER == 4321) { - printf("be"); - } else { - /* - * If it failed do a simple CPU test - */ -#endif -#ifdef __i386__ - printf("le"); -#else - printf("be"); -#endif -#ifdef BYTE_ORDER - } -#endif - - - return 0; -} - diff --git a/examples/endian.h b/examples/endian.h deleted file mode 100644 index 1a8c5fda..00000000 --- a/examples/endian.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $Id$ */ - -int main(void); - diff --git a/examples/menus-be.tar b/examples/menus-be.tar deleted file mode 100644 index 6c207377..00000000 Binary files a/examples/menus-be.tar and /dev/null differ diff --git a/examples/menus-en.tar b/examples/menus-en.tar index 8d2ca7c2..278282c9 100644 Binary files a/examples/menus-en.tar and b/examples/menus-en.tar differ diff --git a/examples/menus-le.tar b/examples/menus-le.tar deleted file mode 100644 index 278282c9..00000000 Binary files a/examples/menus-le.tar and /dev/null differ diff --git a/lib/common.h b/lib/common.h index c008e08a..0fad6f4a 100644 --- a/lib/common.h +++ b/lib/common.h @@ -501,7 +501,7 @@ void name_mangle(char *); /* Mangle name or make uppercase */ * sectest.c */ int Access(securityrec, securityrec); /* Check security access */ - +int Le_Access(securityrec, securityrec); /* Endian independant */ #endif diff --git a/lib/sectest.c b/lib/sectest.c index abfe46aa..40eef1f9 100644 --- a/lib/sectest.c +++ b/lib/sectest.c @@ -4,7 +4,7 @@ * Purpose ...............: Security flags access test * ***************************************************************************** - * Copyright (C) 1997-2002 + * Copyright (C) 1997-2003 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -55,3 +55,27 @@ int Access(securityrec us, securityrec ref) return TRUE; } + + +/* + * The same test, for menus which are written in machine endian independant way. + * The second parameter MUST be the menu parameter. + */ +int Le_Access(securityrec us, securityrec ref) +{ + Syslog('B', "User %5d %08lx %08lx", us.level, us.flags, ~us.flags); + Syslog('B', "Ref. %5d %08lx %08lx", le_int(ref.level), ref.flags, ref.notflags); + + if (us.level < le_int(ref.level)) + return FALSE; + + if ((ref.notflags & ~us.flags) != ref.notflags) + return FALSE; + + if ((ref.flags & us.flags) != ref.flags) + return FALSE; + + return TRUE; +} + + diff --git a/lib/structs.h b/lib/structs.h index 9e5cfdc8..f9796f06 100644 --- a/lib/structs.h +++ b/lib/structs.h @@ -4,7 +4,7 @@ * Purpose ...............: MBSE BBS Global structure * ***************************************************************************** - * Copyright (C) 1997-2002 + * Copyright (C) 1997-2003 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -839,16 +839,16 @@ struct menufile { char Display[81]; /* Menu display line */ securityrec MenuSecurity; /* Menu Security Level */ int Age; /* Minimum Age to use menu */ - unsigned int MaxSecurity; /* Maximum security level */ + unsigned int xMaxSecurity; char Password[15]; /* Menu Password */ char TypeDesc[30]; /* Menu Type Description */ 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 compart mode */ + unsigned Comport : 1; /* Vmodem comport mode */ unsigned NoSuid : 1; /* Execute door nosuid */ unsigned NoPrompt : 1; /* No prompt after door */ - long Credit; /* Credit needed */ + long xCredit; int HiForeGnd; /* High ForeGround color */ int HiBackGnd; /* High ForeGround color */ int ForeGnd; /* Normal ForeGround color */ diff --git a/mbsebbs/menu.c b/mbsebbs/menu.c index 648fb152..63ae225b 100644 --- a/mbsebbs/menu.c +++ b/mbsebbs/menu.c @@ -147,8 +147,8 @@ void menu() */ IsANSI = FALSE; while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { - if ( Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= menus.Age)){ - if ((menus.MenuType == 5) || (menus.MenuType == 19) || (menus.MenuType == 20)) + if ( Le_Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= le_int(menus.Age))){ + if ((le_int(menus.MenuType) == 5) || (le_int(menus.MenuType) == 19) || (le_int(menus.MenuType) == 20)) IsANSI = TRUE; } } @@ -157,9 +157,9 @@ void menu() clear(); while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { - if ( Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= menus.Age)){ + if ( Le_Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= le_int(menus.Age))){ if ( menus.AutoExec ) { - DoMenu( menus.MenuType ); + DoMenu( le_int(menus.MenuType) ); } DisplayMenu( ); } @@ -224,10 +224,10 @@ void menu() while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ((strcmp(tu(Input), menus.MenuKey)) == 0) { - if ((Access(exitinfo.Security, menus.MenuSecurity)) && (UserAge >= menus.Age)) { - Syslog('b', "Menu[%d] %d=(%s), Opt: '%s'", MenuLevel, menus.MenuType, + if ((Le_Access(exitinfo.Security, menus.MenuSecurity)) && (UserAge >= le_int(menus.Age))) { + Syslog('b', "Menu[%d] %d=(%s), Opt: '%s'", MenuLevel, le_int(menus.MenuType), menus.TypeDesc, menus.OptionalData); - if (menus.MenuType == 13) { + if (le_int(menus.MenuType) == 13) { /* * Terminate call, cleanup here */ @@ -235,7 +235,7 @@ void menu() free(sMenuPathFileName); fclose(pMenuFile); } - DoMenu(menus.MenuType); + DoMenu(le_int(menus.MenuType)); iFoundKey = TRUE; break; } @@ -321,8 +321,8 @@ void DoMenu(int Type) strcat(sPrompt, temp); } } - if (menus.ForeGnd || menus.BackGnd) - pout(menus.ForeGnd, menus.BackGnd, sPrompt); + if (le_int(menus.ForeGnd) || le_int(menus.BackGnd)) + pout(le_int(menus.ForeGnd), le_int(menus.BackGnd), sPrompt); else pout(WHITE, BLACK, sPrompt); break; @@ -372,7 +372,7 @@ void DoMenu(int Type) case 15: /* print text to screen */ - if (exitinfo.Security.level >= menus.MenuSecurity.level) { + if (exitinfo.Security.level >= le_int(menus.MenuSecurity.level)) { for (i = 0; i < strlen(menus.OptionalData); i++) if (*(menus.OptionalData + i) == '@') *(menus.OptionalData + i) = '\n'; @@ -713,7 +713,7 @@ void DisplayMenu(void) int maxdpos, dpos, escaped, skipCRLF, highlight; /* Anything to process, if not; save CPU time, return */ - if (( strlen( menus.Display ) == 0 ) && (menus.MenuType != 21)) { + if (( strlen( menus.Display ) == 0 ) && (le_int(menus.MenuType) != 21)) { return; } @@ -724,7 +724,7 @@ void DisplayMenu(void) skipCRLF = 0; highlight = 0; - colour( menus.ForeGnd, menus.BackGnd ); + colour( le_int(menus.ForeGnd), le_int(menus.BackGnd) ); for ( dpos = 0; dpos < maxdpos ; dpos++ ){ switch ( menus.Display[ dpos ] ) { @@ -749,10 +749,10 @@ void DisplayMenu(void) if ( !escaped ) { if ( highlight == 0 ) { highlight = 1; - colour( menus.HiForeGnd, menus.HiBackGnd); + colour( le_int(menus.HiForeGnd), le_int(menus.HiBackGnd)); } else { highlight = 0 ; - colour( menus.ForeGnd, menus.BackGnd ); + colour( le_int(menus.ForeGnd), le_int(menus.BackGnd) ); } } else { escaped=0;