Annotation of sbbs/src/sbbs3/scfg/scfg.c, revision 1.1.1.2

1.1.1.2 ! root        1: /* scfg.c */
        !             2: 
        !             3: /* Synchronet configuration utility                                                                            */
        !             4: 
        !             5: /* $Id: scfg.c,v 1.73 2011/06/30 03:07:04 rswindell Exp $ */
        !             6: 
        !             7: /****************************************************************************
        !             8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !            10:  *                                                                                                                                                     *
        !            11:  * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            12:  *                                                                                                                                                     *
        !            13:  * This program is free software; you can redistribute it and/or                       *
        !            14:  * modify it under the terms of the GNU General Public License                         *
        !            15:  * as published by the Free Software Foundation; either version 2                      *
        !            16:  * of the License, or (at your option) any later version.                                      *
        !            17:  * See the GNU General Public License for more details: gpl.txt or                     *
        !            18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
        !            19:  *                                                                                                                                                     *
        !            20:  * Anonymous FTP access to the most recent released source is available at     *
        !            21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            22:  *                                                                                                                                                     *
        !            23:  * Anonymous CVS access to the development source and modification history     *
        !            24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            26:  *     (just hit return, no password is necessary)                                                     *
        !            27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            28:  *                                                                                                                                                     *
        !            29:  * For Synchronet coding style and modification guidelines, see                                *
        !            30:  * http://www.synchro.net/source.html                                                                          *
        !            31:  *                                                                                                                                                     *
        !            32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            33:  * format) via e-mail to [email protected]                                                                      *
        !            34:  *                                                                                                                                                     *
        !            35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            36:  ****************************************************************************/
        !            37: 
        !            38: #define __COLORS
        !            39: #include "scfg.h"
        !            40: #undef BLINK
        !            41: #include "ciolib.h"
        !            42: 
        !            43: /********************/
        !            44: /* Global Variables */
        !            45: /********************/
        !            46: 
        !            47: scfg_t cfg;    /* Synchronet Configuration */
        !            48: uifcapi_t uifc; /* User Interface (UIFC) Library API */
        !            49: 
        !            50: BOOL no_dirchk=FALSE,forcesave=FALSE;
        !            51: BOOL new_install=FALSE;
        !            52: static BOOL auto_save=FALSE;
        !            53: extern BOOL all_msghdr;
        !            54: extern BOOL no_msghdr;
        !            55: char **opt;
        !            56: char tmp[256];
        !            57: char error[256];
        !            58: int  backup_level=5;
        !            59: 
        !            60: char *invalid_code=
        !            61:        "`Invalid Internal Code:`\n\n"
        !            62:        "Internal codes can be up to eight characters in length and can only\n"
        !            63:        "contain valid DOS filename characters. The code you have entered\n"
        !            64:        "contains one or more invalid characters.";
        !            65: 
        !            66: char *num_flags=
        !            67:        "`Number of Flags Needed:`\n\n"
        !            68:        "If you want users to be required to have all the flags, select `All`.\n"
        !            69:        "\n"
        !            70:        "If you want users to be required to have any one or more of the flags,\n"
        !            71:        "select `One` (Allowed).";
        !            72: 
        !            73: 
        !            74: void allocfail(uint size)
        !            75: {
        !            76:     printf("\7Error allocating %u bytes of memory.\r\n",size);
        !            77:     bail(1);
        !            78: }
        !            79: 
        !            80: int main(int argc, char **argv)
        !            81: {
        !            82:        char    **mopt,*p;
        !            83:     char    errormsg[MAX_PATH*2];
        !            84:        int     i,j,main_dflt=0,chat_dflt=0;
        !            85:        char    str[MAX_PATH+1];
        !            86:        char    exepath[MAX_PATH+1];
        !            87:        BOOL    door_mode=FALSE;
        !            88:        int             ciolib_mode=CIOLIB_MODE_AUTO;
        !            89: 
        !            90:     printf("\r\nSynchronet Configuration Utility (%s)  v%s  Copyright %s "
        !            91:         "Rob Swindell\r\n",PLATFORM_DESC,VERSION,__DATE__+7);
        !            92: 
        !            93:        cfg.size=sizeof(cfg);
        !            94: 
        !            95:     memset(&uifc,0,sizeof(uifc));
        !            96:     p=getenv("SBBSCTRL");
        !            97:     if(p!=NULL)
        !            98:         SAFECOPY(cfg.ctrl_dir,p);
        !            99:     else
        !           100:         getcwd(cfg.ctrl_dir,sizeof(cfg.ctrl_dir));
        !           101: 
        !           102:        uifc.esc_delay=25;
        !           103: 
        !           104:        for(i=1;i<argc;i++) {
        !           105:         if(argv[i][0]=='-'
        !           106: #ifndef __unix__
        !           107:             || argv[i][0]=='/'
        !           108: #endif
        !           109:             )
        !           110:             switch(toupper(argv[i][1])) {
        !           111:                 case 'N':   /* Set "New Installation" flag */
        !           112:                                        new_install=TRUE;
        !           113:                                        forcesave=TRUE;
        !           114:                     continue;
        !           115:                        case 'M':   /* Monochrome mode */
        !           116:                                uifc.mode|=UIFC_MONO;
        !           117:                     break;
        !           118:                 case 'C':
        !           119:                                uifc.mode|=UIFC_COLOR;
        !           120:                     break;
        !           121:                 case 'D':
        !           122:                                        printf("NOTICE: The -d option is depreciated, use -id instead\r\n");
        !           123:                                        SLEEP(2000);
        !           124:                     door_mode=TRUE;
        !           125:                     break;
        !           126:                 case 'B':
        !           127:                                backup_level=atoi(argv[i]+2);
        !           128:                     break;
        !           129:                                case 'U':
        !           130:                                        umask(strtoul(argv[i]+2,NULL,8));
        !           131:                                        break;
        !           132:                 case 'S':
        !           133:                                no_dirchk=!no_dirchk;
        !           134:                     break;
        !           135:                 case 'H':
        !           136:                                no_msghdr=!no_msghdr;
        !           137:                     break;
        !           138:                 case 'A':
        !           139:                                all_msghdr=!all_msghdr;
        !           140:                     break;
        !           141:                 case 'F':
        !           142:                        forcesave=TRUE;
        !           143:                     break;
        !           144:                 case 'L':
        !           145:                     uifc.scrn_len=atoi(argv[i]+2);
        !           146:                     break;
        !           147:                 case 'E':
        !           148:                     uifc.esc_delay=atoi(argv[i]+2);
        !           149:                     break;
        !           150:                                case 'I':
        !           151:                                        switch(toupper(argv[i][2])) {
        !           152:                                                case 'A':
        !           153:                                                        ciolib_mode=CIOLIB_MODE_ANSI;
        !           154:                                                        break;
        !           155:                                                case 'C':
        !           156:                                                        ciolib_mode=CIOLIB_MODE_CURSES;
        !           157:                                                        break;
        !           158:                                                case 0:
        !           159:                                                        printf("NOTICE: The -i option is depreciated, use -if instead\r\n");
        !           160:                                                        SLEEP(2000);
        !           161:                                                case 'F':
        !           162:                                                        ciolib_mode=CIOLIB_MODE_CURSES_IBM;
        !           163:                                                        break;
        !           164:                                                case 'X':
        !           165:                                                        ciolib_mode=CIOLIB_MODE_X;
        !           166:                                                        break;
        !           167:                                                case 'W':
        !           168:                                                        ciolib_mode=CIOLIB_MODE_CONIO;
        !           169:                                                        break;
        !           170:                                                case 'D':
        !           171:                                    door_mode=TRUE;
        !           172:                                    break;
        !           173:                                                default:
        !           174:                                                        goto USAGE;
        !           175:                                        }
        !           176:                                        break;
        !           177:                 case 'V':
        !           178:                     textmode(atoi(argv[i]+2));
        !           179:                     break;
        !           180:                                case 'Y':
        !           181:                                        auto_save=TRUE;
        !           182:                                        break;
        !           183:                                case 'T':
        !           184:                                        /* Legacy (time-slice API), ignore */
        !           185:                                        break;
        !           186:                 default:
        !           187:                                        USAGE:
        !           188:                     printf("\nusage: scfg [ctrl_dir] [options]"
        !           189:                         "\n\noptions:\n\n"
        !           190:                         "-s  =  don't check directories\r\n"
        !           191:                         "-f  =  force save of config files\r\n"
        !           192:                         "-a  =  update all message base status headers\r\n"
        !           193:                         "-h  =  don't update message base status headers\r\n"
        !           194:                                                "-u# =  set file creation permissions mask (in octal)\n"
        !           195:                         "-c  =  force color mode\r\n"
        !           196:                                                "-m  =  force monochrome mode\r\n"
        !           197:                         "-e# =  set escape delay to #msec\r\n"
        !           198:                                                "-iX =  set interface mode to X (default=auto) where X is one of:\r\n"
        !           199: #ifdef __unix__
        !           200:                                                "       X = X11 mode\r\n"
        !           201:                                                "       C = Curses mode\r\n"
        !           202:                                                "       F = Curses mode with forced IBM charset\r\n"
        !           203: #else
        !           204:                                                "       W = Win32 native mode\r\n"
        !           205: #endif
        !           206:                                                "       A = ANSI mode\r\n"
        !           207:                                                "       D = standard input/output/door mode\r\n"
        !           208:                         "-v# =  set video mode to # (default=auto)\r\n"
        !           209:                         "-l# =  set screen lines to # (default=auto-detect)\r\n"
        !           210:                         "-b# =  set automatic back-up level (default=%d)\r\n"
        !           211:                                                "-y  =  automatically save changes (don't ask)\r\n"
        !           212:                                                ,backup_level
        !           213:                         );
        !           214:                                exit(0);
        !           215:            }
        !           216:         else
        !           217:             SAFECOPY(cfg.ctrl_dir,argv[i]);
        !           218:     }
        !           219: 
        !           220:        FULLPATH(exepath,argv[0],sizeof(exepath));      /* Must do this before chdir */
        !           221: 
        !           222:        if(chdir(cfg.ctrl_dir)!=0) {
        !           223:                printf("!ERROR %d changing current directory to: %s\n"
        !           224:                        ,errno,cfg.ctrl_dir);
        !           225:                exit(-1);
        !           226:        }
        !           227:        FULLPATH(cfg.ctrl_dir,".",sizeof(cfg.ctrl_dir));
        !           228:        backslashcolon(cfg.ctrl_dir);
        !           229: 
        !           230:        uifc.size=sizeof(uifc);
        !           231:        if(!door_mode) {
        !           232:                i=initciolib(ciolib_mode);
        !           233:                if(i!=0) {
        !           234:                printf("ciolib library init returned error %d\n",i);
        !           235:                exit(1);
        !           236:                }
        !           237:                i=uifcini32(&uifc);  /* curses/conio/X/ANSI */
        !           238:        }
        !           239:        else
        !           240:                i=uifcinix(&uifc);  /* stdio */
        !           241:        if(i!=0) {
        !           242:                printf("uifc library init returned error %d\n",i);
        !           243:                exit(1);
        !           244:        }
        !           245: 
        !           246:        if((opt=(char **)malloc(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           247:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           248:        for(i=0;i<(MAX_OPTS+1);i++)
        !           249:                if((opt[i]=(char *)malloc(MAX_OPLN))==NULL)
        !           250:                        allocfail(MAX_OPLN);
        !           251: 
        !           252:        if((mopt=(char **)malloc(sizeof(char *)*14))==NULL)
        !           253:                allocfail(sizeof(char *)*14);
        !           254:        for(i=0;i<14;i++)
        !           255:                if((mopt[i]=(char *)malloc(64))==NULL)
        !           256:                        allocfail(64);
        !           257: 
        !           258:        if((p=getenv("SBBSEXEC"))!=NULL)
        !           259:                SAFECOPY(str,p);
        !           260:        else {
        !           261:                SAFECOPY(str,exepath);
        !           262:                p=strrchr(str,'/');
        !           263:                if(p==NULL)
        !           264:                        p=strrchr(str,'\\');
        !           265:                if(p!=NULL)
        !           266:                        *p=0;
        !           267:                else 
        !           268:                        sprintf(str,"%s../exec",cfg.ctrl_dir);
        !           269:        }
        !           270:        FULLPATH(uifc.helpdatfile,str,sizeof(uifc.helpdatfile));
        !           271:        backslash(uifc.helpdatfile);
        !           272:        SAFECOPY(uifc.helpixbfile,uifc.helpdatfile);
        !           273:        strcat(uifc.helpdatfile,"scfghelp.dat");
        !           274:        strcat(uifc.helpixbfile,"scfghelp.ixb");
        !           275: 
        !           276:        sprintf(str,"Synchronet for %s v%s",PLATFORM_DESC,VERSION);
        !           277:        if(uifc.scrn(str)) {
        !           278:                printf(" USCRN (len=%d) failed!\r\n",uifc.scrn_len+1);
        !           279:                bail(1);
        !           280:        }
        !           281: 
        !           282:        if(!fexist(uifc.helpdatfile)) {
        !           283:                sprintf(errormsg,"Help file (%s) missing!",uifc.helpdatfile);
        !           284:                uifc.msg(errormsg);
        !           285:        }
        !           286:        if(!fexist(uifc.helpixbfile)) {
        !           287:                sprintf(errormsg,"Help file (%s) missing!",uifc.helpixbfile);
        !           288:                uifc.msg(errormsg);
        !           289:        }
        !           290:        sprintf(str,"%smain.cnf",cfg.ctrl_dir);
        !           291:        if(!fexist(str)) {
        !           292:                sprintf(errormsg,"Main configuration file (%s) missing!",str);
        !           293:                uifc.msg(errormsg);
        !           294:        }
        !           295: 
        !           296:        i=0;
        !           297:        strcpy(mopt[i++],"Nodes");
        !           298:        strcpy(mopt[i++],"System");
        !           299:        strcpy(mopt[i++],"Networks");
        !           300:        strcpy(mopt[i++],"File Areas");
        !           301:        strcpy(mopt[i++],"File Options");
        !           302:        strcpy(mopt[i++],"Chat Features");
        !           303:        strcpy(mopt[i++],"Message Areas");
        !           304:        strcpy(mopt[i++],"Message Options");
        !           305:        strcpy(mopt[i++],"Command Shells");
        !           306:        strcpy(mopt[i++],"External Programs");
        !           307:        strcpy(mopt[i++],"Text File Sections");
        !           308:        mopt[i][0]=0;
        !           309:        while(1) {
        !           310:                SETHELP(WHERE);
        !           311: /*
        !           312: `Main Configuration Menu:`
        !           313: 
        !           314: This is the main menu of the Synchronet configuration utility (SCFG).
        !           315: From this menu, you have the following choices:
        !           316: 
        !           317:        Nodes                             : Add, delete, or configure nodes
        !           318:        System                            : System-wide configuration options
        !           319:        Networks                          : Message networking configuration
        !           320:        File Areas                        : File area configuration
        !           321:        File Options              : File area options
        !           322:        Chat Features             : Chat actions, sections, pagers, and gurus
        !           323:        Message Areas             : Message area configuration
        !           324:        Message Options           : Message and email options
        !           325:        External Programs         : Events, editors, and online programs
        !           326:        Text File Sections        : General text file area
        !           327: 
        !           328: Use the arrow keys and ~ ENTER ~ to select an option, or ~ ESC ~ to exit.
        !           329: */
        !           330:                switch(uifc.list(WIN_ORG|WIN_MID|WIN_ESC|WIN_ACT,0,0,30,&main_dflt,0
        !           331:                        ,"Configure",mopt)) {
        !           332:                        case 0:
        !           333:                                uifc.pop("Reading MAIN.CNF...");
        !           334:                                if(!read_main_cfg(&cfg,error)) {
        !           335:                                        uifc.pop(0);
        !           336:                                        sprintf(errormsg,"ERROR: %s",error);
        !           337:                                        uifc.msg(errormsg);
        !           338:                                        break;
        !           339:                                }
        !           340:                                uifc.pop(0);
        !           341:                                node_menu();
        !           342:                                free_main_cfg(&cfg);
        !           343:                                break;
        !           344:                        case 1:
        !           345:                                uifc.pop("Reading MAIN.CNF...");
        !           346:                                if(!read_main_cfg(&cfg,error)) {
        !           347:                                        uifc.pop(0);
        !           348:                                        sprintf(errormsg,"ERROR: %s",error);
        !           349:                                        uifc.msg(errormsg);
        !           350:                                        break;
        !           351:                                }
        !           352:                                uifc.pop("Reading XTRN.CNF...");
        !           353:                                if(!read_xtrn_cfg(&cfg,error)) {
        !           354:                                        uifc.pop(0);
        !           355:                                        sprintf(errormsg,"ERROR: %s",error);
        !           356:                                        uifc.msg(errormsg);
        !           357:                                        break;
        !           358:                                }
        !           359:                                uifc.pop(0);
        !           360:                                sys_cfg();
        !           361:                                free_xtrn_cfg(&cfg);
        !           362:                                free_main_cfg(&cfg);
        !           363:                                break;
        !           364:                        case 2:
        !           365:                                uifc.pop("Reading MAIN.CNF...");
        !           366:                                if(!read_main_cfg(&cfg,error)) {
        !           367:                                        uifc.pop(0);
        !           368:                                        sprintf(errormsg,"ERROR: %s",error);
        !           369:                                        uifc.msg(errormsg);
        !           370:                                        break;
        !           371:                                }
        !           372:                                uifc.pop("Reading MSGS.CNF...");
        !           373:                                if(!read_msgs_cfg(&cfg,error)) {
        !           374:                                        uifc.pop(0);
        !           375:                                        sprintf(errormsg,"ERROR: %s",error);
        !           376:                                        uifc.msg(errormsg);
        !           377:                                        break;
        !           378:                                }
        !           379:                                uifc.pop(0);
        !           380:                                net_cfg();
        !           381:                                free_msgs_cfg(&cfg);
        !           382:                                free_main_cfg(&cfg);
        !           383:                                break;
        !           384:                        case 3:
        !           385:                                uifc.pop("Reading MAIN.CNF...");
        !           386:                                if(!read_main_cfg(&cfg,error)) {
        !           387:                                        uifc.pop(0);
        !           388:                                        sprintf(errormsg,"ERROR: %s",error);
        !           389:                                        uifc.msg(errormsg);
        !           390:                                        break;
        !           391:                                }
        !           392:                                uifc.pop("Reading FILE.CNF...");
        !           393:                                if(!read_file_cfg(&cfg,error)) {
        !           394:                                        uifc.pop(0);
        !           395:                                        sprintf(errormsg,"ERROR: %s",error);
        !           396:                                        uifc.msg(errormsg);
        !           397:                                        break;
        !           398:                                }       
        !           399:                                uifc.pop(0);
        !           400:                                xfer_cfg();
        !           401:                                free_file_cfg(&cfg);
        !           402:                                free_main_cfg(&cfg);
        !           403:                                break;
        !           404:                        case 4:
        !           405:                                uifc.pop("Reading MAIN.CNF...");
        !           406:                                if(!read_main_cfg(&cfg,error)) {
        !           407:                                        uifc.pop(0);
        !           408:                                        sprintf(errormsg,"ERROR: %s",error);
        !           409:                                        uifc.msg(errormsg);
        !           410:                                        break;
        !           411:                                }
        !           412:                                uifc.pop("Reading FILE.CNF...");
        !           413:                                if(!read_file_cfg(&cfg,error)) {
        !           414:                                        uifc.pop(0);
        !           415:                                        sprintf(errormsg,"ERROR: %s",error);
        !           416:                                        uifc.msg(errormsg);
        !           417:                                        break;
        !           418:                                }
        !           419:                                uifc.pop(0);
        !           420:                                xfer_opts();
        !           421:                                free_file_cfg(&cfg);
        !           422:                                free_main_cfg(&cfg);
        !           423:                                break;
        !           424:                        case 5:
        !           425:                                uifc.pop("Reading CHAT.CNF...");
        !           426:                                if(!read_chat_cfg(&cfg,error)) {
        !           427:                                        uifc.pop(0);
        !           428:                                        sprintf(errormsg,"ERROR: %s",error);
        !           429:                                        uifc.msg(errormsg);
        !           430:                                        break;
        !           431:                                }       
        !           432:                                uifc.pop(0);
        !           433:                                while(1) {
        !           434:                                        i=0;
        !           435:                                        strcpy(opt[i++],"Artificial Gurus");
        !           436:                                        strcpy(opt[i++],"Multinode Chat Actions");
        !           437:                                        strcpy(opt[i++],"Multinode Chat Channels");
        !           438:                                        strcpy(opt[i++],"External Sysop Chat Pagers");
        !           439:                                        opt[i][0]=0;
        !           440:                                        j=uifc.list(WIN_ORG|WIN_ACT|WIN_CHE,0,0,0,&chat_dflt,0
        !           441:                                                ,"Chat Features",opt);
        !           442:                                        if(j==-1) {
        !           443:                                                j=save_changes(WIN_MID);
        !           444:                                                if(j==-1)
        !           445:                                                        continue;
        !           446:                                                if(!j) {
        !           447:                                                        write_chat_cfg(&cfg,backup_level);
        !           448:                                                        refresh_cfg(&cfg);
        !           449:                                                }
        !           450:                                                break;
        !           451:                                        }
        !           452:                                        switch(j) {
        !           453:                                                case 0:
        !           454:                                                        guru_cfg();
        !           455:                                                        break;
        !           456:                                                case 1:
        !           457:                                                        actsets_cfg();
        !           458:                                                        break;
        !           459:                                                case 2:
        !           460:                                                        chan_cfg();
        !           461:                                                        break;
        !           462:                                                case 3:
        !           463:                                                        page_cfg();
        !           464:                                                        break; 
        !           465:                                        } 
        !           466:                                }
        !           467:                                free_chat_cfg(&cfg);
        !           468:                                break;
        !           469:                        case 6:
        !           470:                                uifc.pop("Reading MAIN.CNF...");
        !           471:                                if(!read_main_cfg(&cfg,error)) {
        !           472:                                        uifc.pop(0);
        !           473:                                        sprintf(errormsg,"ERROR: %s",error);
        !           474:                                        uifc.msg(errormsg);
        !           475:                                        break;
        !           476:                                }
        !           477:                                uifc.pop("Reading MSGS.CNF...");
        !           478:                                if(!read_msgs_cfg(&cfg,error)) {
        !           479:                                        uifc.pop(0);
        !           480:                                        sprintf(errormsg,"ERROR: %s",error);
        !           481:                                        uifc.msg(errormsg);
        !           482:                                        break;
        !           483:                                }
        !           484:                                uifc.pop(0);
        !           485:                                msgs_cfg();
        !           486:                                free_msgs_cfg(&cfg);
        !           487:                                free_main_cfg(&cfg);
        !           488:                                break;
        !           489:                        case 7:
        !           490:                                uifc.pop("Reading MAIN.CNF...");
        !           491:                                if(!read_main_cfg(&cfg,error)) {
        !           492:                                        uifc.pop(0);
        !           493:                                        sprintf(errormsg,"ERROR: %s",error);
        !           494:                                        uifc.msg(errormsg);
        !           495:                                        break;
        !           496:                                }
        !           497:                                uifc.pop("Reading MSGS.CNF...");
        !           498:                                if(!read_msgs_cfg(&cfg,error)) {
        !           499:                                        uifc.pop(0);
        !           500:                                        sprintf(errormsg,"ERROR: %s",error);
        !           501:                                        uifc.msg(errormsg);
        !           502:                                        break;
        !           503:                                }
        !           504:                                uifc.pop(0);
        !           505:                                msg_opts();
        !           506:                                free_msgs_cfg(&cfg);
        !           507:                                free_main_cfg(&cfg);
        !           508:                                break;
        !           509:                        case 8:
        !           510:                                uifc.pop("Reading MAIN.CNF...");
        !           511:                                if(!read_main_cfg(&cfg,error)) {
        !           512:                                        uifc.pop(0);
        !           513:                                        sprintf(errormsg,"ERROR: %s",error);
        !           514:                                        uifc.msg(errormsg);
        !           515:                                        break;
        !           516:                                }
        !           517:                                uifc.pop(0);
        !           518:                                shell_cfg();
        !           519:                                free_main_cfg(&cfg);
        !           520:                                break;
        !           521:                        case 9:
        !           522:                                uifc.pop("Reading MAIN.CNF...");
        !           523:                                if(!read_main_cfg(&cfg,error)) {
        !           524:                                        uifc.pop(0);
        !           525:                                        sprintf(errormsg,"ERROR: %s",error);
        !           526:                                        uifc.msg(errormsg);
        !           527:                                        break;
        !           528:                                }
        !           529:                                uifc.pop("Reading XTRN.CNF...");
        !           530:                                if(!read_xtrn_cfg(&cfg,error)) {
        !           531:                                        uifc.pop(0);
        !           532:                                        sprintf(errormsg,"ERROR: %s",error);
        !           533:                                        uifc.msg(errormsg);
        !           534:                                        break;
        !           535:                                }
        !           536:                                uifc.pop(0);
        !           537:                                xprogs_cfg();
        !           538:                                free_xtrn_cfg(&cfg);
        !           539:                                free_main_cfg(&cfg);
        !           540:                                break;
        !           541:                        case 10:
        !           542:                                uifc.pop("Reading MAIN.CNF...");
        !           543:                                if(!read_main_cfg(&cfg,error)) {
        !           544:                                        uifc.pop(0);
        !           545:                                        sprintf(errormsg,"ERROR: %s",error);
        !           546:                                        uifc.msg(errormsg);
        !           547:                                        break;
        !           548:                                }
        !           549:                                uifc.pop("Reading FILE.CNF...");
        !           550:                                if(!read_file_cfg(&cfg,error)) {
        !           551:                                        uifc.pop(0);
        !           552:                                        sprintf(errormsg,"ERROR: %s",error);
        !           553:                                        uifc.msg(errormsg);
        !           554:                                        break;
        !           555:                                }
        !           556:                                uifc.pop(0);
        !           557:                                txt_cfg();
        !           558:                                free_file_cfg(&cfg);
        !           559:                                free_main_cfg(&cfg);
        !           560:                                break;
        !           561:                        case -1:
        !           562:                                i=0;
        !           563:                                strcpy(opt[0],"Yes");
        !           564:                                strcpy(opt[1],"No");
        !           565:                                opt[2][0]=0;
        !           566:                                SETHELP(WHERE);
        !           567: /*
        !           568: `Exit SCFG:`
        !           569: 
        !           570: If you want to exit the Synchronet configuration utility, select `Yes`.
        !           571: Otherwise, select `No` or hit ~ ESC ~.
        !           572: */
        !           573:                                i=uifc.list(WIN_MID,0,0,0,&i,0,"Exit SCFG",opt);
        !           574:                                if(!i)
        !           575:                                        bail(0);
        !           576:                                break; 
        !           577:                } 
        !           578:        }
        !           579: }
        !           580: 
        !           581: /****************************************************************************/
        !           582: /* Checks the uifc.changes variable. If there have been no uifc.changes, returns 2.    */
        !           583: /* If there have been uifc.changes, it prompts the user to change or not. If the */
        !           584: /* user escapes the menu, returns -1, selects Yes, 0, and selects no, 1        */
        !           585: /****************************************************************************/
        !           586: int save_changes(int mode)
        !           587: {
        !           588:        int i=0;
        !           589: 
        !           590:        if(!uifc.changes)
        !           591:                return(2);
        !           592:        if(auto_save==TRUE)     { /* -y switch used, return "Yes" */
        !           593:                uifc.changes=0;
        !           594:                return(0);
        !           595:        }
        !           596:        strcpy(opt[0],"Yes");
        !           597:        strcpy(opt[1],"No");
        !           598:        opt[2][0]=0;
        !           599:        SETHELP(WHERE);
        !           600: /*
        !           601: `Save uifc.changes:`
        !           602: 
        !           603: You have made some uifc.changes to the configuration. If you want to save
        !           604: these uifc.changes, select `Yes`. If you are positive you DO NOT want to save
        !           605: these uifc.changes, select `No`. If you are not sure and want to review the
        !           606: configuration before deciding, hit ~ ESC ~.
        !           607: */
        !           608:        i=uifc.list(mode|WIN_ACT,0,0,0,&i,0,"Save Changes",opt);
        !           609:        if(i!=-1)
        !           610:                uifc.changes=0;
        !           611:        return(i);
        !           612: }
        !           613: 
        !           614: void txt_cfg()
        !           615: {
        !           616:        static int txt_dflt,bar;
        !           617:        char str[81],code[9],done=0,*p;
        !           618:        int j,k;
        !           619:        uint i;
        !           620:        static txtsec_t savtxtsec;
        !           621: 
        !           622:        while(1) {
        !           623:                for(i=0;i<cfg.total_txtsecs;i++)
        !           624:                        sprintf(opt[i],"%-25s",cfg.txtsec[i]->name);
        !           625:                opt[i][0]=0;
        !           626:                j=WIN_ORG|WIN_ACT|WIN_CHE;
        !           627:                if(cfg.total_txtsecs)
        !           628:                        j|=WIN_DEL|WIN_GET;
        !           629:                if(cfg.total_txtsecs<MAX_OPTS)
        !           630:                        j|=WIN_INS|WIN_INSACT|WIN_XTR;
        !           631:                if(savtxtsec.name[0])
        !           632:                        j|=WIN_PUT;
        !           633:                SETHELP(WHERE);
        !           634: /*
        !           635: `Text File Sections:`
        !           636: 
        !           637: This is a list of `General Text File (G-File) Sections` configured for
        !           638: your system. G-File sections are used to store text files that can be
        !           639: viewed freely by the users. Common text file section topics include
        !           640: `ANSI Artwork`, `System Information`, `Game Help Files`, and other special
        !           641: interest topics.
        !           642: 
        !           643: To add a text file section, select the desired location with the arrow
        !           644: keys and hit ~ INS ~.
        !           645: 
        !           646: To delete a text file section, select it and hit ~ DEL ~.
        !           647: 
        !           648: To configure a text file, select it and hit ~ ENTER ~.
        !           649: */
        !           650:                i=uifc.list(j,0,0,45,&txt_dflt,&bar,"Text File Sections",opt);
        !           651:                if((signed)i==-1) {
        !           652:                        j=save_changes(WIN_MID);
        !           653:                        if(j==-1)
        !           654:                                continue;
        !           655:                        if(!j) {
        !           656:                                write_file_cfg(&cfg,backup_level);
        !           657:                                refresh_cfg(&cfg);
        !           658:                        }
        !           659:                        return;
        !           660:                }
        !           661:                if((i&MSK_ON)==MSK_INS) {
        !           662:                        i&=MSK_OFF;
        !           663:                        strcpy(str,"ANSI Artwork");
        !           664:                        SETHELP(WHERE);
        !           665: /*
        !           666: `Text Section Name:`
        !           667: 
        !           668: This is the name of this text section.
        !           669: */
        !           670:                        if(uifc.input(WIN_MID|WIN_SAV,0,0,"Text Section Name",str,40
        !           671:                                ,K_EDIT)<1)
        !           672:                                continue;
        !           673:                        sprintf(code,"%.8s",str);
        !           674:                        p=strchr(code,' ');
        !           675:                        if(p) *p=0;
        !           676:                        strupr(code);
        !           677:                        SETHELP(WHERE);
        !           678: /*
        !           679: `Text Section Internal Code:`
        !           680: 
        !           681: Every text file section must have its own unique internal code for
        !           682: Synchronet to reference it by. It is helpful if this code is an
        !           683: abreviation of the name.
        !           684: */
        !           685:                        if(uifc.input(WIN_MID|WIN_SAV,0,0,"Text Section Internal Code",code,LEN_CODE
        !           686:                                ,K_EDIT)<1)
        !           687:                                continue;
        !           688:                        if(!code_ok(code)) {
        !           689:                                uifc.helpbuf=invalid_code;
        !           690:                                uifc.msg("Invalid Code");
        !           691:                                uifc.helpbuf=0;
        !           692:                                continue; }
        !           693:                        if((cfg.txtsec=(txtsec_t **)realloc(cfg.txtsec
        !           694:                                ,sizeof(txtsec_t *)*(cfg.total_txtsecs+1)))==NULL) {
        !           695:                                errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_txtsecs+1);
        !           696:                                cfg.total_txtsecs=0;
        !           697:                                bail(1);
        !           698:                                continue; }
        !           699:                        if(cfg.total_txtsecs)
        !           700:                                for(j=cfg.total_txtsecs;j>i;j--)
        !           701:                                        cfg.txtsec[j]=cfg.txtsec[j-1];
        !           702:                        if((cfg.txtsec[i]=(txtsec_t *)malloc(sizeof(txtsec_t)))==NULL) {
        !           703:                                errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(txtsec_t));
        !           704:                                continue; }
        !           705:                        memset((txtsec_t *)cfg.txtsec[i],0,sizeof(txtsec_t));
        !           706:                        strcpy(cfg.txtsec[i]->name,str);
        !           707:                        strcpy(cfg.txtsec[i]->code,code);
        !           708:                        cfg.total_txtsecs++;
        !           709:                        uifc.changes=1;
        !           710:                        continue; }
        !           711:                if((i&MSK_ON)==MSK_DEL) {
        !           712:                        i&=MSK_OFF;
        !           713:                        free(cfg.txtsec[i]);
        !           714:                        cfg.total_txtsecs--;
        !           715:                        for(j=i;j<cfg.total_txtsecs;j++)
        !           716:                                cfg.txtsec[j]=cfg.txtsec[j+1];
        !           717:                        uifc.changes=1;
        !           718:                        continue; }
        !           719:                if((i&MSK_ON)==MSK_GET) {
        !           720:                        i&=MSK_OFF;
        !           721:                        savtxtsec=*cfg.txtsec[i];
        !           722:                        continue; }
        !           723:                if((i&MSK_ON)==MSK_PUT) {
        !           724:                        i&=MSK_OFF;
        !           725:                        *cfg.txtsec[i]=savtxtsec;
        !           726:                        uifc.changes=1;
        !           727:                        continue; }
        !           728:                i=txt_dflt;
        !           729:                j=0;
        !           730:                done=0;
        !           731:                while(!done) {
        !           732:                        k=0;
        !           733:                        sprintf(opt[k++],"%-27.27s%s","Name",cfg.txtsec[i]->name);
        !           734:                        sprintf(opt[k++],"%-27.27s%s","Access Requirements"
        !           735:                                ,cfg.txtsec[i]->arstr);
        !           736:                        sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.txtsec[i]->code);
        !           737:                        opt[k][0]=0;
        !           738:                        switch(uifc.list(WIN_ACT|WIN_MID,0,0,60,&j,0,cfg.txtsec[i]->name
        !           739:                                ,opt)) {
        !           740:                                case -1:
        !           741:                                        done=1;
        !           742:                                        break;
        !           743:                                case 0:
        !           744:                                        SETHELP(WHERE);
        !           745: /*
        !           746: `Text Section Name:`
        !           747: 
        !           748: This is the name of this text section.
        !           749: */
        !           750:                                        strcpy(str,cfg.txtsec[i]->name);        /* save */
        !           751:                                        if(!uifc.input(WIN_MID|WIN_SAV,0,10
        !           752:                                                ,"Text File Section Name"
        !           753:                                                ,cfg.txtsec[i]->name,sizeof(cfg.txtsec[i]->name)-1,K_EDIT))
        !           754:                                                strcpy(cfg.txtsec[i]->name,str);
        !           755:                                        break;
        !           756:                                case 1:
        !           757:                                        sprintf(str,"%s Text Section",cfg.txtsec[i]->name);
        !           758:                                        getar(str,cfg.txtsec[i]->arstr);
        !           759:                                        break;
        !           760:                                case 2:
        !           761:                                        strcpy(str,cfg.txtsec[i]->code);
        !           762:                                        SETHELP(WHERE);
        !           763: /*
        !           764: `Text Section Internal Code:`
        !           765: 
        !           766: Every text file section must have its own unique internal code for
        !           767: Synchronet to reference it by. It is helpful if this code is an
        !           768: abreviation of the name.
        !           769: */
        !           770:                                        uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)"
        !           771:                                                ,str,LEN_CODE,K_EDIT);
        !           772:                                        if(code_ok(str))
        !           773:                                                strcpy(cfg.txtsec[i]->code,str);
        !           774:                                        else {
        !           775:                                                uifc.helpbuf=invalid_code;
        !           776:                                                uifc.msg("Invalid Code");
        !           777:                                                uifc.helpbuf=0; }
        !           778:                                        break; 
        !           779:                        } 
        !           780:                } 
        !           781:        }
        !           782: }
        !           783: 
        !           784: void shell_cfg()
        !           785: {
        !           786:        static int shell_dflt,shell_bar;
        !           787:        char str[81],code[9],done=0,*p;
        !           788:        int j,k;
        !           789:        uint i;
        !           790:        static shell_t savshell;
        !           791: 
        !           792:        while(1) {
        !           793:                for(i=0;i<cfg.total_shells;i++)
        !           794:                        sprintf(opt[i],"%-25s",cfg.shell[i]->name);
        !           795:                opt[i][0]=0;
        !           796:                j=WIN_ORG|WIN_ACT|WIN_CHE;
        !           797:                if(cfg.total_shells)
        !           798:                        j|=WIN_DEL|WIN_GET;
        !           799:                if(cfg.total_shells<MAX_OPTS)
        !           800:                        j|=WIN_INS|WIN_INSACT|WIN_XTR;
        !           801:                if(savshell.name[0])
        !           802:                        j|=WIN_PUT;
        !           803:                SETHELP(WHERE);
        !           804: /*
        !           805: `Command Shells:`
        !           806: 
        !           807: This is a list of `Command Shells` configured for your system.
        !           808: Command shells are the programmable command and menu structures which
        !           809: are available for your BBS.
        !           810: 
        !           811: To add a command shell section, select the desired location with the
        !           812: arrow keys and hit ~ INS ~.
        !           813: 
        !           814: To delete a command shell, select it and hit ~ DEL ~.
        !           815: 
        !           816: To configure a command shell, select it and hit ~ ENTER ~.
        !           817: */
        !           818:                i=uifc.list(j,0,0,45,&shell_dflt,&shell_bar,"Command Shells",opt);
        !           819:                if((signed)i==-1) {
        !           820:                        j=save_changes(WIN_MID);
        !           821:                        if(j==-1)
        !           822:                                continue;
        !           823:                        if(!j) {
        !           824:                                cfg.new_install=new_install;
        !           825:                                write_main_cfg(&cfg,backup_level);
        !           826:                                refresh_cfg(&cfg);
        !           827:                        }
        !           828:                        return;
        !           829:                }
        !           830:                if((i&MSK_ON)==MSK_INS) {
        !           831:                        i&=MSK_OFF;
        !           832:                        strcpy(str,"Menu Shell");
        !           833:                        SETHELP(WHERE);
        !           834: /*
        !           835: `Command Shell Name:`
        !           836: 
        !           837: This is the descriptive name of this command shell.
        !           838: */
        !           839:                        if(uifc.input(WIN_MID|WIN_SAV,0,0,"Command Shell Name",str,40
        !           840:                                ,K_EDIT)<1)
        !           841:                                continue;
        !           842:                        sprintf(code,"%.8s",str);
        !           843:                        p=strchr(code,' ');
        !           844:                        if(p) *p=0;
        !           845:                        strupr(code);
        !           846:                        SETHELP(WHERE);
        !           847: /*
        !           848: `Command Shell Internal Code:`
        !           849: 
        !           850: Every command shell must have its own unique internal code for
        !           851: Synchronet to reference it by. It is helpful if this code is an
        !           852: abreviation of the name.
        !           853: 
        !           854: This code will be the base filename used to load the shell from your
        !           855: EXEC directory. e.g. A shell with an internal code of `MYBBS` would
        !           856: indicate a Baja shell file named `MYBBS.BIN` in your EXEC directory.
        !           857: */
        !           858:                        if(uifc.input(WIN_MID|WIN_SAV,0,0,"Command Shell Internal Code",code,LEN_CODE
        !           859:                                ,K_EDIT)<1)
        !           860:                                continue;
        !           861:                        if(!code_ok(code)) {
        !           862:                                uifc.helpbuf=invalid_code;
        !           863:                                uifc.msg("Invalid Code");
        !           864:                                uifc.helpbuf=0;
        !           865:                                continue; }
        !           866:                        if((cfg.shell=(shell_t **)realloc(cfg.shell
        !           867:                                ,sizeof(shell_t *)*(cfg.total_shells+1)))==NULL) {
        !           868:                                errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_shells+1);
        !           869:                                cfg.total_shells=0;
        !           870:                                bail(1);
        !           871:                                continue; }
        !           872:                        if(cfg.total_shells)
        !           873:                                for(j=cfg.total_shells;j>i;j--)
        !           874:                                        cfg.shell[j]=cfg.shell[j-1];
        !           875:                        if((cfg.shell[i]=(shell_t *)malloc(sizeof(shell_t)))==NULL) {
        !           876:                                errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(shell_t));
        !           877:                                continue; }
        !           878:                        memset((shell_t *)cfg.shell[i],0,sizeof(shell_t));
        !           879:                        strcpy(cfg.shell[i]->name,str);
        !           880:                        strcpy(cfg.shell[i]->code,code);
        !           881:                        cfg.total_shells++;
        !           882:                        uifc.changes=1;
        !           883:                        continue; }
        !           884:                if((i&MSK_ON)==MSK_DEL) {
        !           885:                        i&=MSK_OFF;
        !           886:                        free(cfg.shell[i]);
        !           887:                        cfg.total_shells--;
        !           888:                        for(j=i;j<cfg.total_shells;j++)
        !           889:                                cfg.shell[j]=cfg.shell[j+1];
        !           890:                        uifc.changes=1;
        !           891:                        continue; }
        !           892:                if((i&MSK_ON)==MSK_GET) {
        !           893:                        i&=MSK_OFF;
        !           894:                        savshell=*cfg.shell[i];
        !           895:                        continue; }
        !           896:                if((i&MSK_ON)==MSK_PUT) {
        !           897:                        i&=MSK_OFF;
        !           898:                        *cfg.shell[i]=savshell;
        !           899:                        uifc.changes=1;
        !           900:                        continue; }
        !           901:                i=shell_dflt;
        !           902:                j=0;
        !           903:                done=0;
        !           904:                while(!done) {
        !           905:                        k=0;
        !           906:                        sprintf(opt[k++],"%-27.27s%s","Name",cfg.shell[i]->name);
        !           907:                        sprintf(opt[k++],"%-27.27s%s","Access Requirements"
        !           908:                                ,cfg.shell[i]->arstr);
        !           909:                        sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.shell[i]->code);
        !           910:                        opt[k][0]=0;
        !           911:                        SETHELP(WHERE);
        !           912: /*
        !           913: `Command Shell:`
        !           914: 
        !           915: A command shell is a programmed command and menu structure that you or
        !           916: your users can use to navigate the BBS. For every command shell
        !           917: configured here, there must be an associated .BIN file in your EXEC
        !           918: directory for Synchronet to execute.
        !           919: 
        !           920: Command shell files are created by using the Baja command shell compiler
        !           921: to turn Baja source code (.SRC) files into binary files (.BIN) for
        !           922: Synchronet to interpret. See the example .SRC files in the TEXT
        !           923: directory and the documentation for the Baja compiler for more details.
        !           924: */
        !           925:                        switch(uifc.list(WIN_ACT|WIN_MID,0,0,60,&j,0,cfg.shell[i]->name
        !           926:                                ,opt)) {
        !           927:                                case -1:
        !           928:                                        done=1;
        !           929:                                        break;
        !           930:                                case 0:
        !           931:                                        SETHELP(WHERE);
        !           932: /*
        !           933: `Command Shell Name:`
        !           934: 
        !           935: This is the descriptive name of this command shell.
        !           936: */
        !           937:                                        strcpy(str,cfg.shell[i]->name);    /* save */
        !           938:                                        if(!uifc.input(WIN_MID|WIN_SAV,0,10
        !           939:                                                ,"Command Shell Name"
        !           940:                                                ,cfg.shell[i]->name,sizeof(cfg.shell[i]->name)-1,K_EDIT))
        !           941:                                                strcpy(cfg.shell[i]->name,str);
        !           942:                                        break;
        !           943:                                case 1:
        !           944:                                        sprintf(str,"%s Command Shell",cfg.shell[i]->name);
        !           945:                                        getar(str,cfg.shell[i]->arstr);
        !           946:                                        break;
        !           947:                                case 2:
        !           948:                                        strcpy(str,cfg.shell[i]->code);
        !           949:                                        SETHELP(WHERE);
        !           950: /*
        !           951: `Command Shell Internal Code:`
        !           952: 
        !           953: Every command shell must have its own unique internal code for
        !           954: Synchronet to reference it by. It is helpful if this code is an
        !           955: abreviation of the name.
        !           956: 
        !           957: This code will be the base filename used to load the shell from your
        !           958: EXEC directory. e.g. A shell with an internal code of `MYBBS` would
        !           959: indicate a Baja shell file named `MYBBS.BIN` in your EXEC directory.
        !           960: */
        !           961:                                        uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)"
        !           962:                                                ,str,LEN_CODE,K_EDIT);
        !           963:                                        if(code_ok(str))
        !           964:                                                strcpy(cfg.shell[i]->code,str);
        !           965:                                        else {
        !           966:                                                uifc.helpbuf=invalid_code;
        !           967:                                                uifc.msg("Invalid Code");
        !           968:                                                uifc.helpbuf=0; }
        !           969:                                        break; 
        !           970:                        } 
        !           971:                } 
        !           972:        }
        !           973: }
        !           974: 
        !           975: int whichlogic(void)
        !           976: {
        !           977:        int i;
        !           978: 
        !           979:        i=0;
        !           980:        strcpy(opt[0],"Greater than or Equal");
        !           981:        strcpy(opt[1],"Equal");
        !           982:        strcpy(opt[2],"Not Equal");
        !           983:        strcpy(opt[3],"Less than");
        !           984:        opt[4][0]=0;
        !           985:        SETHELP(WHERE);
        !           986: /*
        !           987: `Select Logic for Requirement:`
        !           988: 
        !           989: This menu allows you to choose the type of logic evaluation to use
        !           990: in determining if the requirement is met. If, for example, the user's
        !           991: level is being evaluated and you select `Greater than or Equal` from
        !           992: this menu and set the required level to `50`, the user must have level
        !           993: `50 or higher` to meet this requirement. If you selected `Equal` from
        !           994: this menu and set the required level to `50`, the user must have level
        !           995: `50 exactly`. If you select `Not equal` and level `50`, then the user
        !           996: must have `any level BUT 50`. And if you select `Less than` from this
        !           997: menu and level `50`, the user must have a level `below 50`.
        !           998: */
        !           999:        i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Select Logic",opt);
        !          1000:        return(i);
        !          1001: }
        !          1002: 
        !          1003: int whichcond(void)
        !          1004: {
        !          1005:        int i;
        !          1006: 
        !          1007:        i=0;
        !          1008:        strcpy(opt[0],"AND (Both/All)");
        !          1009:        strcpy(opt[1],"OR  (Either/Any)");
        !          1010:        opt[2][0]=0;
        !          1011:        SETHELP(WHERE);
        !          1012: /*
        !          1013: `Select Logic for Multiple Requirements:`
        !          1014: 
        !          1015: If you wish this new parameter to be required along with the other
        !          1016: parameters, select `AND` to specify that `both` or `all` of the
        !          1017: parameter requirments must be met.
        !          1018: 
        !          1019: If you wish this new parameter to only be required if the other
        !          1020: parameter requirements aren't met, select `OR` to specify that `either`
        !          1021: or `any` of the parameter requirements must be met.
        !          1022: */
        !          1023:        i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Multiple Requirement Logic",opt);
        !          1024:        return(i);
        !          1025: }
        !          1026: 
        !          1027: 
        !          1028: void getar(char *desc, char *inar)
        !          1029: {
        !          1030:        static int curar;
        !          1031:        char str[128],ar[128];
        !          1032:        int i,j,len,done=0,n;
        !          1033: 
        !          1034:        strcpy(ar,inar);
        !          1035:        while(!done) {
        !          1036:        len=strlen(ar);
        !          1037:        if(len>=30) {     /* Needs to be shortened */
        !          1038:                str[0]=0;
        !          1039:                n=strlen(ar);
        !          1040:                for(i=0;i<n;i++) {                                      /* Shorten operators */
        !          1041:                        if(!strncmp(ar+i,"AND",3)) {
        !          1042:                                strcat(str,"&");
        !          1043:                                i+=2; }
        !          1044:                        else if(!strncmp(ar+i,"NOT",3)) {
        !          1045:                                strcat(str,"!");
        !          1046:                                i+=2; }
        !          1047:                        else if(!strncmp(ar+i,"EQUAL",5)) {
        !          1048:                                strcat(str,"=");
        !          1049:                                i+=4; }
        !          1050:                        else if(!strncmp(ar+i,"EQUALS",6)) {
        !          1051:                                strcat(str,"=");
        !          1052:                                i+=5; }
        !          1053:                        else if(!strncmp(ar+i,"EQUAL TO",8)) {
        !          1054:                                strcat(str,"=");
        !          1055:                                i+=7; }
        !          1056:                        else if(!strncmp(ar+i,"OR",2)) {
        !          1057:                                strcat(str,"|");
        !          1058:                                i+=1; }
        !          1059:                        else
        !          1060:                                strncat(str,ar+i,1); }
        !          1061:                strcpy(ar,str);
        !          1062:                len=strlen(ar); }
        !          1063: 
        !          1064:        if(len>=30) {
        !          1065:                str[0]=0;
        !          1066:                n=strlen(ar);
        !          1067:                for(i=0;i<n;i++) {                                      /* Remove spaces from ! and = */
        !          1068:                        if(!strncmp(ar+i," ! ",3)) {
        !          1069:                                strcat(str,"!");
        !          1070:                                i+=2; }
        !          1071:                        else if(!strncmp(ar+i,"= ",2)) {
        !          1072:                                strcat(str,"=");
        !          1073:                 i++; }
        !          1074:                        else if(!strncmp(ar+i," = ",3)) {
        !          1075:                                strcat(str,"=");
        !          1076:                                i+=2; }
        !          1077:                        else
        !          1078:                                strncat(str,ar+i,1); }
        !          1079:                strcpy(ar,str);
        !          1080:         len=strlen(ar); }
        !          1081: 
        !          1082:        if(len>=30) {
        !          1083:                str[0]=0;
        !          1084:                n=strlen(ar);
        !          1085:                for(i=0;i<n;i++) {                                      /* Remove spaces from & and | */
        !          1086:                        if(!strncmp(ar+i," & ",3)) {
        !          1087:                                strcat(str," ");
        !          1088:                                i+=2; }
        !          1089:                        else if(!strncmp(ar+i," | ",3)) {
        !          1090:                                strcat(str,"|");
        !          1091:                                i+=2; }
        !          1092:                        else
        !          1093:                                strncat(str,ar+i,1); }
        !          1094:                strcpy(ar,str);
        !          1095:         len=strlen(ar); }
        !          1096: 
        !          1097:        if(len>=30) {                                   /* change week days to numbers */
        !          1098:         str[0]=0;
        !          1099:         n=strlen(ar);
        !          1100:                for(i=0;i<n;i++) {
        !          1101:                        for(j=0;j<7;j++)
        !          1102:                 if(!strnicmp(ar+i,wday[j],3)) {
        !          1103:                     strcat(str,ultoa(j,tmp,10));
        !          1104:                                        i+=2;
        !          1105:                                        break; }
        !          1106:                        if(j==7)
        !          1107:                                strncat(str,ar+i,1); }
        !          1108:         strcpy(ar,str);
        !          1109:         len=strlen(ar); }
        !          1110: 
        !          1111:        if(len>=30) {                             /* Shorten parameters */
        !          1112:                str[0]=0;
        !          1113:                n=strlen(ar);
        !          1114:                for(i=0;i<n;i++) {
        !          1115:                        if(!strncmp(ar+i,"AGE",3)) {
        !          1116:                                strcat(str,"$A");
        !          1117:                                i+=2; }
        !          1118:                        else if(!strncmp(ar+i,"BPS",3)) {
        !          1119:                                strcat(str,"$B");
        !          1120:                                i+=2; }
        !          1121:                        else if(!strncmp(ar+i,"PCR",3)) {
        !          1122:                                strcat(str,"$P");
        !          1123:                                i+=2; }
        !          1124:                        else if(!strncmp(ar+i,"RIP",3)) {
        !          1125:                                strcat(str,"$*");
        !          1126:                                i+=2; }
        !          1127:                        else if(!strncmp(ar+i,"SEX",3)) {
        !          1128:                                strcat(str,"$S");
        !          1129:                                i+=2; }
        !          1130:                        else if(!strncmp(ar+i,"UDR",3)) {
        !          1131:                                strcat(str,"$K");
        !          1132:                                i+=2; }
        !          1133:                        else if(!strncmp(ar+i,"DAY",3)) {
        !          1134:                                strcat(str,"$W");
        !          1135:                 i+=2; }
        !          1136:                        else if(!strncmp(ar+i,"ANSI",4)) {
        !          1137:                                strcat(str,"$[");
        !          1138:                 i+=3; }
        !          1139:                        else if(!strncmp(ar+i,"UDFR",4)) {
        !          1140:                                strcat(str,"$D");
        !          1141:                                i+=3; }
        !          1142:                        else if(!strncmp(ar+i,"FLAG",4)) {
        !          1143:                                strcat(str,"$F");
        !          1144:                                i+=3; }
        !          1145:                        else if(!strncmp(ar+i,"NODE",4)) {
        !          1146:                                strcat(str,"$N");
        !          1147:                                i+=3; }
        !          1148:                        else if(!strncmp(ar+i,"NULL",4)) {
        !          1149:                                strcat(str,"$0");
        !          1150:                 i+=3; }
        !          1151:                        else if(!strncmp(ar+i,"TIME",4)) {
        !          1152:                                strcat(str,"$T");
        !          1153:                                i+=3; }
        !          1154:                        else if(!strncmp(ar+i,"USER",4)) {
        !          1155:                                strcat(str,"$U");
        !          1156:                                i+=3; }
        !          1157:                        else if(!strncmp(ar+i,"REST",4)) {
        !          1158:                                strcat(str,"$Z");
        !          1159:                 i+=3; }
        !          1160:                        else if(!strncmp(ar+i,"LOCAL",5)) {
        !          1161:                                strcat(str,"$G");
        !          1162:                                i+=4; }
        !          1163:                        else if(!strncmp(ar+i,"LEVEL",5)) {
        !          1164:                                strcat(str,"$L");
        !          1165:                 i+=4; }
        !          1166:                        else if(!strncmp(ar+i,"TLEFT",5)) {
        !          1167:                                strcat(str,"$R");
        !          1168:                                i+=4; }
        !          1169:                        else if(!strncmp(ar+i,"TUSED",5)) {
        !          1170:                                strcat(str,"$O");
        !          1171:                                i+=4; }
        !          1172:                        else if(!strncmp(ar+i,"EXPIRE",6)) {
        !          1173:                                strcat(str,"$E");
        !          1174:                                i+=5; }
        !          1175:                        else if(!strncmp(ar+i,"CREDIT",6)) {
        !          1176:                                strcat(str,"$C");
        !          1177:                 i+=5; }
        !          1178:                        else if(!strncmp(ar+i,"EXEMPT",6)) {
        !          1179:                                strcat(str,"$X");
        !          1180:                 i+=5; }
        !          1181:                        else if(!strncmp(ar+i,"RANDOM",6)) {
        !          1182:                                strcat(str,"$Q");
        !          1183:                 i+=5; }
        !          1184:                        else if(!strncmp(ar+i,"LASTON",6)) {
        !          1185:                                strcat(str,"$Y");
        !          1186:                 i+=5; }
        !          1187:                        else if(!strncmp(ar+i,"LOGONS",6)) {
        !          1188:                                strcat(str,"$V");
        !          1189:                 i+=5; }
        !          1190:                        else if(!strncmp(ar+i,":00",3)) {
        !          1191:                                i+=2; }
        !          1192:                        else
        !          1193:                                strncat(str,ar+i,1); }
        !          1194:                strcpy(ar,str);
        !          1195:                len=strlen(ar); }
        !          1196:        if(len>=30) {                             /* Remove all spaces and &s */
        !          1197:                str[0]=0;
        !          1198:                n=strlen(ar);
        !          1199:                for(i=0;i<n;i++)
        !          1200:                        if(ar[i]!=' ' && ar[i]!='&')
        !          1201:                                strncat(str,ar+i,1);
        !          1202:                strcpy(ar,str);
        !          1203:                len=strlen(ar); }
        !          1204:        i=0;
        !          1205:        sprintf(opt[i++],"Requirement String (%s)",ar);
        !          1206:        strcpy(opt[i++],"Clear Requirements");
        !          1207:        strcpy(opt[i++],"Set Required Level");
        !          1208:        strcpy(opt[i++],"Set Required Flag");
        !          1209:        strcpy(opt[i++],"Set Required Age");
        !          1210:        strcpy(opt[i++],"Set Required Sex");
        !          1211:        strcpy(opt[i++],"Set Required Connect Rate");
        !          1212:        strcpy(opt[i++],"Set Required Post/Call Ratio (percentage)");
        !          1213:        strcpy(opt[i++],"Set Required Number of Credits");
        !          1214:        strcpy(opt[i++],"Set Required Upload/Download Byte Ratio (percentage)");
        !          1215:        strcpy(opt[i++],"Set Required Upload/Download File Ratio (percentage)");
        !          1216:        strcpy(opt[i++],"Set Required Time of Day");
        !          1217:        strcpy(opt[i++],"Set Required Day of Week");
        !          1218:        strcpy(opt[i++],"Set Required Node Number");
        !          1219:        strcpy(opt[i++],"Set Required User Number");
        !          1220:        strcpy(opt[i++],"Set Required Time Remaining");
        !          1221:        strcpy(opt[i++],"Set Required Days Till Expiration");
        !          1222:        opt[i][0]=0;
        !          1223:        SETHELP(WHERE);
        !          1224: /*
        !          1225: `Access Requirements:`
        !          1226: 
        !          1227: This menu allows you to edit the access requirement string for the
        !          1228: selected feature/section of your BBS. You can edit the string
        !          1229: directly (see documentation for details) or use the `Set Required...`
        !          1230: options from this menu to automatically fill in the string for you.
        !          1231: */
        !          1232:        sprintf(str,"%s Requirements",desc);
        !          1233:        switch(uifc.list(WIN_ACT|WIN_MID|WIN_SAV,0,0,60,&curar,0,str,opt)) {
        !          1234:                case -1:
        !          1235:                        done=1;
        !          1236:                        break;
        !          1237:                case 0:
        !          1238:                        SETHELP(WHERE);
        !          1239: /*
        !          1240: Key word       Symbol          Description
        !          1241: ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
        !          1242: AND              &             More than one requirement (optional)
        !          1243: NOT              !             Logical negation (i.e. NOT EQUAL)
        !          1244: EQUAL            =             Equality required
        !          1245: OR                       |             Either of two or more parameters is required
        !          1246: AGE              $A            User's age (years since birthdate, 0-255)
        !          1247: BPS              $B            User's current connect rate (bps)
        !          1248: FLAG             $F            User's flag (A-Z)
        !          1249: LEVEL            $L            User's level (0-99)
        !          1250: NODE             $N            Current node (1-250)
        !          1251: PCR              $P            User's post/call ratio (0-100)
        !          1252: SEX              $S            User's sex/gender (M or F)
        !          1253: TIME             $T            Time of day (HH:MM, 00:00-23:59)
        !          1254: TLEFT            $R            User's time left online (minutes, 0-255)
        !          1255: TUSED            $O            User's time online this call (minutes, 0-255)
        !          1256: USER             $U            User's number (1-xxxx)
        !          1257: */
        !          1258:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Requirement String",ar,LEN_ARSTR
        !          1259:                 ,K_EDIT|K_UPPER);
        !          1260:                        break;
        !          1261:                case 1:
        !          1262:                        i=1;
        !          1263:                        strcpy(opt[0],"Yes");
        !          1264:                        strcpy(opt[1],"No");
        !          1265:                        opt[2][0]=0;
        !          1266:                        SETHELP(WHERE);
        !          1267: /*
        !          1268: `Clear Requirements:`
        !          1269: 
        !          1270: If you wish to clear the current requirement string, select `Yes`.
        !          1271: Otherwise, select `No`.
        !          1272: */
        !          1273:                        i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Are You Sure",opt);
        !          1274:                        if(!i) {
        !          1275:                                ar[0]=0;
        !          1276:                                uifc.changes=1; }
        !          1277:                        break;
        !          1278:                case 2:
        !          1279:                        if(strlen(ar)>=30) {
        !          1280:                                uifc.msg("Maximum string length reached");
        !          1281:                 break; }
        !          1282:                        i=whichlogic();
        !          1283:                        if(i==-1)
        !          1284:                                break;
        !          1285:                        str[0]=0;
        !          1286:                        SETHELP(WHERE);
        !          1287: /*
        !          1288: `Required Level:`
        !          1289: 
        !          1290: You are being prompted to enter the security level to be used in this
        !          1291: requirement evaluation. The valid range is 0 (zero) through 99.
        !          1292: */
        !          1293:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Level",str,2,K_NUMBER);
        !          1294:                        if(!str[0])
        !          1295:                                break;
        !          1296:                        if(ar[0]) {
        !          1297:                                j=whichcond();
        !          1298:                                if(j==-1)
        !          1299:                                        break;
        !          1300:                                if(!j)
        !          1301:                                        strcat(ar," AND ");
        !          1302:                                else
        !          1303:                                        strcat(ar," OR "); }
        !          1304:                        strcat(ar,"LEVEL ");
        !          1305:                        switch(i) {
        !          1306:                                case 1:
        !          1307:                                        strcat(ar,"= ");
        !          1308:                                        break;
        !          1309:                                case 2:
        !          1310:                                        strcat(ar,"NOT = ");
        !          1311:                                        break;
        !          1312:                                case 3:
        !          1313:                                        strcat(ar,"NOT ");
        !          1314:                                        break; }
        !          1315:                        strcat(ar,str);
        !          1316:                        break;
        !          1317:                case 3:
        !          1318:                        if(strlen(ar)>=30) {
        !          1319:                                uifc.msg("Maximum string length reached");
        !          1320:                 break; }
        !          1321: 
        !          1322:                        for(i=0;i<4;i++)
        !          1323:                                sprintf(opt[i],"Flag Set #%d",i+1);
        !          1324:                        opt[i][0]=0;
        !          1325:                        i=0;
        !          1326:                        i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Select Flag Set",opt);
        !          1327:                        if(i==-1)
        !          1328:                 break;
        !          1329:                        str[0]=0;
        !          1330:                        SETHELP(WHERE);
        !          1331: /*
        !          1332: `Required Flag:`
        !          1333: 
        !          1334: You are being prompted to enter the security flag to be used in this
        !          1335: requirement evaluation. The valid range is A through Z.
        !          1336: */
        !          1337:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Flag (A-Z)",str,1
        !          1338:                                ,K_UPPER|K_ALPHA);
        !          1339:                        if(!str[0])
        !          1340:                                break;
        !          1341:                        if(ar[0]) {
        !          1342:                                j=whichcond();
        !          1343:                                if(j==-1)
        !          1344:                                        break;
        !          1345:                                if(!j)
        !          1346:                                        strcat(ar," AND ");
        !          1347:                                else
        !          1348:                     strcat(ar," OR "); }
        !          1349:                        strcat(ar,"FLAG ");
        !          1350:                        if(i)
        !          1351:                                strcat(ar,ultoa(i+1,tmp,10));
        !          1352:                        strcat(ar,str);
        !          1353:                        break;
        !          1354:                case 4:
        !          1355:                        if(strlen(ar)>=30) {
        !          1356:                                uifc.msg("Maximum string length reached");
        !          1357:                 break; }
        !          1358:                        i=whichlogic();
        !          1359:                        if(i==-1)
        !          1360:                                break;
        !          1361:                        str[0]=0;
        !          1362:                        SETHELP(WHERE);
        !          1363: /*
        !          1364: `Required Age:`
        !          1365: 
        !          1366: You are being prompted to enter the user's age to be used in this
        !          1367: requirement evaluation. The valid range is 0 through 255.
        !          1368: */
        !          1369:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Age",str,3,K_NUMBER);
        !          1370:                        if(!str[0])
        !          1371:                                break;
        !          1372:                        if(ar[0]) {
        !          1373:                                j=whichcond();
        !          1374:                                if(j==-1)
        !          1375:                                        break;
        !          1376:                                if(!j)
        !          1377:                                        strcat(ar," AND ");
        !          1378:                                else
        !          1379:                     strcat(ar," OR "); }
        !          1380:                        strcat(ar,"AGE ");
        !          1381:                        switch(i) {
        !          1382:                                case 1:
        !          1383:                                        strcat(ar,"= ");
        !          1384:                                        break;
        !          1385:                                case 2:
        !          1386:                                        strcat(ar,"NOT = ");
        !          1387:                                        break;
        !          1388:                                case 3:
        !          1389:                                        strcat(ar,"NOT ");
        !          1390:                                        break; }
        !          1391:                        strcat(ar,str);
        !          1392:             break;
        !          1393:                case 5:
        !          1394:                        if(strlen(ar)>=30) {
        !          1395:                                uifc.msg("Maximum string length reached");
        !          1396:                 break; }
        !          1397:                        str[0]=0;
        !          1398:                        SETHELP(WHERE);
        !          1399: /*
        !          1400: `Required Sex:`
        !          1401: 
        !          1402: You are being prompted to enter the user's gender to be used in this
        !          1403: requirement evaluation. The valid values are M or F (for male or
        !          1404: female).
        !          1405: */
        !          1406:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Sex (M or F)",str,1
        !          1407:                                ,K_UPPER|K_ALPHA);
        !          1408:                        if(!str[0])
        !          1409:                                break;
        !          1410:                        if(ar[0]) {
        !          1411:                                j=whichcond();
        !          1412:                                if(j==-1)
        !          1413:                                        break;
        !          1414:                                if(!j)
        !          1415:                                        strcat(ar," AND ");
        !          1416:                                else
        !          1417:                                        strcat(ar," OR "); }
        !          1418:                        strcat(ar,"SEX ");
        !          1419:                        strcat(ar,str);
        !          1420:                        break;
        !          1421:                case 6:
        !          1422:                        if(strlen(ar)>=30) {
        !          1423:                                uifc.msg("Maximum string length reached");
        !          1424:                 break; }
        !          1425:                        i=whichlogic();
        !          1426:                        if(i==-1)
        !          1427:                                break;
        !          1428:                        str[0]=0;
        !          1429:                        SETHELP(WHERE);
        !          1430: /*
        !          1431: `Required Connect Rate (BPS):`
        !          1432: 
        !          1433: You are being prompted to enter the connect rate to be used in this
        !          1434: requirement evaluation. The valid range is 300 through 57600.
        !          1435: */
        !          1436:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Connect Rate (BPS)",str,5,K_NUMBER);
        !          1437:                        if(!str[0])
        !          1438:                                break;
        !          1439:                        j=atoi(str);
        !          1440:                        if(j>=300 && j<30000) {
        !          1441:                                j/=100;
        !          1442:                                sprintf(str,"%d",j); }
        !          1443:                        if(ar[0]) {
        !          1444:                                j=whichcond();
        !          1445:                                if(j==-1)
        !          1446:                                        break;
        !          1447:                                if(!j)
        !          1448:                                        strcat(ar," AND ");
        !          1449:                                else
        !          1450:                     strcat(ar," OR "); }
        !          1451:                        strcat(ar,"BPS ");
        !          1452:                        switch(i) {
        !          1453:                                case 1:
        !          1454:                                        strcat(ar,"= ");
        !          1455:                                        break;
        !          1456:                                case 2:
        !          1457:                                        strcat(ar,"NOT = ");
        !          1458:                                        break;
        !          1459:                                case 3:
        !          1460:                                        strcat(ar,"NOT ");
        !          1461:                                        break; }
        !          1462:                        strcat(ar,str);
        !          1463:             break;
        !          1464:                case 7:
        !          1465:                        if(strlen(ar)>=30) {
        !          1466:                                uifc.msg("Maximum string length reached");
        !          1467:                 break; }
        !          1468:                        i=whichlogic();
        !          1469:                        if(i==-1)
        !          1470:                                break;
        !          1471:                        str[0]=0;
        !          1472:                        SETHELP(WHERE);
        !          1473: /*
        !          1474: `Required Post/Call Ratio:`
        !          1475: 
        !          1476: You are being prompted to enter the post/call ratio to be used in this
        !          1477: requirement evaluation (percentage). The valid range is 0 through 100.
        !          1478: */
        !          1479:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Post/Call Ratio (percentage)"
        !          1480:                                ,str,3,K_NUMBER);
        !          1481:                        if(!str[0])
        !          1482:                                break;
        !          1483:                        if(ar[0]) {
        !          1484:                                j=whichcond();
        !          1485:                                if(j==-1)
        !          1486:                                        break;
        !          1487:                                if(!j)
        !          1488:                                        strcat(ar," AND ");
        !          1489:                                else
        !          1490:                     strcat(ar," OR "); }
        !          1491:                        strcat(ar,"PCR ");
        !          1492:                        switch(i) {
        !          1493:                                case 1:
        !          1494:                                        strcat(ar,"= ");
        !          1495:                                        break;
        !          1496:                                case 2:
        !          1497:                                        strcat(ar,"NOT = ");
        !          1498:                                        break;
        !          1499:                                case 3:
        !          1500:                                        strcat(ar,"NOT ");
        !          1501:                                        break; }
        !          1502:                        strcat(ar,str);
        !          1503:             break;
        !          1504:                case 8:
        !          1505:                        if(strlen(ar)>=30) {
        !          1506:                                uifc.msg("Maximum string length reached");
        !          1507:                 break; }
        !          1508:                        i=whichlogic();
        !          1509:                        if(i==-1)
        !          1510:                                break;
        !          1511:                        str[0]=0;
        !          1512:                        SETHELP(WHERE);
        !          1513: /*
        !          1514: `Required Number of Credits:`
        !          1515: 
        !          1516: You are being prompted to enter the number of credits (in `kilobytes`) to
        !          1517: be used in this requirement evaluation. The valid range is 0 through
        !          1518: 65535.
        !          1519: */
        !          1520:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Required Credits",str,5,K_NUMBER);
        !          1521:                        if(!str[0])
        !          1522:                                break;
        !          1523:                        if(ar[0]) {
        !          1524:                                j=whichcond();
        !          1525:                                if(j==-1)
        !          1526:                                        break;
        !          1527:                                if(!j)
        !          1528:                                        strcat(ar," AND ");
        !          1529:                                else
        !          1530:                     strcat(ar," OR "); }
        !          1531:                        strcat(ar,"CREDIT ");
        !          1532:                        switch(i) {
        !          1533:                                case 1:
        !          1534:                                        strcat(ar,"= ");
        !          1535:                                        break;
        !          1536:                                case 2:
        !          1537:                                        strcat(ar,"NOT = ");
        !          1538:                                        break;
        !          1539:                                case 3:
        !          1540:                                        strcat(ar,"NOT ");
        !          1541:                                        break; }
        !          1542:                        strcat(ar,str);
        !          1543:             break;
        !          1544:                case 9:
        !          1545:                        if(strlen(ar)>=30) {
        !          1546:                                uifc.msg("Maximum string length reached");
        !          1547:                 break; }
        !          1548:                        i=whichlogic();
        !          1549:                        if(i==-1)
        !          1550:                                break;
        !          1551:                        str[0]=0;
        !          1552:                        SETHELP(WHERE);
        !          1553: /*
        !          1554: `Required Upload/Download Byte Ratio:`
        !          1555: 
        !          1556: You are being prompted to enter the upload/download ratio to be used in
        !          1557: this requirement evaluation (percentage). The valid range is 0 through
        !          1558: 100. This ratio is based on the number of `bytes` uploaded by the user
        !          1559: divided by the number of bytes downloaded.
        !          1560: */
        !          1561:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Upload/Download Byte Ratio (percentage)"
        !          1562:                                ,str,3,K_NUMBER);
        !          1563:                        if(!str[0])
        !          1564:                                break;
        !          1565:                        if(ar[0]) {
        !          1566:                                j=whichcond();
        !          1567:                                if(j==-1)
        !          1568:                                        break;
        !          1569:                                if(!j)
        !          1570:                                        strcat(ar," AND ");
        !          1571:                                else
        !          1572:                     strcat(ar," OR "); }
        !          1573:                        strcat(ar,"UDR ");
        !          1574:                        switch(i) {
        !          1575:                                case 1:
        !          1576:                                        strcat(ar,"= ");
        !          1577:                                        break;
        !          1578:                                case 2:
        !          1579:                                        strcat(ar,"NOT = ");
        !          1580:                                        break;
        !          1581:                                case 3:
        !          1582:                                        strcat(ar,"NOT ");
        !          1583:                                        break; }
        !          1584:                        strcat(ar,str);
        !          1585:             break;
        !          1586:                case 10:
        !          1587:                        if(strlen(ar)>=30) {
        !          1588:                                uifc.msg("Maximum string length reached");
        !          1589:                 break; }
        !          1590:                        i=whichlogic();
        !          1591:                        if(i==-1)
        !          1592:                                break;
        !          1593:                        str[0]=0;
        !          1594:                        SETHELP(WHERE);
        !          1595: /*
        !          1596: `Required Upload/Download File Ratio:`
        !          1597: 
        !          1598: You are being prompted to enter the upload/download ratio to be used in
        !          1599: this requirement evaluation (percentage). The valid range is 0 through
        !          1600: 100. This ratio is based on the number of `files` uploaded by the user
        !          1601: divided by the number of files downloaded.
        !          1602: */
        !          1603:                        uifc.input(WIN_MID|WIN_SAV,0,0
        !          1604:                                ,"Upload/Download File Ratio (percentage)"
        !          1605:                                ,str,3,K_NUMBER);
        !          1606:                        if(!str[0])
        !          1607:                                break;
        !          1608:                        if(ar[0]) {
        !          1609:                                j=whichcond();
        !          1610:                                if(j==-1)
        !          1611:                                        break;
        !          1612:                                if(!j)
        !          1613:                                        strcat(ar," AND ");
        !          1614:                                else
        !          1615:                     strcat(ar," OR "); }
        !          1616:                        strcat(ar,"UDFR ");
        !          1617:                        switch(i) {
        !          1618:                                case 1:
        !          1619:                                        strcat(ar,"= ");
        !          1620:                                        break;
        !          1621:                                case 2:
        !          1622:                                        strcat(ar,"NOT = ");
        !          1623:                                        break;
        !          1624:                                case 3:
        !          1625:                                        strcat(ar,"NOT ");
        !          1626:                                        break; }
        !          1627:                        strcat(ar,str);
        !          1628:             break;
        !          1629:                case 11:
        !          1630:                        if(strlen(ar)>=30) {
        !          1631:                                uifc.msg("Maximum string length reached");
        !          1632:                 break; }
        !          1633:                        i=0;
        !          1634:                        strcpy(opt[0],"Before");
        !          1635:                        strcpy(opt[1],"After");
        !          1636:                        opt[2][0]=0;
        !          1637:                        i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Time Relationship",opt);
        !          1638:                        if(i==-1)
        !          1639:                                break;
        !          1640:                        str[0]=0;
        !          1641:                        SETHELP(WHERE);
        !          1642: /*
        !          1643: `Required Time of Day:`
        !          1644: 
        !          1645: You are being prompted to enter the time of day to be used in this
        !          1646: requirement evaluation (24 hour HH:MM format). The valid range is 0
        !          1647: through 23:59.
        !          1648: */
        !          1649:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Time of Day (HH:MM)",str,5,K_UPPER);
        !          1650:                        if(!str[0])
        !          1651:                                break;
        !          1652:                        if(ar[0]) {
        !          1653:                                j=whichcond();
        !          1654:                                if(j==-1)
        !          1655:                                        break;
        !          1656:                                if(!j)
        !          1657:                                        strcat(ar," AND ");
        !          1658:                                else
        !          1659:                     strcat(ar," OR "); }
        !          1660:                        strcat(ar,"TIME ");
        !          1661:                        if(!i)
        !          1662:                                strcat(ar,"NOT ");
        !          1663:                        strcat(ar,str);
        !          1664:                        break;
        !          1665:                case 12:
        !          1666:                        if(strlen(ar)>=30) {
        !          1667:                                uifc.msg("Maximum string length reached");
        !          1668:                 break; }
        !          1669:                        i=whichlogic();
        !          1670:                        if(i==-1)
        !          1671:                                break;
        !          1672:                        SETHELP(WHERE);
        !          1673: /*
        !          1674: `Required Day of Week:`
        !          1675: 
        !          1676: You are being prompted to select a day of the week as an access
        !          1677: requirement value.
        !          1678: */
        !          1679:                        for(n=0;n<7;n++)
        !          1680:                                strcpy(opt[n],wday[n]);
        !          1681:                        opt[n][0]=0;
        !          1682:                        n=0;
        !          1683:                        n=uifc.list(WIN_MID|WIN_SAV,0,0,0,&n,0,"Select Day of Week",opt);
        !          1684:                        if(n==-1)
        !          1685:                 break;
        !          1686:                        strcpy(str,wday[n]);
        !          1687:                        strupr(str);
        !          1688:                        if(ar[0]) {
        !          1689:                                j=whichcond();
        !          1690:                                if(j==-1)
        !          1691:                                        break;
        !          1692:                                if(!j)
        !          1693:                                        strcat(ar," AND ");
        !          1694:                                else
        !          1695:                     strcat(ar," OR "); }
        !          1696:                        strcat(ar,"DAY ");
        !          1697:                        switch(i) {
        !          1698:                                case 1:
        !          1699:                                        strcat(ar,"= ");
        !          1700:                                        break;
        !          1701:                                case 2:
        !          1702:                                        strcat(ar,"NOT = ");
        !          1703:                                        break;
        !          1704:                                case 3:
        !          1705:                                        strcat(ar,"NOT ");
        !          1706:                                        break; }
        !          1707:                        strcat(ar,str);
        !          1708:             break;
        !          1709:                case 13:
        !          1710:                        if(strlen(ar)>=30) {
        !          1711:                                uifc.msg("Maximum string length reached");
        !          1712:                 break; }
        !          1713:                        i=whichlogic();
        !          1714:                        if(i==-1)
        !          1715:                                break;
        !          1716:                        str[0]=0;
        !          1717:                        SETHELP(WHERE);
        !          1718: /*
        !          1719: `Required Node:`
        !          1720: 
        !          1721: You are being prompted to enter the number of a node to be used in this
        !          1722: requirement evaluation. The valid range is 1 through 250.
        !          1723: */
        !          1724:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Node Number",str,3,K_NUMBER);
        !          1725:                        if(!str[0])
        !          1726:                                break;
        !          1727:                        if(ar[0]) {
        !          1728:                                j=whichcond();
        !          1729:                                if(j==-1)
        !          1730:                                        break;
        !          1731:                                if(!j)
        !          1732:                                        strcat(ar," AND ");
        !          1733:                                else
        !          1734:                     strcat(ar," OR "); }
        !          1735:                        strcat(ar,"NODE ");
        !          1736:                        switch(i) {
        !          1737:                                case 1:
        !          1738:                                        strcat(ar,"= ");
        !          1739:                                        break;
        !          1740:                                case 2:
        !          1741:                                        strcat(ar,"NOT = ");
        !          1742:                                        break;
        !          1743:                                case 3:
        !          1744:                                        strcat(ar,"NOT ");
        !          1745:                                        break; }
        !          1746:                        strcat(ar,str);
        !          1747:             break;
        !          1748:                case 14:
        !          1749:                        if(strlen(ar)>=30) {
        !          1750:                                uifc.msg("Maximum string length reached");
        !          1751:                 break; }
        !          1752:                        i=whichlogic();
        !          1753:                        if(i==-1)
        !          1754:                                break;
        !          1755:                        str[0]=0;
        !          1756:                        SETHELP(WHERE);
        !          1757: /*
        !          1758: `Required User Number:`
        !          1759: 
        !          1760: You are being prompted to enter the user's number to be used in this
        !          1761: requirement evaluation.
        !          1762: */
        !          1763:                        uifc.input(WIN_MID|WIN_SAV,0,0,"User Number",str,5,K_NUMBER);
        !          1764:                        if(!str[0])
        !          1765:                                break;
        !          1766:                        if(ar[0]) {
        !          1767:                                j=whichcond();
        !          1768:                                if(j==-1)
        !          1769:                                        break;
        !          1770:                                if(!j)
        !          1771:                                        strcat(ar," AND ");
        !          1772:                                else
        !          1773:                     strcat(ar," OR "); }
        !          1774:                        strcat(ar,"USER ");
        !          1775:                        switch(i) {
        !          1776:                                case 1:
        !          1777:                                        strcat(ar,"= ");
        !          1778:                                        break;
        !          1779:                                case 2:
        !          1780:                                        strcat(ar,"NOT = ");
        !          1781:                                        break;
        !          1782:                                case 3:
        !          1783:                                        strcat(ar,"NOT ");
        !          1784:                                        break; }
        !          1785:                        strcat(ar,str);
        !          1786:             break;
        !          1787: 
        !          1788:                case 15:
        !          1789:                        if(strlen(ar)>=30) {
        !          1790:                                uifc.msg("Maximum string length reached");
        !          1791:                 break; }
        !          1792:                        i=whichlogic();
        !          1793:                        if(i==-1)
        !          1794:                                break;
        !          1795:                        str[0]=0;
        !          1796:                        SETHELP(WHERE);
        !          1797: /*
        !          1798: `Required Time Remaining:`
        !          1799: 
        !          1800: You are being prompted to enter the time remaining to be used in this
        !          1801: requirement evaluation (in `minutes`). The valid range is 0 through 255.
        !          1802: */
        !          1803:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Time Remaining (minutes)"
        !          1804:                                ,str,3,K_NUMBER);
        !          1805:                        if(!str[0])
        !          1806:                                break;
        !          1807:                        if(ar[0]) {
        !          1808:                                j=whichcond();
        !          1809:                                if(j==-1)
        !          1810:                                        break;
        !          1811:                                if(!j)
        !          1812:                                        strcat(ar," AND ");
        !          1813:                                else
        !          1814:                     strcat(ar," OR "); }
        !          1815:                        strcat(ar,"TLEFT ");
        !          1816:                        switch(i) {
        !          1817:                                case 1:
        !          1818:                                        strcat(ar,"= ");
        !          1819:                                        break;
        !          1820:                                case 2:
        !          1821:                                        strcat(ar,"NOT = ");
        !          1822:                                        break;
        !          1823:                                case 3:
        !          1824:                                        strcat(ar,"NOT ");
        !          1825:                                        break; }
        !          1826:                        strcat(ar,str);
        !          1827:                        break;
        !          1828: 
        !          1829:                case 16:
        !          1830:                        if(strlen(ar)>=30) {
        !          1831:                                uifc.msg("Maximum string length reached");
        !          1832:                 break; }
        !          1833:                        i=whichlogic();
        !          1834:                        if(i==-1)
        !          1835:                                break;
        !          1836:                        str[0]=0;
        !          1837:                        SETHELP(WHERE);
        !          1838: /*
        !          1839: `Required Days Till User Account Expiration:`
        !          1840: 
        !          1841: You are being prompted to enter the required number of days till the
        !          1842: user's account will expire.
        !          1843: */
        !          1844:                        uifc.input(WIN_MID|WIN_SAV,0,0,"Days Till Expiration"
        !          1845:                                ,str,5,K_NUMBER);
        !          1846:                        if(!str[0])
        !          1847:                                break;
        !          1848:                        if(ar[0]) {
        !          1849:                                j=whichcond();
        !          1850:                                if(j==-1)
        !          1851:                                        break;
        !          1852:                                if(!j)
        !          1853:                                        strcat(ar," AND ");
        !          1854:                                else
        !          1855:                     strcat(ar," OR "); }
        !          1856:                        strcat(ar,"EXPIRE ");
        !          1857:                        switch(i) {
        !          1858:                                case 1:
        !          1859:                                        strcat(ar,"= ");
        !          1860:                                        break;
        !          1861:                                case 2:
        !          1862:                                        strcat(ar,"NOT = ");
        !          1863:                                        break;
        !          1864:                                case 3:
        !          1865:                                        strcat(ar,"NOT ");
        !          1866:                                        break; }
        !          1867:                        strcat(ar,str);
        !          1868:             break;
        !          1869:                        
        !          1870:                } 
        !          1871:        }
        !          1872:        sprintf(inar,"%.*s",LEN_ARSTR,ar);
        !          1873: }
        !          1874: 
        !          1875: int code_ok(char *str)
        !          1876: {
        !          1877: 
        !          1878:        if(!strlen(str))
        !          1879:                return(0);
        !          1880:        if(strcspn(str," \\/|<>*?+[]:=\";,")!=strlen(str))
        !          1881:                return(0);
        !          1882:        return(1);
        !          1883: }
        !          1884: 
        !          1885: #ifdef __BORLANDC__
        !          1886:        #pragma argsused
        !          1887: #endif
        !          1888: int lprintf(int level, char *fmt, ...)
        !          1889: {
        !          1890:        va_list argptr;
        !          1891:        char sbuf[1024];
        !          1892: 
        !          1893:     va_start(argptr,fmt);
        !          1894:     vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
        !          1895:        sbuf[sizeof(sbuf)-1]=0;
        !          1896:     va_end(argptr);
        !          1897:     strip_ctrl(sbuf,sbuf);
        !          1898:     uifc.msg(sbuf);
        !          1899:     return(0);
        !          1900: }
        !          1901: 
        !          1902: void bail(int code)
        !          1903: {
        !          1904:     if(code) {
        !          1905:                printf("\nHit enter to continue...");
        !          1906:                getchar();
        !          1907:        }
        !          1908:     else if(forcesave) {
        !          1909:         uifc.pop("Loading Configs...");
        !          1910:         read_main_cfg(&cfg,error);
        !          1911:         read_msgs_cfg(&cfg,error);
        !          1912:         read_file_cfg(&cfg,error);
        !          1913:         read_chat_cfg(&cfg,error);
        !          1914:         read_xtrn_cfg(&cfg,error);
        !          1915:         uifc.pop(0);
        !          1916:                cfg.new_install=new_install;
        !          1917:         write_main_cfg(&cfg,backup_level);
        !          1918:         write_msgs_cfg(&cfg,backup_level);
        !          1919:         write_file_cfg(&cfg,backup_level);
        !          1920:         write_chat_cfg(&cfg,backup_level);
        !          1921:         write_xtrn_cfg(&cfg,backup_level); }
        !          1922: 
        !          1923:     uifc.bail();
        !          1924: 
        !          1925:     exit(code);
        !          1926: }
        !          1927: 
        !          1928: /****************************************************************************/
        !          1929: /* Error handling routine. Prints to local and remote screens the error     */
        !          1930: /* information, function, action, object and access and then attempts to    */
        !          1931: /* write the error information into the file ERROR.LOG in the text dir.     */
        !          1932: /****************************************************************************/
        !          1933: void errormsg(int line, char* source,  char* action, char* object, ulong access)
        !          1934: {
        !          1935:        char scrn_buf[MAX_BFLN];
        !          1936:     gettext(1,1,80,uifc.scrn_len,scrn_buf);
        !          1937:     clrscr();
        !          1938:     printf("ERROR -     line: %d\n",line);
        !          1939:     printf("            file: %s\n",source);
        !          1940:     printf("          action: %s\n",action);
        !          1941:     printf("          object: %s\n",object);
        !          1942:     printf("          access: %ld (%lx)\n",access,access);
        !          1943:     printf("\nHit enter to continue...");
        !          1944:     getchar();
        !          1945:     puttext(1,1,80,uifc.scrn_len,scrn_buf);
        !          1946: }
        !          1947: 
        !          1948: /* Prepare a string to be used as an internal code */
        !          1949: /* Return the usable code */
        !          1950: char* prep_code(char *str, const char* prefix)
        !          1951: {
        !          1952:        char tmp[1024];
        !          1953:        int i,j;
        !          1954: 
        !          1955:        if(prefix!=NULL) {      /* skip the grp/lib prefix, if specified */
        !          1956:                i=strlen(prefix);
        !          1957:                if(i && strnicmp(str,prefix,i)==0 && strlen(str)!=i)
        !          1958:                        str+=i;
        !          1959:        }
        !          1960:        for(i=j=0;str[i] && i<sizeof(tmp);i++)
        !          1961:                if(str[i]>' ' && !(str[i]&0x80) && str[i]!='*' && str[i]!='?'
        !          1962:                        && strchr(ILLEGAL_FILENAME_CHARS,str[i])==NULL)
        !          1963:                        tmp[j++]=toupper(str[i]);
        !          1964:        tmp[j]=0;
        !          1965:        strcpy(str,tmp);
        !          1966:        if(j>LEN_CODE) {        /* Extra chars? Strip symbolic chars */
        !          1967:                for(i=j=0;str[i];i++)
        !          1968:                        if(isalnum(str[i]))
        !          1969:                                tmp[j++]=str[i];
        !          1970:                tmp[j]=0;
        !          1971:                strcpy(str,tmp);
        !          1972:        }
        !          1973:        return(str);
        !          1974: }
        !          1975: 
        !          1976: /* End of SCFG.C */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.