--- sbbs/src/sbbs3/scfg/scfg.c 2018/04/24 16:41:24 1.1.1.1 +++ sbbs/src/sbbs3/scfg/scfg.c 2018/04/24 16:44:56 1.1.1.2 @@ -1,1954 +1,1976 @@ -/* scfg.c */ - -/* Synchronet configuration utility */ - -/* $Id: scfg.c,v 1.1.1.1 2018/04/24 16:41:24 root Exp $ */ - -/**************************************************************************** - * @format.tab-size 4 (Plain Text/Source Code File Header) * - * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * - * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * See the GNU General Public License for more details: gpl.txt or * - * http://www.fsf.org/copyleft/gpl.html * - * * - * Anonymous FTP access to the most recent released source is available at * - * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * - * * - * Anonymous CVS access to the development source and modification history * - * is available at cvs.synchro.net:/cvsroot/sbbs, example: * - * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login * - * (just hit return, no password is necessary) * - * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src * - * * - * For Synchronet coding style and modification guidelines, see * - * http://www.synchro.net/source.html * - * * - * You are encouraged to submit any modifications (preferably in Unix diff * - * format) via e-mail to mods@synchro.net * - * * - * Note: If this box doesn't appear square, then you need to fix your tabs. * - ****************************************************************************/ - -#define __COLORS -#include "scfg.h" -#undef BLINK -#include "ciolib.h" - -/********************/ -/* Global Variables */ -/********************/ - -scfg_t cfg; /* Synchronet Configuration */ -uifcapi_t uifc; /* User Interface (UIFC) Library API */ - -BOOL no_dirchk=FALSE,forcesave=FALSE; -BOOL new_install=FALSE; -static BOOL auto_save=FALSE; -extern BOOL all_msghdr; -extern BOOL no_msghdr; -char **opt; -char tmp[256]; -char error[256]; -int backup_level=5; - -char *invalid_code= -"Invalid Internal Code:\n\n" -"Internal codes can be up to eight characters in length and can only\n" -"contain valid DOS filename characters. The code you have entered\n" -"contains one or more invalid characters."; - -char *num_flags= -"Number of Flags Needed:\n\n" -"If you want users to be required to have all the flags, select All.\n" -"\n" -"If you want users to be required to have any one or more of the flags,\n" -"select One (Allowed)."; - - -void allocfail(uint size) -{ - printf("\7Error allocating %u bytes of memory.\r\n",size); - bail(1); -} - -int main(int argc, char **argv) -{ - char **mopt,*p; - char errormsg[MAX_PATH*2]; - int i,j,main_dflt=0,chat_dflt=0; - char str[MAX_PATH+1]; - char exepath[MAX_PATH+1]; - BOOL door_mode=FALSE; - int ciolib_mode=CIOLIB_MODE_AUTO; - - printf("\r\nSynchronet Configuration Utility (%s) v%s Copyright %s " - "Rob Swindell\r\n",PLATFORM_DESC,VERSION,__DATE__+7); - - cfg.size=sizeof(cfg); - - memset(&uifc,0,sizeof(uifc)); - p=getenv("SBBSCTRL"); - if(p!=NULL) - SAFECOPY(cfg.ctrl_dir,p); - else - getcwd(cfg.ctrl_dir,sizeof(cfg.ctrl_dir)); - - uifc.esc_delay=25; - - for(i=1;iname); - opt[i][0]=0; - j=WIN_ORG|WIN_ACT|WIN_CHE; - if(cfg.total_txtsecs) - j|=WIN_DEL|WIN_GET; - if(cfg.total_txtsecsi;j--) - cfg.txtsec[j]=cfg.txtsec[j-1]; - if((cfg.txtsec[i]=(txtsec_t *)malloc(sizeof(txtsec_t)))==NULL) { - errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(txtsec_t)); - continue; } - memset((txtsec_t *)cfg.txtsec[i],0,sizeof(txtsec_t)); - strcpy(cfg.txtsec[i]->name,str); - strcpy(cfg.txtsec[i]->code,code); - cfg.total_txtsecs++; - uifc.changes=1; - continue; } - if((i&MSK_ON)==MSK_DEL) { - i&=MSK_OFF; - free(cfg.txtsec[i]); - cfg.total_txtsecs--; - for(j=i;jname); - sprintf(opt[k++],"%-27.27s%s","Access Requirements" - ,cfg.txtsec[i]->arstr); - sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.txtsec[i]->code); - opt[k][0]=0; - switch(uifc.list(WIN_ACT|WIN_MID,0,0,60,&j,0,cfg.txtsec[i]->name - ,opt)) { - case -1: - done=1; - break; - case 0: - SETHELP(WHERE); -/* -Text Section Name: - -This is the name of this text section. -*/ - strcpy(str,cfg.txtsec[i]->name); /* save */ - if(!uifc.input(WIN_MID|WIN_SAV,0,10 - ,"Text File Section Name" - ,cfg.txtsec[i]->name,sizeof(cfg.txtsec[i]->name)-1,K_EDIT)) - strcpy(cfg.txtsec[i]->name,str); - break; - case 1: - sprintf(str,"%s Text Section",cfg.txtsec[i]->name); - getar(str,cfg.txtsec[i]->arstr); - break; - case 2: - strcpy(str,cfg.txtsec[i]->code); - SETHELP(WHERE); -/* -Text Section Internal Code: - -Every text file section must have its own unique internal code for -Synchronet to reference it by. It is helpful if this code is an -abreviation of the name. -*/ - uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)" - ,str,LEN_CODE,K_EDIT); - if(code_ok(str)) - strcpy(cfg.txtsec[i]->code,str); - else { - uifc.helpbuf=invalid_code; - uifc.msg("Invalid Code"); - uifc.helpbuf=0; } - break; } } } -} - -void shell_cfg() -{ - static int shell_dflt,shell_bar; - char str[81],code[9],done=0,*p; - int j,k; - uint i; - static shell_t savshell; - -while(1) { - for(i=0;iname); - opt[i][0]=0; - j=WIN_ORG|WIN_ACT|WIN_CHE; - if(cfg.total_shells) - j|=WIN_DEL|WIN_GET; - if(cfg.total_shellsi;j--) - cfg.shell[j]=cfg.shell[j-1]; - if((cfg.shell[i]=(shell_t *)malloc(sizeof(shell_t)))==NULL) { - errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(shell_t)); - continue; } - memset((shell_t *)cfg.shell[i],0,sizeof(shell_t)); - strcpy(cfg.shell[i]->name,str); - strcpy(cfg.shell[i]->code,code); - cfg.total_shells++; - uifc.changes=1; - continue; } - if((i&MSK_ON)==MSK_DEL) { - i&=MSK_OFF; - free(cfg.shell[i]); - cfg.total_shells--; - for(j=i;jname); - sprintf(opt[k++],"%-27.27s%s","Access Requirements" - ,cfg.shell[i]->arstr); - sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.shell[i]->code); - opt[k][0]=0; - SETHELP(WHERE); -/* -Command Shell: - -A command shell is a programmed command and menu structure that you or -your users can use to navigate the BBS. For every command shell -configured here, there must be an associated .BIN file in your EXEC -directory for Synchronet to execute. - -Command shell files are created by using the Baja command shell compiler -to turn Baja source code (.SRC) files into binary files (.BIN) for -Synchronet to interpret. See the example .SRC files in the TEXT -directory and the documentation for the Baja compiler for more details. -*/ - switch(uifc.list(WIN_ACT|WIN_MID,0,0,60,&j,0,cfg.shell[i]->name - ,opt)) { - case -1: - done=1; - break; - case 0: - SETHELP(WHERE); -/* -Command Shell Name: - -This is the descriptive name of this command shell. -*/ - strcpy(str,cfg.shell[i]->name); /* save */ - if(!uifc.input(WIN_MID|WIN_SAV,0,10 - ,"Command Shell Name" - ,cfg.shell[i]->name,sizeof(cfg.shell[i]->name)-1,K_EDIT)) - strcpy(cfg.shell[i]->name,str); - break; - case 1: - sprintf(str,"%s Command Shell",cfg.shell[i]->name); - getar(str,cfg.shell[i]->arstr); - break; - case 2: - strcpy(str,cfg.shell[i]->code); - SETHELP(WHERE); -/* -Command Shell Internal Code: - -Every command shell must have its own unique internal code for -Synchronet to reference it by. It is helpful if this code is an -abreviation of the name. - -This code will be the base filename used to load the shell from your -EXEC directory. e.g. A shell with an internal code of MYBBS would -indicate a Baja shell file named MYBBS.BIN in your EXEC directory. -*/ - uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)" - ,str,LEN_CODE,K_EDIT); - if(code_ok(str)) - strcpy(cfg.shell[i]->code,str); - else { - uifc.helpbuf=invalid_code; - uifc.msg("Invalid Code"); - uifc.helpbuf=0; } - break; } } } -} - -int whichlogic(void) -{ - int i; - -i=0; -strcpy(opt[0],"Greater than or Equal"); -strcpy(opt[1],"Equal"); -strcpy(opt[2],"Not Equal"); -strcpy(opt[3],"Less than"); -opt[4][0]=0; -SETHELP(WHERE); -/* -Select Logic for Requirement: - -This menu allows you to choose the type of logic evaluation to use -in determining if the requirement is met. If, for example, the user's -level is being evaluated and you select Greater than or Equal from -this menu and set the required level to 50, the user must have level -50 or higher to meet this requirement. If you selected Equal from -this menu and set the required level to 50, the user must have level -50 exactly. If you select Not equal and level 50, then the user -must have any level BUT 50. And if you select Less than from this -menu and level 50, the user must have a level below 50. -*/ -i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Select Logic",opt); -return(i); -} - -int whichcond(void) -{ - int i; - -i=0; -strcpy(opt[0],"AND (Both/All)"); -strcpy(opt[1],"OR (Either/Any)"); -opt[2][0]=0; -SETHELP(WHERE); -/* -Select Logic for Multiple Requirements: - -If you wish this new parameter to be required along with the other -parameters, select AND to specify that both or all of the -parameter requirments must be met. - -If you wish this new parameter to only be required if the other -parameter requirements aren't met, select OR to specify that either -or any of the parameter requirements must be met. -*/ -i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Multiple Requirement Logic",opt); -return(i); -} - - -void getar(char *desc, char *inar) -{ - static int curar; - char str[128],ar[128]; - int i,j,len,done=0,n; - -strcpy(ar,inar); -while(!done) { - len=strlen(ar); - if(len>=30) { /* Needs to be shortened */ - str[0]=0; - n=strlen(ar); - for(i=0;i=30) { - str[0]=0; - n=strlen(ar); - for(i=0;i=30) { - str[0]=0; - n=strlen(ar); - for(i=0;i=30) { /* change week days to numbers */ - str[0]=0; - n=strlen(ar); - for(i=0;i=30) { /* Shorten parameters */ - str[0]=0; - n=strlen(ar); - for(i=0;i=30) { /* Remove all spaces and &s */ - str[0]=0; - n=strlen(ar); - for(i=0;i=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Level: - -You are being prompted to enter the security level to be used in this -requirement evaluation. The valid range is 0 (zero) through 99. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Level",str,2,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"LEVEL "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 3: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - - for(i=0;i<4;i++) - sprintf(opt[i],"Flag Set #%d",i+1); - opt[i][0]=0; - i=0; - i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Select Flag Set",opt); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Flag: - -You are being prompted to enter the security flag to be used in this -requirement evaluation. The valid range is A through Z. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Flag (A-Z)",str,1 - ,K_UPPER|K_ALPHA); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"FLAG "); - if(i) - strcat(ar,ultoa(i+1,tmp,10)); - strcat(ar,str); - break; - case 4: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Age: - -You are being prompted to enter the user's age to be used in this -requirement evaluation. The valid range is 0 through 255. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Age",str,3,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"AGE "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 5: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - str[0]=0; - SETHELP(WHERE); -/* -Required Sex: - -You are being prompted to enter the user's gender to be used in this -requirement evaluation. The valid values are M or F (for male or -female). -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Sex (M or F)",str,1 - ,K_UPPER|K_ALPHA); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"SEX "); - strcat(ar,str); - break; - case 6: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Connect Rate (BPS): - -You are being prompted to enter the connect rate to be used in this -requirement evaluation. The valid range is 300 through 57600. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Connect Rate (BPS)",str,5,K_NUMBER); - if(!str[0]) - break; - j=atoi(str); - if(j>=300 && j<30000) { - j/=100; - sprintf(str,"%d",j); } - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"BPS "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 7: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Post/Call Ratio: - -You are being prompted to enter the post/call ratio to be used in this -requirement evaluation (percentage). The valid range is 0 through 100. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Post/Call Ratio (percentage)" - ,str,3,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"PCR "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 8: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Number of Credits: - -You are being prompted to enter the number of credits (in kilobytes) to -be used in this requirement evaluation. The valid range is 0 through -65535. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Required Credits",str,5,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"CREDIT "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 9: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Upload/Download Byte Ratio: - -You are being prompted to enter the upload/download ratio to be used in -this requirement evaluation (percentage). The valid range is 0 through -100. This ratio is based on the number of bytes uploaded by the user -divided by the number of bytes downloaded. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Upload/Download Byte Ratio (percentage)" - ,str,3,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"UDR "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 10: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Upload/Download File Ratio: - -You are being prompted to enter the upload/download ratio to be used in -this requirement evaluation (percentage). The valid range is 0 through -100. This ratio is based on the number of files uploaded by the user -divided by the number of files downloaded. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0 - ,"Upload/Download File Ratio (percentage)" - ,str,3,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"UDFR "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 11: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=0; - strcpy(opt[0],"Before"); - strcpy(opt[1],"After"); - opt[2][0]=0; - i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Time Relationship",opt); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Time of Day: - -You are being prompted to enter the time of day to be used in this -requirement evaluation (24 hour HH:MM format). The valid range is 0 -through 23:59. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Time of Day (HH:MM)",str,5,K_UPPER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"TIME "); - if(!i) - strcat(ar,"NOT "); - strcat(ar,str); - break; - case 12: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - SETHELP(WHERE); -/* -Required Day of Week: - -You are being prompted to select a day of the week as an access -requirement value. -*/ - for(n=0;n<7;n++) - strcpy(opt[n],wday[n]); - opt[n][0]=0; - n=0; - n=uifc.list(WIN_MID|WIN_SAV,0,0,0,&n,0,"Select Day of Week",opt); - if(n==-1) - break; - strcpy(str,wday[n]); - strupr(str); - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"DAY "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 13: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Node: - -You are being prompted to enter the number of a node to be used in this -requirement evaluation. The valid range is 1 through 250. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Node Number",str,3,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"NODE "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - case 14: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required User Number: - -You are being prompted to enter the user's number to be used in this -requirement evaluation. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"User Number",str,5,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"USER "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - - case 15: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Time Remaining: - -You are being prompted to enter the time remaining to be used in this -requirement evaluation (in minutes). The valid range is 0 through 255. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Time Remaining (minutes)" - ,str,3,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"TLEFT "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - - case 16: - if(strlen(ar)>=30) { - uifc.msg("Maximum string length reached"); - break; } - i=whichlogic(); - if(i==-1) - break; - str[0]=0; - SETHELP(WHERE); -/* -Required Days Till User Account Expiration: - -You are being prompted to enter the required number of days till the -user's account will expire. -*/ - uifc.input(WIN_MID|WIN_SAV,0,0,"Days Till Expiration" - ,str,5,K_NUMBER); - if(!str[0]) - break; - if(ar[0]) { - j=whichcond(); - if(j==-1) - break; - if(!j) - strcat(ar," AND "); - else - strcat(ar," OR "); } - strcat(ar,"EXPIRE "); - switch(i) { - case 1: - strcat(ar,"= "); - break; - case 2: - strcat(ar,"NOT = "); - break; - case 3: - strcat(ar,"NOT "); - break; } - strcat(ar,str); - break; - } } -sprintf(inar,"%.*s",LEN_ARSTR,ar); -} - -int code_ok(char *str) -{ - - if(!strlen(str)) - return(0); - if(strcspn(str," \\/|<>*?+[]:=\";,")!=strlen(str)) - return(0); - return(1); -} - -#ifdef __BORLANDC__ - #pragma argsused -#endif -int lprintf(int level, char *fmt, ...) -{ - va_list argptr; - char sbuf[1024]; - - va_start(argptr,fmt); - vsnprintf(sbuf,sizeof(sbuf),fmt,argptr); - sbuf[sizeof(sbuf)-1]=0; - va_end(argptr); - strip_ctrl(sbuf); - uifc.msg(sbuf); - return(0); -} - -void bail(int code) -{ - if(code) { - printf("\nHit enter to continue..."); - getchar(); - } - else if(forcesave) { - uifc.pop("Loading Configs..."); - read_main_cfg(&cfg,error); - read_msgs_cfg(&cfg,error); - read_file_cfg(&cfg,error); - read_chat_cfg(&cfg,error); - read_xtrn_cfg(&cfg,error); - uifc.pop(0); - cfg.new_install=new_install; - write_main_cfg(&cfg,backup_level); - write_msgs_cfg(&cfg,backup_level); - write_file_cfg(&cfg,backup_level); - write_chat_cfg(&cfg,backup_level); - write_xtrn_cfg(&cfg,backup_level); } - - uifc.bail(); - - exit(code); -} - -/****************************************************************************/ -/* Error handling routine. Prints to local and remote screens the error */ -/* information, function, action, object and access and then attempts to */ -/* write the error information into the file ERROR.LOG in the text dir. */ -/****************************************************************************/ -void errormsg(int line, char* source, char* action, char* object, ulong access) -{ - char scrn_buf[MAX_BFLN]; - gettext(1,1,80,uifc.scrn_len,scrn_buf); - clrscr(); - printf("ERROR - line: %d\n",line); - printf(" file: %s\n",source); - printf(" action: %s\n",action); - printf(" object: %s\n",object); - printf(" access: %ld (%lx)\n",access,access); - printf("\nHit enter to continue..."); - getchar(); - puttext(1,1,80,uifc.scrn_len,scrn_buf); -} - -/* Prepare a string to be used as an internal code */ -char* prep_code(char *str) -{ - char tmp[1024]; - int i,j; - - for(i=j=0;str[i] && i' ' && !(str[i]&0x80) && str[i]!='*' && str[i]!='?' - && strchr(ILLEGAL_FILENAME_CHARS,str[i])==NULL) - tmp[j++]=str[i]; - tmp[j]=0; - strcpy(str,tmp); - if(j>LEN_CODE) { /* Extra chars? Strip symbolic chars */ - for(i=j=0;str[i];i++) - if(isalnum(str[i])) - tmp[j++]=str[i]; - tmp[j]=0; - strcpy(str,tmp); - } - return(str); -} - -/* End of SCFG.C */ +/* scfg.c */ + +/* Synchronet configuration utility */ + +/* $Id: scfg.c,v 1.1.1.2 2018/04/24 16:44:56 root Exp $ */ + +/**************************************************************************** + * @format.tab-size 4 (Plain Text/Source Code File Header) * + * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * + * * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * See the GNU General Public License for more details: gpl.txt or * + * http://www.fsf.org/copyleft/gpl.html * + * * + * Anonymous FTP access to the most recent released source is available at * + * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * + * * + * Anonymous CVS access to the development source and modification history * + * is available at cvs.synchro.net:/cvsroot/sbbs, example: * + * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login * + * (just hit return, no password is necessary) * + * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src * + * * + * For Synchronet coding style and modification guidelines, see * + * http://www.synchro.net/source.html * + * * + * You are encouraged to submit any modifications (preferably in Unix diff * + * format) via e-mail to mods@synchro.net * + * * + * Note: If this box doesn't appear square, then you need to fix your tabs. * + ****************************************************************************/ + +#define __COLORS +#include "scfg.h" +#undef BLINK +#include "ciolib.h" + +/********************/ +/* Global Variables */ +/********************/ + +scfg_t cfg; /* Synchronet Configuration */ +uifcapi_t uifc; /* User Interface (UIFC) Library API */ + +BOOL no_dirchk=FALSE,forcesave=FALSE; +BOOL new_install=FALSE; +static BOOL auto_save=FALSE; +extern BOOL all_msghdr; +extern BOOL no_msghdr; +char **opt; +char tmp[256]; +char error[256]; +int backup_level=5; + +char *invalid_code= + "`Invalid Internal Code:`\n\n" + "Internal codes can be up to eight characters in length and can only\n" + "contain valid DOS filename characters. The code you have entered\n" + "contains one or more invalid characters."; + +char *num_flags= + "`Number of Flags Needed:`\n\n" + "If you want users to be required to have all the flags, select `All`.\n" + "\n" + "If you want users to be required to have any one or more of the flags,\n" + "select `One` (Allowed)."; + + +void allocfail(uint size) +{ + printf("\7Error allocating %u bytes of memory.\r\n",size); + bail(1); +} + +int main(int argc, char **argv) +{ + char **mopt,*p; + char errormsg[MAX_PATH*2]; + int i,j,main_dflt=0,chat_dflt=0; + char str[MAX_PATH+1]; + char exepath[MAX_PATH+1]; + BOOL door_mode=FALSE; + int ciolib_mode=CIOLIB_MODE_AUTO; + + printf("\r\nSynchronet Configuration Utility (%s) v%s Copyright %s " + "Rob Swindell\r\n",PLATFORM_DESC,VERSION,__DATE__+7); + + cfg.size=sizeof(cfg); + + memset(&uifc,0,sizeof(uifc)); + p=getenv("SBBSCTRL"); + if(p!=NULL) + SAFECOPY(cfg.ctrl_dir,p); + else + getcwd(cfg.ctrl_dir,sizeof(cfg.ctrl_dir)); + + uifc.esc_delay=25; + + for(i=1;iname); + opt[i][0]=0; + j=WIN_ORG|WIN_ACT|WIN_CHE; + if(cfg.total_txtsecs) + j|=WIN_DEL|WIN_GET; + if(cfg.total_txtsecsi;j--) + cfg.txtsec[j]=cfg.txtsec[j-1]; + if((cfg.txtsec[i]=(txtsec_t *)malloc(sizeof(txtsec_t)))==NULL) { + errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(txtsec_t)); + continue; } + memset((txtsec_t *)cfg.txtsec[i],0,sizeof(txtsec_t)); + strcpy(cfg.txtsec[i]->name,str); + strcpy(cfg.txtsec[i]->code,code); + cfg.total_txtsecs++; + uifc.changes=1; + continue; } + if((i&MSK_ON)==MSK_DEL) { + i&=MSK_OFF; + free(cfg.txtsec[i]); + cfg.total_txtsecs--; + for(j=i;jname); + sprintf(opt[k++],"%-27.27s%s","Access Requirements" + ,cfg.txtsec[i]->arstr); + sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.txtsec[i]->code); + opt[k][0]=0; + switch(uifc.list(WIN_ACT|WIN_MID,0,0,60,&j,0,cfg.txtsec[i]->name + ,opt)) { + case -1: + done=1; + break; + case 0: + SETHELP(WHERE); +/* +`Text Section Name:` + +This is the name of this text section. +*/ + strcpy(str,cfg.txtsec[i]->name); /* save */ + if(!uifc.input(WIN_MID|WIN_SAV,0,10 + ,"Text File Section Name" + ,cfg.txtsec[i]->name,sizeof(cfg.txtsec[i]->name)-1,K_EDIT)) + strcpy(cfg.txtsec[i]->name,str); + break; + case 1: + sprintf(str,"%s Text Section",cfg.txtsec[i]->name); + getar(str,cfg.txtsec[i]->arstr); + break; + case 2: + strcpy(str,cfg.txtsec[i]->code); + SETHELP(WHERE); +/* +`Text Section Internal Code:` + +Every text file section must have its own unique internal code for +Synchronet to reference it by. It is helpful if this code is an +abreviation of the name. +*/ + uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)" + ,str,LEN_CODE,K_EDIT); + if(code_ok(str)) + strcpy(cfg.txtsec[i]->code,str); + else { + uifc.helpbuf=invalid_code; + uifc.msg("Invalid Code"); + uifc.helpbuf=0; } + break; + } + } + } +} + +void shell_cfg() +{ + static int shell_dflt,shell_bar; + char str[81],code[9],done=0,*p; + int j,k; + uint i; + static shell_t savshell; + + while(1) { + for(i=0;iname); + opt[i][0]=0; + j=WIN_ORG|WIN_ACT|WIN_CHE; + if(cfg.total_shells) + j|=WIN_DEL|WIN_GET; + if(cfg.total_shellsi;j--) + cfg.shell[j]=cfg.shell[j-1]; + if((cfg.shell[i]=(shell_t *)malloc(sizeof(shell_t)))==NULL) { + errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(shell_t)); + continue; } + memset((shell_t *)cfg.shell[i],0,sizeof(shell_t)); + strcpy(cfg.shell[i]->name,str); + strcpy(cfg.shell[i]->code,code); + cfg.total_shells++; + uifc.changes=1; + continue; } + if((i&MSK_ON)==MSK_DEL) { + i&=MSK_OFF; + free(cfg.shell[i]); + cfg.total_shells--; + for(j=i;jname); + sprintf(opt[k++],"%-27.27s%s","Access Requirements" + ,cfg.shell[i]->arstr); + sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.shell[i]->code); + opt[k][0]=0; + SETHELP(WHERE); +/* +`Command Shell:` + +A command shell is a programmed command and menu structure that you or +your users can use to navigate the BBS. For every command shell +configured here, there must be an associated .BIN file in your EXEC +directory for Synchronet to execute. + +Command shell files are created by using the Baja command shell compiler +to turn Baja source code (.SRC) files into binary files (.BIN) for +Synchronet to interpret. See the example .SRC files in the TEXT +directory and the documentation for the Baja compiler for more details. +*/ + switch(uifc.list(WIN_ACT|WIN_MID,0,0,60,&j,0,cfg.shell[i]->name + ,opt)) { + case -1: + done=1; + break; + case 0: + SETHELP(WHERE); +/* +`Command Shell Name:` + +This is the descriptive name of this command shell. +*/ + strcpy(str,cfg.shell[i]->name); /* save */ + if(!uifc.input(WIN_MID|WIN_SAV,0,10 + ,"Command Shell Name" + ,cfg.shell[i]->name,sizeof(cfg.shell[i]->name)-1,K_EDIT)) + strcpy(cfg.shell[i]->name,str); + break; + case 1: + sprintf(str,"%s Command Shell",cfg.shell[i]->name); + getar(str,cfg.shell[i]->arstr); + break; + case 2: + strcpy(str,cfg.shell[i]->code); + SETHELP(WHERE); +/* +`Command Shell Internal Code:` + +Every command shell must have its own unique internal code for +Synchronet to reference it by. It is helpful if this code is an +abreviation of the name. + +This code will be the base filename used to load the shell from your +EXEC directory. e.g. A shell with an internal code of `MYBBS` would +indicate a Baja shell file named `MYBBS.BIN` in your EXEC directory. +*/ + uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)" + ,str,LEN_CODE,K_EDIT); + if(code_ok(str)) + strcpy(cfg.shell[i]->code,str); + else { + uifc.helpbuf=invalid_code; + uifc.msg("Invalid Code"); + uifc.helpbuf=0; } + break; + } + } + } +} + +int whichlogic(void) +{ + int i; + + i=0; + strcpy(opt[0],"Greater than or Equal"); + strcpy(opt[1],"Equal"); + strcpy(opt[2],"Not Equal"); + strcpy(opt[3],"Less than"); + opt[4][0]=0; + SETHELP(WHERE); +/* +`Select Logic for Requirement:` + +This menu allows you to choose the type of logic evaluation to use +in determining if the requirement is met. If, for example, the user's +level is being evaluated and you select `Greater than or Equal` from +this menu and set the required level to `50`, the user must have level +`50 or higher` to meet this requirement. If you selected `Equal` from +this menu and set the required level to `50`, the user must have level +`50 exactly`. If you select `Not equal` and level `50`, then the user +must have `any level BUT 50`. And if you select `Less than` from this +menu and level `50`, the user must have a level `below 50`. +*/ + i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Select Logic",opt); + return(i); +} + +int whichcond(void) +{ + int i; + + i=0; + strcpy(opt[0],"AND (Both/All)"); + strcpy(opt[1],"OR (Either/Any)"); + opt[2][0]=0; + SETHELP(WHERE); +/* +`Select Logic for Multiple Requirements:` + +If you wish this new parameter to be required along with the other +parameters, select `AND` to specify that `both` or `all` of the +parameter requirments must be met. + +If you wish this new parameter to only be required if the other +parameter requirements aren't met, select `OR` to specify that `either` +or `any` of the parameter requirements must be met. +*/ + i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Multiple Requirement Logic",opt); + return(i); +} + + +void getar(char *desc, char *inar) +{ + static int curar; + char str[128],ar[128]; + int i,j,len,done=0,n; + + strcpy(ar,inar); + while(!done) { + len=strlen(ar); + if(len>=30) { /* Needs to be shortened */ + str[0]=0; + n=strlen(ar); + for(i=0;i=30) { + str[0]=0; + n=strlen(ar); + for(i=0;i=30) { + str[0]=0; + n=strlen(ar); + for(i=0;i=30) { /* change week days to numbers */ + str[0]=0; + n=strlen(ar); + for(i=0;i=30) { /* Shorten parameters */ + str[0]=0; + n=strlen(ar); + for(i=0;i=30) { /* Remove all spaces and &s */ + str[0]=0; + n=strlen(ar); + for(i=0;i=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Level:` + +You are being prompted to enter the security level to be used in this +requirement evaluation. The valid range is 0 (zero) through 99. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Level",str,2,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"LEVEL "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 3: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + + for(i=0;i<4;i++) + sprintf(opt[i],"Flag Set #%d",i+1); + opt[i][0]=0; + i=0; + i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Select Flag Set",opt); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Flag:` + +You are being prompted to enter the security flag to be used in this +requirement evaluation. The valid range is A through Z. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Flag (A-Z)",str,1 + ,K_UPPER|K_ALPHA); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"FLAG "); + if(i) + strcat(ar,ultoa(i+1,tmp,10)); + strcat(ar,str); + break; + case 4: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Age:` + +You are being prompted to enter the user's age to be used in this +requirement evaluation. The valid range is 0 through 255. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Age",str,3,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"AGE "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 5: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + str[0]=0; + SETHELP(WHERE); +/* +`Required Sex:` + +You are being prompted to enter the user's gender to be used in this +requirement evaluation. The valid values are M or F (for male or +female). +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Sex (M or F)",str,1 + ,K_UPPER|K_ALPHA); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"SEX "); + strcat(ar,str); + break; + case 6: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Connect Rate (BPS):` + +You are being prompted to enter the connect rate to be used in this +requirement evaluation. The valid range is 300 through 57600. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Connect Rate (BPS)",str,5,K_NUMBER); + if(!str[0]) + break; + j=atoi(str); + if(j>=300 && j<30000) { + j/=100; + sprintf(str,"%d",j); } + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"BPS "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 7: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Post/Call Ratio:` + +You are being prompted to enter the post/call ratio to be used in this +requirement evaluation (percentage). The valid range is 0 through 100. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Post/Call Ratio (percentage)" + ,str,3,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"PCR "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 8: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Number of Credits:` + +You are being prompted to enter the number of credits (in `kilobytes`) to +be used in this requirement evaluation. The valid range is 0 through +65535. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Required Credits",str,5,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"CREDIT "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 9: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Upload/Download Byte Ratio:` + +You are being prompted to enter the upload/download ratio to be used in +this requirement evaluation (percentage). The valid range is 0 through +100. This ratio is based on the number of `bytes` uploaded by the user +divided by the number of bytes downloaded. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Upload/Download Byte Ratio (percentage)" + ,str,3,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"UDR "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 10: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Upload/Download File Ratio:` + +You are being prompted to enter the upload/download ratio to be used in +this requirement evaluation (percentage). The valid range is 0 through +100. This ratio is based on the number of `files` uploaded by the user +divided by the number of files downloaded. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0 + ,"Upload/Download File Ratio (percentage)" + ,str,3,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"UDFR "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 11: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=0; + strcpy(opt[0],"Before"); + strcpy(opt[1],"After"); + opt[2][0]=0; + i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Time Relationship",opt); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Time of Day:` + +You are being prompted to enter the time of day to be used in this +requirement evaluation (24 hour HH:MM format). The valid range is 0 +through 23:59. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Time of Day (HH:MM)",str,5,K_UPPER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"TIME "); + if(!i) + strcat(ar,"NOT "); + strcat(ar,str); + break; + case 12: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + SETHELP(WHERE); +/* +`Required Day of Week:` + +You are being prompted to select a day of the week as an access +requirement value. +*/ + for(n=0;n<7;n++) + strcpy(opt[n],wday[n]); + opt[n][0]=0; + n=0; + n=uifc.list(WIN_MID|WIN_SAV,0,0,0,&n,0,"Select Day of Week",opt); + if(n==-1) + break; + strcpy(str,wday[n]); + strupr(str); + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"DAY "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 13: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Node:` + +You are being prompted to enter the number of a node to be used in this +requirement evaluation. The valid range is 1 through 250. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Node Number",str,3,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"NODE "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + case 14: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required User Number:` + +You are being prompted to enter the user's number to be used in this +requirement evaluation. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"User Number",str,5,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"USER "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + + case 15: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Time Remaining:` + +You are being prompted to enter the time remaining to be used in this +requirement evaluation (in `minutes`). The valid range is 0 through 255. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Time Remaining (minutes)" + ,str,3,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"TLEFT "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + + case 16: + if(strlen(ar)>=30) { + uifc.msg("Maximum string length reached"); + break; } + i=whichlogic(); + if(i==-1) + break; + str[0]=0; + SETHELP(WHERE); +/* +`Required Days Till User Account Expiration:` + +You are being prompted to enter the required number of days till the +user's account will expire. +*/ + uifc.input(WIN_MID|WIN_SAV,0,0,"Days Till Expiration" + ,str,5,K_NUMBER); + if(!str[0]) + break; + if(ar[0]) { + j=whichcond(); + if(j==-1) + break; + if(!j) + strcat(ar," AND "); + else + strcat(ar," OR "); } + strcat(ar,"EXPIRE "); + switch(i) { + case 1: + strcat(ar,"= "); + break; + case 2: + strcat(ar,"NOT = "); + break; + case 3: + strcat(ar,"NOT "); + break; } + strcat(ar,str); + break; + + } + } + sprintf(inar,"%.*s",LEN_ARSTR,ar); +} + +int code_ok(char *str) +{ + + if(!strlen(str)) + return(0); + if(strcspn(str," \\/|<>*?+[]:=\";,")!=strlen(str)) + return(0); + return(1); +} + +#ifdef __BORLANDC__ + #pragma argsused +#endif +int lprintf(int level, char *fmt, ...) +{ + va_list argptr; + char sbuf[1024]; + + va_start(argptr,fmt); + vsnprintf(sbuf,sizeof(sbuf),fmt,argptr); + sbuf[sizeof(sbuf)-1]=0; + va_end(argptr); + strip_ctrl(sbuf,sbuf); + uifc.msg(sbuf); + return(0); +} + +void bail(int code) +{ + if(code) { + printf("\nHit enter to continue..."); + getchar(); + } + else if(forcesave) { + uifc.pop("Loading Configs..."); + read_main_cfg(&cfg,error); + read_msgs_cfg(&cfg,error); + read_file_cfg(&cfg,error); + read_chat_cfg(&cfg,error); + read_xtrn_cfg(&cfg,error); + uifc.pop(0); + cfg.new_install=new_install; + write_main_cfg(&cfg,backup_level); + write_msgs_cfg(&cfg,backup_level); + write_file_cfg(&cfg,backup_level); + write_chat_cfg(&cfg,backup_level); + write_xtrn_cfg(&cfg,backup_level); } + + uifc.bail(); + + exit(code); +} + +/****************************************************************************/ +/* Error handling routine. Prints to local and remote screens the error */ +/* information, function, action, object and access and then attempts to */ +/* write the error information into the file ERROR.LOG in the text dir. */ +/****************************************************************************/ +void errormsg(int line, char* source, char* action, char* object, ulong access) +{ + char scrn_buf[MAX_BFLN]; + gettext(1,1,80,uifc.scrn_len,scrn_buf); + clrscr(); + printf("ERROR - line: %d\n",line); + printf(" file: %s\n",source); + printf(" action: %s\n",action); + printf(" object: %s\n",object); + printf(" access: %ld (%lx)\n",access,access); + printf("\nHit enter to continue..."); + getchar(); + puttext(1,1,80,uifc.scrn_len,scrn_buf); +} + +/* Prepare a string to be used as an internal code */ +/* Return the usable code */ +char* prep_code(char *str, const char* prefix) +{ + char tmp[1024]; + int i,j; + + if(prefix!=NULL) { /* skip the grp/lib prefix, if specified */ + i=strlen(prefix); + if(i && strnicmp(str,prefix,i)==0 && strlen(str)!=i) + str+=i; + } + for(i=j=0;str[i] && i' ' && !(str[i]&0x80) && str[i]!='*' && str[i]!='?' + && strchr(ILLEGAL_FILENAME_CHARS,str[i])==NULL) + tmp[j++]=toupper(str[i]); + tmp[j]=0; + strcpy(str,tmp); + if(j>LEN_CODE) { /* Extra chars? Strip symbolic chars */ + for(i=j=0;str[i];i++) + if(isalnum(str[i])) + tmp[j++]=str[i]; + tmp[j]=0; + strcpy(str,tmp); + } + return(str); +} + +/* End of SCFG.C */