|
|
1.1 ! root 1: /* scfglib1.c */ ! 2: ! 3: /* Synchronet configuration library routines */ ! 4: ! 5: /* $Id: scfglib1.c,v 1.14 2000/12/05 03:37: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 2000 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: #include "sbbs.h" ! 39: #include "scfglib.h" ! 40: ! 41: const char *scfgnulstr=""; ! 42: ! 43: void prep_dir(char* base, char* path) ! 44: { ! 45: #ifdef __unix__ ! 46: char *p; ! 47: #endif ! 48: char str[LEN_DIR*2]; ! 49: ! 50: if(!path[0]) ! 51: return; ! 52: if(path[0]!='\\' && path[0]!='/' && path[1]!=':') /* Relative to NODE directory */ ! 53: sprintf(str,"%s%s",base,path); ! 54: else ! 55: strcpy(str,path); ! 56: ! 57: #ifdef __unix__ /* Change backslashes to forward slashes on Unix */ ! 58: for(p=str;*p;p++) ! 59: if(*p=='\\') ! 60: *p='/'; ! 61: strlwr(str); /* temporary hack */ ! 62: #endif ! 63: ! 64: backslashcolon(str); ! 65: strcat(str,"."); // Change C: to C:. and C:\SBBS\ to C:\SBBS\. ! 66: _fullpath(path,str,LEN_DIR+1); // Change C:\SBBS\NODE1\..\EXEC to C:\SBBS\EXEC ! 67: backslash(path); ! 68: } ! 69: ! 70: void prep_path(char* path) ! 71: { ! 72: #ifdef __unix__ /* Change backslashes to forward slashes on Unix */ ! 73: char *p; ! 74: ! 75: for(p=path;*p;p++) ! 76: if(*p=='\\') ! 77: *p='/'; ! 78: #endif ! 79: } ! 80: ! 81: char * get_alloc(long *offset, char *outstr, int maxlen, FILE *instream) ! 82: { ! 83: ! 84: #ifdef SCFG ! 85: fread(outstr,1,maxlen+1,instream); ! 86: (*offset)+=maxlen+1; ! 87: #else ! 88: char str[257]; ! 89: ! 90: fread(str,1,maxlen+1,instream); ! 91: // lprintf("%s %d %p\r\n",__FILE__,__LINE__,offset); ! 92: (*offset)+=maxlen+1; // this line was commented out (04/12/97) why? ! 93: if(!str[0]) /* Save memory */ ! 94: return((char *)scfgnulstr); ! 95: if((outstr=(char *)MALLOC(strlen(str)+1))==NULL) ! 96: return(NULL); ! 97: strcpy(outstr,str); ! 98: #endif ! 99: ! 100: return(outstr); ! 101: } ! 102: ! 103: #ifdef SCFG /* SCFG allocate max length */ ! 104: #define readline_alloc(l,s,m,i) readline(l,s,m,i) ! 105: #else ! 106: char *readline_alloc(long *offset, char *outstr, int maxline ! 107: , FILE *instream); ! 108: #define readline_alloc(l,s,m,i) s=readline_alloc(l,s,m,i) ! 109: #define get_alloc(o,s,l,i) s=get_alloc(o,s,l,i) ! 110: #endif ! 111: ! 112: /***********************************************************/ ! 113: /* These functions are called from here and must be linked */ ! 114: /***********************************************************/ ! 115: /*** ! 116: nopen() ! 117: truncsp() ! 118: ***/ ! 119: ! 120: BOOL allocerr(read_cfg_text_t* txt, long offset, char *fname, uint size) ! 121: { ! 122: lprintf(txt->error,offset,fname); ! 123: lprintf(txt->allocerr,size); ! 124: return(FALSE); ! 125: } ! 126: ! 127: #ifndef NO_NODE_CFG ! 128: ! 129: /****************************************************************************/ ! 130: /* Reads in NODE.CNF and initializes the associated variables */ ! 131: /****************************************************************************/ ! 132: BOOL read_node_cfg(scfg_t* cfg, read_cfg_text_t* txt) ! 133: { ! 134: char c,str[256],fname[13]; ! 135: int i; ! 136: short n; ! 137: long offset=0; ! 138: FILE *instream; ! 139: ! 140: strcpy(fname,"node.cnf"); ! 141: sprintf(str,"%s%s",cfg->node_dir,fname); ! 142: if((instream=fnopen(NULL,str,O_RDONLY))==NULL) { ! 143: lprintf(txt->openerr,str); ! 144: return(FALSE); ! 145: } ! 146: ! 147: if(txt->reading && txt->reading[0]) ! 148: lprintf(txt->reading,fname); ! 149: get_int(cfg->node_num,instream); ! 150: if(!cfg->node_num) { ! 151: lprintf(txt->error,offset,fname); ! 152: lprintf("Node number must be non-zero."); ! 153: return(FALSE); } ! 154: get_str(cfg->node_name,instream); ! 155: get_str(cfg->node_phone,instream); ! 156: get_str(cfg->node_comspec,instream); ! 157: #ifdef __OS2__ ! 158: if(!node_comspec[0]) ! 159: strcpy(node_comspec,"C:\\OS2\\MDOS\\COMMAND.COM"); ! 160: #endif ! 161: get_int(cfg->node_misc,instream); ! 162: get_int(cfg->node_ivt,instream); ! 163: get_int(cfg->node_swap,instream); ! 164: get_str(cfg->node_swapdir,instream); ! 165: get_int(cfg->node_valuser,instream); ! 166: get_int(cfg->node_minbps,instream); ! 167: #ifdef SCFG ! 168: get_str(cfg->node_ar,instream); ! 169: #else ! 170: fread(str,1,LEN_ARSTR+1,instream); ! 171: offset+=LEN_ARSTR+1; ! 172: cfg->node_ar=arstr(0, str, cfg); ! 173: #endif ! 174: get_int(cfg->node_dollars_per_call,instream); ! 175: get_str(cfg->node_editor,instream); ! 176: get_str(cfg->node_viewer,instream); ! 177: get_str(cfg->node_daily,instream); ! 178: get_int(c,instream); ! 179: if(c) cfg->node_scrnlen=c; ! 180: get_int(cfg->node_scrnblank,instream); ! 181: get_str(cfg->text_dir,instream); /* ctrl directory */ ! 182: get_str(cfg->text_dir,instream); /* text directory */ ! 183: get_str(cfg->temp_dir,instream); /* temp directory */ ! 184: if(!cfg->temp_dir[0]) ! 185: strcpy(cfg->temp_dir,"temp"); ! 186: ! 187: strlwr(cfg->text_dir); /* temporary Unix-compatibility hack */ ! 188: strlwr(cfg->temp_dir); /* temporary Unix-compatibility hack */ ! 189: ! 190: #ifndef SCFG ! 191: prep_dir(cfg->ctrl_dir, cfg->text_dir); ! 192: #endif ! 193: ! 194: for(i=0;i<10;i++) { /* WFC 0-9 DOS commands */ ! 195: get_alloc(&offset,cfg->wfc_cmd[i],LEN_CMD,instream); } ! 196: for(i=0;i<12;i++) { /* WFC F1-F12 shrinking DOS cmds */ ! 197: get_alloc(&offset,cfg->wfc_scmd[i],LEN_CMD,instream); } ! 198: get_str(cfg->mdm_hang,instream); ! 199: get_int(cfg->node_sem_check,instream); ! 200: if(!cfg->node_sem_check) cfg->node_sem_check=60; ! 201: get_int(cfg->node_stat_check,instream); ! 202: if(!cfg->node_stat_check) cfg->node_stat_check=10; ! 203: get_str(cfg->scfg_cmd,instream); ! 204: if(!cfg->scfg_cmd[0]) ! 205: strcpy(cfg->scfg_cmd,"%!scfg %k"); ! 206: get_int(cfg->sec_warn,instream); ! 207: if(!cfg->sec_warn) ! 208: cfg->sec_warn=180; ! 209: get_int(cfg->sec_hangup,instream); ! 210: if(!cfg->sec_hangup) ! 211: cfg->sec_hangup=300; ! 212: for(i=0;i<188;i++) { /* Unused - initialized to NULL */ ! 213: fread(&n,1,2,instream); ! 214: offset+=2; } ! 215: for(i=0;i<256;i++) { /* Unused - initialized to 0xff */ ! 216: fread(&n,1,2,instream); ! 217: offset+=2; } ! 218: ! 219: /***************/ ! 220: /* Modem Stuff */ ! 221: /***************/ ! 222: ! 223: get_int(cfg->com_port,instream); ! 224: get_int(cfg->com_irq,instream); ! 225: get_int(cfg->com_base,instream); ! 226: get_int(cfg->com_rate,instream); ! 227: get_int(cfg->mdm_misc,instream); ! 228: get_str(cfg->mdm_init,instream); ! 229: get_str(cfg->mdm_spec,instream); ! 230: get_str(cfg->mdm_term,instream); ! 231: get_str(cfg->mdm_dial,instream); ! 232: get_str(cfg->mdm_offh,instream); ! 233: get_str(cfg->mdm_answ,instream); ! 234: get_int(cfg->mdm_reinit,instream); ! 235: get_int(cfg->mdm_ansdelay,instream); ! 236: get_int(cfg->mdm_rings,instream); ! 237: ! 238: get_int(cfg->mdm_results,instream); ! 239: ! 240: if(cfg->mdm_results) { ! 241: if((cfg->mdm_result=(mdm_result_t *)MALLOC(sizeof(mdm_result_t)*cfg->mdm_results)) ! 242: ==NULL) ! 243: return allocerr(txt,offset,fname,sizeof(mdm_result_t *)*cfg->mdm_results); } ! 244: else ! 245: cfg->mdm_result=NULL; ! 246: ! 247: for(i=0;i<cfg->mdm_results;i++) { ! 248: if(feof(instream)) break; ! 249: get_int(cfg->mdm_result[i].code,instream); ! 250: get_int(cfg->mdm_result[i].rate,instream); ! 251: get_int(cfg->mdm_result[i].cps,instream); ! 252: get_alloc(&offset,cfg->mdm_result[i].str,LEN_MODEM,instream); } ! 253: cfg->mdm_results=i; ! 254: fclose(instream); ! 255: if(txt->readit && txt->readit[0]) ! 256: lprintf(txt->readit,fname); ! 257: return(TRUE); ! 258: } ! 259: ! 260: #endif ! 261: ! 262: #ifndef NO_MAIN_CFG ! 263: ! 264: /****************************************************************************/ ! 265: /* Reads in MAIN.CNF and initializes the associated variables */ ! 266: /****************************************************************************/ ! 267: BOOL read_main_cfg(scfg_t* cfg, read_cfg_text_t* txt) ! 268: { ! 269: char str[256],fname[13],c; ! 270: short i,j,n; ! 271: long offset=0; ! 272: FILE *instream; ! 273: ! 274: strcpy(fname,"main.cnf"); ! 275: sprintf(str,"%s%s",cfg->ctrl_dir,fname); ! 276: if((instream=fnopen(NULL,str,O_RDONLY))==NULL) { ! 277: lprintf(txt->openerr,str); ! 278: return(FALSE); } ! 279: ! 280: if(txt->reading && txt->reading[0]) ! 281: lprintf(txt->reading,fname); ! 282: get_str(cfg->sys_name,instream); ! 283: get_str(cfg->sys_id,instream); ! 284: get_str(cfg->sys_location,instream); ! 285: get_str(cfg->sys_phonefmt,instream); ! 286: get_str(cfg->sys_op,instream); ! 287: get_str(cfg->sys_guru,instream); ! 288: get_str(cfg->sys_pass,instream); ! 289: get_int(cfg->sys_nodes,instream); ! 290: ! 291: if(!cfg->sys_nodes || cfg->sys_nodes<cfg->node_num || cfg->sys_nodes>MAX_NODES) { ! 292: lprintf(txt->error,offset,fname); ! 293: if(!cfg->sys_nodes) ! 294: lprintf("Total nodes on system must be non-zero."); ! 295: else if(cfg->sys_nodes>MAX_NODES) ! 296: lprintf("Total nodes exceeds %u.",MAX_NODES); ! 297: else ! 298: lprintf("Total nodes (%u) < node number in NODE.CNF (%u)" ! 299: ,cfg->sys_nodes,cfg->node_num); ! 300: return(FALSE); } ! 301: ! 302: if((cfg->node_path=(char **)MALLOC(sizeof(char *)*cfg->sys_nodes))==NULL) ! 303: return allocerr(txt,offset,fname,sizeof(char *)*cfg->sys_nodes); ! 304: ! 305: for(i=0;i<cfg->sys_nodes;i++) { ! 306: if(feof(instream)) break; ! 307: fread(str,LEN_DIR+1,1,instream); ! 308: prep_dir(cfg->ctrl_dir, str); ! 309: offset+=LEN_DIR+1; ! 310: if((cfg->node_path[i]=(char *)MALLOC(strlen(str)+1))==NULL) ! 311: return allocerr(txt,offset,fname,strlen(str)+1); ! 312: strcpy(cfg->node_path[i],str); ! 313: strlwr(cfg->node_path[i]); /* temporary Unix-compatibility hack */ ! 314: } ! 315: ! 316: get_str(cfg->data_dir,instream); /* data directory */ ! 317: get_str(cfg->exec_dir,instream); /* exec directory */ ! 318: ! 319: strlwr(cfg->data_dir); /* temporary Unix-compatibility hack */ ! 320: strlwr(cfg->exec_dir); /* temporary Unix-compatibility hack */ ! 321: ! 322: #ifndef SCFG ! 323: prep_dir(cfg->ctrl_dir, cfg->data_dir); ! 324: prep_dir(cfg->ctrl_dir, cfg->exec_dir); ! 325: #endif ! 326: ! 327: get_str(cfg->sys_logon,instream); ! 328: get_str(cfg->sys_logout,instream); ! 329: get_str(cfg->sys_daily,instream); ! 330: get_int(cfg->sys_timezone,instream); ! 331: get_int(cfg->sys_misc,instream); ! 332: get_int(cfg->sys_lastnode,instream); ! 333: get_int(cfg->sys_autonode,instream); ! 334: get_int(cfg->uq,instream); ! 335: get_int(cfg->sys_pwdays,instream); ! 336: get_int(cfg->sys_deldays,instream); ! 337: get_int(cfg->sys_exp_warn,instream); /* Days left till expiration warning */ ! 338: get_int(cfg->sys_autodel,instream); ! 339: get_int(cfg->sys_def_stat,instream); /* default status line */ ! 340: ! 341: #ifdef SCFG ! 342: get_str(cfg->sys_chat_ar,instream); ! 343: #else ! 344: fread(str,1,LEN_ARSTR+1,instream); ! 345: offset+=LEN_ARSTR+1; ! 346: cfg->sys_chat_ar=arstr(0,str,cfg); ! 347: #endif ! 348: ! 349: get_int(cfg->cdt_min_value,instream); ! 350: get_int(cfg->max_minutes,instream); ! 351: get_int(cfg->cdt_per_dollar,instream); ! 352: get_str(cfg->new_pass,instream); ! 353: get_str(cfg->new_magic,instream); ! 354: get_str(cfg->new_sif,instream); ! 355: get_str(cfg->new_sof,instream); ! 356: if(!cfg->new_sof[0]) /* if output not specified, use input file */ ! 357: strcpy(cfg->new_sof,cfg->new_sif); ! 358: ! 359: /*********************/ ! 360: /* New User Settings */ ! 361: /*********************/ ! 362: ! 363: get_int(cfg->new_level,instream); ! 364: get_int(cfg->new_flags1,instream); ! 365: get_int(cfg->new_flags2,instream); ! 366: get_int(cfg->new_flags3,instream); ! 367: get_int(cfg->new_flags4,instream); ! 368: get_int(cfg->new_exempt,instream); ! 369: get_int(cfg->new_rest,instream); ! 370: get_int(cfg->new_cdt,instream); ! 371: get_int(cfg->new_min,instream); ! 372: get_str(cfg->new_xedit,instream); ! 373: get_int(cfg->new_expire,instream); ! 374: get_int(cfg->new_shell,instream); ! 375: get_int(cfg->new_misc,instream); ! 376: get_int(cfg->new_prot,instream); ! 377: if(cfg->new_prot<SP) ! 378: cfg->new_prot=SP; ! 379: get_int(c,instream); ! 380: for(i=0;i<7;i++) ! 381: get_int(n,instream); ! 382: ! 383: /*************************/ ! 384: /* Expired User Settings */ ! 385: /*************************/ ! 386: ! 387: get_int(cfg->expired_level,instream); ! 388: get_int(cfg->expired_flags1,instream); ! 389: get_int(cfg->expired_flags2,instream); ! 390: get_int(cfg->expired_flags3,instream); ! 391: get_int(cfg->expired_flags4,instream); ! 392: get_int(cfg->expired_exempt,instream); ! 393: get_int(cfg->expired_rest,instream); ! 394: ! 395: get_str(cfg->logon_mod,instream); ! 396: get_str(cfg->logoff_mod,instream); ! 397: get_str(cfg->newuser_mod,instream); ! 398: get_str(cfg->login_mod,instream); ! 399: if(!cfg->login_mod[0]) strcpy(cfg->login_mod,"login"); ! 400: get_str(cfg->logout_mod,instream); ! 401: get_str(cfg->sync_mod,instream); ! 402: get_str(cfg->expire_mod,instream); ! 403: get_int(c,instream); ! 404: ! 405: #if 1 /* temporary hack for Unix compatibility */ ! 406: strlwr (cfg->logon_mod); ! 407: strlwr (cfg->logoff_mod); ! 408: strlwr (cfg->newuser_mod); ! 409: strlwr (cfg->login_mod); ! 410: strlwr (cfg->logout_mod); ! 411: strlwr (cfg->sync_mod); ! 412: strlwr (cfg->expire_mod); ! 413: #endif ! 414: ! 415: for(i=0;i<224;i++) /* unused - initialized to NULL */ ! 416: get_int(n,instream); ! 417: for(i=0;i<256;i++) /* unused - initialized to 0xff */ ! 418: get_int(n,instream); ! 419: ! 420: /*******************/ ! 421: /* Validation Sets */ ! 422: /*******************/ ! 423: ! 424: for(i=0;i<10 && !feof(instream);i++) { ! 425: get_int(cfg->val_level[i],instream); ! 426: get_int(cfg->val_expire[i],instream); ! 427: get_int(cfg->val_flags1[i],instream); ! 428: get_int(cfg->val_flags2[i],instream); ! 429: get_int(cfg->val_flags3[i],instream); ! 430: get_int(cfg->val_flags4[i],instream); ! 431: get_int(cfg->val_cdt[i],instream); ! 432: get_int(cfg->val_exempt[i],instream); ! 433: get_int(cfg->val_rest[i],instream); ! 434: for(j=0;j<8;j++) ! 435: get_int(n,instream); } ! 436: ! 437: /***************************/ ! 438: /* Security Level Settings */ ! 439: /***************************/ ! 440: ! 441: for(i=0;i<100 && !feof(instream);i++) { ! 442: get_int(cfg->level_timeperday[i],instream); ! 443: if(cfg->level_timeperday[i]>500) ! 444: cfg->level_timeperday[i]=500; ! 445: get_int(cfg->level_timepercall[i],instream); ! 446: if(cfg->level_timepercall[i]>500) ! 447: cfg->level_timepercall[i]=500; ! 448: get_int(cfg->level_callsperday[i],instream); ! 449: get_int(cfg->level_freecdtperday[i],instream); ! 450: get_int(cfg->level_linespermsg[i],instream); ! 451: get_int(cfg->level_postsperday[i],instream); ! 452: get_int(cfg->level_emailperday[i],instream); ! 453: get_int(cfg->level_misc[i],instream); ! 454: get_int(cfg->level_expireto[i],instream); ! 455: get_int(c,instream); ! 456: for(j=0;j<5;j++) ! 457: get_int(n,instream); } ! 458: if(i!=100) { ! 459: lprintf(txt->error,offset,fname); ! 460: lprintf("Insufficient User Level Information" ! 461: "%d user levels read, 100 needed.",i); ! 462: return(FALSE); } ! 463: ! 464: get_int(cfg->total_shells,instream); ! 465: #ifdef SBBS ! 466: if(!cfg->total_shells) { ! 467: lprintf(txt->error,offset,fname); ! 468: lprintf("At least one command shell must be configured."); ! 469: return(FALSE); } ! 470: #endif ! 471: ! 472: if(cfg->total_shells) { ! 473: if((cfg->shell=(shell_t **)MALLOC(sizeof(shell_t *)*cfg->total_shells))==NULL) ! 474: return allocerr(txt,offset,fname,sizeof(shell_t *)*cfg->total_shells); } ! 475: else ! 476: cfg->shell=NULL; ! 477: ! 478: for(i=0;i<cfg->total_shells;i++) { ! 479: if(feof(instream)) break; ! 480: if((cfg->shell[i]=(shell_t *)MALLOC(sizeof(shell_t)))==NULL) ! 481: return allocerr(txt,offset,fname,sizeof(shell_t)); ! 482: memset(cfg->shell[i],0,sizeof(shell_t)); ! 483: ! 484: get_alloc(&offset,cfg->shell[i]->name,40,instream); ! 485: get_str(cfg->shell[i]->code,instream); ! 486: strlwr(cfg->shell[i]->code); /* temporary Unix-compatibility hack */ ! 487: #ifdef SCFG ! 488: get_str(cfg->shell[i]->ar,instream); ! 489: #else ! 490: fread(str,1,LEN_ARSTR+1,instream); ! 491: offset+=LEN_ARSTR+1; ! 492: cfg->shell[i]->ar=arstr(0,str,cfg); ! 493: #endif ! 494: get_int(cfg->shell[i]->misc,instream); ! 495: for(j=0;j<8;j++) ! 496: get_int(n,instream); ! 497: } ! 498: cfg->total_shells=i; ! 499: ! 500: ! 501: fclose(instream); ! 502: if(txt->readit && txt->readit[0]) ! 503: lprintf(txt->readit,fname); ! 504: return(TRUE); ! 505: } ! 506: ! 507: #endif ! 508: ! 509: #ifndef NO_MSGS_CFG ! 510: ! 511: ! 512: /****************************************************************************/ ! 513: /* Reads in MSGS.CNF and initializes the associated variables */ ! 514: /****************************************************************************/ ! 515: BOOL read_msgs_cfg(scfg_t* cfg, read_cfg_text_t* txt) ! 516: { ! 517: char str[256],fname[13],c; ! 518: short i,j,k,n; ! 519: long offset=0; ! 520: FILE *instream; ! 521: ! 522: #ifndef SCFG ! 523: ! 524: sprintf(cfg->data_dir_subs,"%ssubs/",cfg->data_dir); ! 525: prep_dir(cfg->ctrl_dir, cfg->data_dir_subs); ! 526: ! 527: #endif ! 528: ! 529: strcpy(fname,"msgs.cnf"); ! 530: sprintf(str,"%s%s",cfg->ctrl_dir,fname); ! 531: if((instream=fnopen(NULL,str,O_RDONLY))==NULL) { ! 532: lprintf(txt->openerr,str); ! 533: return(FALSE); } ! 534: ! 535: if(txt->reading && txt->reading[0]) ! 536: lprintf(txt->reading,fname); ! 537: ! 538: /*************************/ ! 539: /* General Message Stuff */ ! 540: /*************************/ ! 541: ! 542: get_int(cfg->max_qwkmsgs,instream); ! 543: get_int(cfg->mail_maxcrcs,instream); ! 544: get_int(cfg->mail_maxage,instream); ! 545: #ifdef SCFG ! 546: get_str(cfg->preqwk_ar,instream); ! 547: #else ! 548: fread(str,1,LEN_ARSTR+1,instream); ! 549: offset+=LEN_ARSTR+1; ! 550: cfg->preqwk_ar=arstr(0,str,cfg); ! 551: #endif ! 552: get_int(cfg->smb_retry_time,instream); /* odd byte */ ! 553: if(!cfg->smb_retry_time) ! 554: cfg->smb_retry_time=30; ! 555: for(i=0;i<235;i++) /* NULL */ ! 556: get_int(n,instream); ! 557: for(i=0;i<256;i++) /* 0xff */ ! 558: get_int(n,instream); ! 559: ! 560: ! 561: /******************/ ! 562: /* Message Groups */ ! 563: /******************/ ! 564: ! 565: get_int(cfg->total_grps,instream); ! 566: ! 567: ! 568: if(cfg->total_grps) { ! 569: if((cfg->grp=(grp_t **)MALLOC(sizeof(grp_t *)*cfg->total_grps))==NULL) ! 570: return allocerr(txt,offset,fname,sizeof(grp_t *)*cfg->total_grps); } ! 571: else ! 572: cfg->grp=NULL; ! 573: ! 574: ! 575: for(i=0;i<cfg->total_grps;i++) { ! 576: ! 577: if(feof(instream)) break; ! 578: if((cfg->grp[i]=(grp_t *)MALLOC(sizeof(grp_t)))==NULL) ! 579: return allocerr(txt,offset,fname,sizeof(grp_t)); ! 580: memset(cfg->grp[i],0,sizeof(grp_t)); ! 581: ! 582: get_alloc(&offset,cfg->grp[i]->lname,LEN_GLNAME,instream); ! 583: get_alloc(&offset,cfg->grp[i]->sname,LEN_GSNAME,instream); ! 584: ! 585: #if !defined(SCFG) && defined(SAVE_MEMORY) /* Save memory */ ! 586: if(!strcmp(cfg->grp[i]->lname,cfg->grp[i]->sname) && cfg->grp[i]->sname!=scfgnulstr) { ! 587: FREE(cfg->grp[i]->sname); ! 588: cfg->grp[i]->sname=cfg->grp[i]->lname; } ! 589: #endif ! 590: ! 591: #ifdef SCFG ! 592: get_str(cfg->grp[i]->ar,instream); ! 593: #else ! 594: fread(str,1,LEN_ARSTR+1,instream); ! 595: offset+=LEN_ARSTR+1; ! 596: cfg->grp[i]->ar=arstr(0,str,cfg); ! 597: #endif ! 598: for(j=0;j<48;j++) ! 599: get_int(n,instream); ! 600: } ! 601: cfg->total_grps=i; ! 602: ! 603: /**********************/ ! 604: /* Message Sub-boards */ ! 605: /**********************/ ! 606: ! 607: get_int(cfg->total_subs,instream); ! 608: ! 609: if(cfg->total_subs) { ! 610: if((cfg->sub=(sub_t **)MALLOC(sizeof(sub_t *)*cfg->total_subs))==NULL) ! 611: return allocerr(txt,offset,fname,sizeof(sub_t *)*cfg->total_subs); } ! 612: else ! 613: cfg->sub=NULL; ! 614: ! 615: for(i=0;i<cfg->total_subs;i++) { ! 616: if(feof(instream)) break; ! 617: if((cfg->sub[i]=(sub_t *)MALLOC(sizeof(sub_t)))==NULL) ! 618: return allocerr(txt,offset,fname,sizeof(sub_t)); ! 619: memset(cfg->sub[i],0,sizeof(sub_t)); ! 620: ! 621: get_int(cfg->sub[i]->grp,instream); ! 622: get_alloc(&offset,cfg->sub[i]->lname,LEN_SLNAME,instream); ! 623: get_alloc(&offset,cfg->sub[i]->sname,LEN_SSNAME,instream); ! 624: ! 625: #if !defined(SCFG) && defined(SAVE_MEMORY) /* Save memory */ ! 626: if(!strcmp(cfg->sub[i]->lname,cfg->sub[i]->sname) && cfg->sub[i]->sname!=scfgnulstr) { ! 627: FREE(cfg->sub[i]->sname); ! 628: cfg->sub[i]->sname=cfg->sub[i]->lname; } ! 629: #endif ! 630: ! 631: get_alloc(&offset,cfg->sub[i]->qwkname,10,instream); ! 632: ! 633: #if !defined(SCFG) && defined(SAVE_MEMORY) /* Save memory */ ! 634: if(!strcmp(cfg->sub[i]->qwkname,cfg->sub[i]->sname) && cfg->sub[i]->qwkname!=scfgnulstr) { ! 635: FREE(cfg->sub[i]->qwkname); ! 636: cfg->sub[i]->qwkname=cfg->sub[i]->sname; } ! 637: #endif ! 638: ! 639: get_str(cfg->sub[i]->code,instream); ! 640: strlwr(cfg->sub[i]->code); /* temporary Unix-compatibility hack */ ! 641: ! 642: #ifdef SCFG ! 643: get_str(cfg->sub[i]->data_dir,instream); ! 644: #else ! 645: fread(str,LEN_DIR+1,1,instream); /* substitute data dir */ ! 646: offset+=LEN_DIR+1; ! 647: if(str[0]) { ! 648: prep_dir(cfg->ctrl_dir, str); ! 649: if((cfg->sub[i]->data_dir=(char *)MALLOC(strlen(str)+1))==NULL) ! 650: return allocerr(txt,offset,fname,strlen(str)+1); ! 651: strcpy(cfg->sub[i]->data_dir,str); } ! 652: else ! 653: cfg->sub[i]->data_dir=cfg->data_dir_subs; ! 654: #endif ! 655: ! 656: ! 657: #ifdef SCFG ! 658: get_str(cfg->sub[i]->ar,instream); ! 659: get_str(cfg->sub[i]->read_ar,instream); ! 660: get_str(cfg->sub[i]->post_ar,instream); ! 661: get_str(cfg->sub[i]->op_ar,instream); ! 662: #else ! 663: fread(str,1,LEN_ARSTR+1,instream); ! 664: offset+=LEN_ARSTR+1; ! 665: cfg->sub[i]->ar=arstr(0,str,cfg); ! 666: fread(str,1,LEN_ARSTR+1,instream); ! 667: offset+=LEN_ARSTR+1; ! 668: cfg->sub[i]->read_ar=arstr(0,str,cfg); ! 669: fread(str,1,LEN_ARSTR+1,instream); ! 670: offset+=LEN_ARSTR+1; ! 671: cfg->sub[i]->post_ar=arstr(0,str,cfg); ! 672: fread(str,1,LEN_ARSTR+1,instream); ! 673: offset+=LEN_ARSTR+1; ! 674: cfg->sub[i]->op_ar=arstr(0,str,cfg); ! 675: #endif ! 676: get_int(cfg->sub[i]->misc,instream); ! 677: ! 678: ! 679: #ifdef SCFG ! 680: get_str(cfg->sub[i]->tagline,instream); ! 681: #else ! 682: fread(str,81,1,instream); /* substitute tagline */ ! 683: offset+=81; ! 684: if(str[0]) { ! 685: if((cfg->sub[i]->tagline=(char *)MALLOC(strlen(str)+1))==NULL) ! 686: return allocerr(txt,offset,fname,strlen(str)+1); ! 687: strcpy(cfg->sub[i]->tagline,str); } ! 688: else ! 689: cfg->sub[i]->tagline=cfg->qnet_tagline; ! 690: #endif ! 691: ! 692: #ifdef SCFG ! 693: get_str(cfg->sub[i]->origline,instream); ! 694: #else ! 695: fread(str,1,51,instream); /* substitute origin line */ ! 696: offset+=51; ! 697: if(str[0]) { ! 698: if((cfg->sub[i]->origline=(char *)MALLOC(strlen(str)+1))==NULL) ! 699: return allocerr(txt,offset,fname,strlen(str)+1); ! 700: strcpy(cfg->sub[i]->origline,str); } ! 701: else ! 702: cfg->sub[i]->origline=cfg->origline; ! 703: #endif ! 704: ! 705: #ifdef SCFG ! 706: get_str(cfg->sub[i]->echomail_sem,instream); ! 707: #else ! 708: fread(str,1,LEN_DIR+1,instream); /* substitute echomail semaphore */ ! 709: offset+=LEN_DIR+1; ! 710: if(str[0]) { ! 711: prep_path(str); ! 712: if((cfg->sub[i]->echomail_sem=(char *)MALLOC(strlen(str)+1))==NULL) ! 713: return allocerr(txt,offset,fname,strlen(str)+1); ! 714: strcpy(cfg->sub[i]->echomail_sem,str); ! 715: } else ! 716: cfg->sub[i]->echomail_sem=cfg->echomail_sem; ! 717: #endif ! 718: fread(str,1,LEN_DIR+1,instream); /* substitute EchoMail path */ ! 719: offset+=LEN_DIR+1; ! 720: #ifndef SBBS ! 721: backslash(str); ! 722: strcpy(cfg->sub[i]->echopath,str); ! 723: #endif ! 724: get_int(cfg->sub[i]->faddr,instream); /* FidoNet address */ ! 725: ! 726: get_int(cfg->sub[i]->maxmsgs,instream); ! 727: get_int(cfg->sub[i]->maxcrcs,instream); ! 728: get_int(cfg->sub[i]->maxage,instream); ! 729: get_int(cfg->sub[i]->ptridx,instream); ! 730: #ifdef SBBS ! 731: for(j=0;j<i;j++) ! 732: if(cfg->sub[i]->ptridx==cfg->sub[j]->ptridx) { ! 733: lprintf(txt->error,offset,fname); ! 734: lprintf("Duplicate pointer index for subs #%d and #%d" ! 735: ,i+1,j+1); ! 736: return(FALSE); } ! 737: #endif ! 738: ! 739: #ifdef SCFG ! 740: get_str(cfg->sub[i]->mod_ar,instream); ! 741: #else ! 742: fread(str,1,LEN_ARSTR+1,instream); ! 743: offset+=LEN_ARSTR+1; ! 744: cfg->sub[i]->mod_ar=arstr(0,str,cfg); ! 745: #endif ! 746: get_int(cfg->sub[i]->qwkconf,instream); ! 747: get_int(c,instream); ! 748: for(j=0;j<26;j++) ! 749: get_int(n,instream); ! 750: } ! 751: cfg->total_subs=i; ! 752: ! 753: /***********/ ! 754: /* FidoNet */ ! 755: /***********/ ! 756: ! 757: get_int(cfg->total_faddrs,instream); ! 758: ! 759: if(cfg->total_faddrs) { ! 760: if((cfg->faddr=(faddr_t *)MALLOC(sizeof(faddr_t)*cfg->total_faddrs))==NULL) ! 761: return allocerr(txt,offset,fname,sizeof(faddr_t)*cfg->total_faddrs); } ! 762: else ! 763: cfg->faddr=NULL; ! 764: ! 765: for(i=0;i<cfg->total_faddrs;i++) ! 766: get_int(cfg->faddr[i],instream); ! 767: ! 768: get_str(cfg->origline,instream); ! 769: get_str(cfg->netmail_sem,instream); ! 770: get_str(cfg->echomail_sem,instream); ! 771: get_str(cfg->netmail_dir,instream); ! 772: get_str(cfg->echomail_dir,instream); ! 773: get_str(cfg->fidofile_dir,instream); ! 774: get_int(cfg->netmail_misc,instream); ! 775: get_int(cfg->netmail_cost,instream); ! 776: get_int(cfg->dflt_faddr,instream); ! 777: for(i=0;i<28;i++) ! 778: get_int(n,instream); ! 779: ! 780: /* Fix-up paths */ ! 781: prep_path(cfg->netmail_sem); ! 782: prep_path(cfg->echomail_sem); ! 783: prep_dir(cfg->netmail_dir,cfg->data_dir); ! 784: prep_dir(cfg->echomail_dir,cfg->data_dir); ! 785: prep_dir(cfg->fidofile_dir,cfg->data_dir); ! 786: ! 787: /**********/ ! 788: /* QWKnet */ ! 789: /**********/ ! 790: ! 791: get_str(cfg->qnet_tagline,instream); ! 792: ! 793: get_int(cfg->total_qhubs,instream); ! 794: ! 795: if(cfg->total_qhubs) { ! 796: if((cfg->qhub=(qhub_t **)MALLOC(sizeof(qhub_t *)*cfg->total_qhubs))==NULL) ! 797: return allocerr(txt,offset,fname,sizeof(qhub_t*)*cfg->total_qhubs); } ! 798: else ! 799: cfg->qhub=NULL; ! 800: ! 801: for(i=0;i<cfg->total_qhubs;i++) { ! 802: if(feof(instream)) break; ! 803: if((cfg->qhub[i]=(qhub_t *)MALLOC(sizeof(qhub_t)))==NULL) ! 804: return allocerr(txt,offset,fname,sizeof(qhub_t)); ! 805: memset(cfg->qhub[i],0,sizeof(qhub_t)); ! 806: ! 807: get_str(cfg->qhub[i]->id,instream); ! 808: get_int(cfg->qhub[i]->time,instream); ! 809: get_int(cfg->qhub[i]->freq,instream); ! 810: get_int(cfg->qhub[i]->days,instream); ! 811: get_int(cfg->qhub[i]->node,instream); ! 812: get_alloc(&offset,cfg->qhub[i]->call,LEN_CMD,instream); ! 813: get_alloc(&offset,cfg->qhub[i]->pack,LEN_CMD,instream); ! 814: get_alloc(&offset,cfg->qhub[i]->unpack,LEN_CMD,instream); ! 815: get_int(k,instream); ! 816: ! 817: if(k) { ! 818: if((cfg->qhub[i]->sub=(ushort *)MALLOC(sizeof(ushort)*k))==NULL) ! 819: return allocerr(txt,offset,fname,sizeof(uint)*k); ! 820: if((cfg->qhub[i]->conf=(ushort *)MALLOC(sizeof(ushort)*k))==NULL) ! 821: return allocerr(txt,offset,fname,sizeof(ushort)*k); ! 822: if((cfg->qhub[i]->mode=(char *)MALLOC(sizeof(char)*k))==NULL) ! 823: return allocerr(txt,offset,fname,sizeof(uchar)*k); } ! 824: ! 825: for(j=0;j<k;j++) { ! 826: if(feof(instream)) break; ! 827: get_int(cfg->qhub[i]->conf[cfg->qhub[i]->subs],instream); ! 828: get_int(cfg->qhub[i]->sub[cfg->qhub[i]->subs],instream); ! 829: get_int(cfg->qhub[i]->mode[cfg->qhub[i]->subs],instream); ! 830: if(cfg->qhub[i]->sub[cfg->qhub[i]->subs]<cfg->total_subs) ! 831: cfg->sub[cfg->qhub[i]->sub[cfg->qhub[i]->subs]]->misc|=SUB_QNET; ! 832: else ! 833: continue; ! 834: if(cfg->qhub[i]->sub[cfg->qhub[i]->subs]!=INVALID_SUB) ! 835: cfg->qhub[i]->subs++; } ! 836: for(j=0;j<32;j++) ! 837: get_int(n,instream); } ! 838: ! 839: cfg->total_qhubs=i; ! 840: ! 841: for(j=0;j<32;j++) ! 842: get_int(n,instream); ! 843: ! 844: /************/ ! 845: /* PostLink */ ! 846: /************/ ! 847: ! 848: fread(str,11,1,instream); /* Unused - used to be Site Name */ ! 849: offset+=11; ! 850: get_int(cfg->sys_psnum,instream); /* Site Number */ ! 851: get_int(cfg->total_phubs,instream); ! 852: ! 853: if(cfg->total_phubs) { ! 854: if((cfg->phub=(phub_t **)MALLOC(sizeof(phub_t *)*cfg->total_phubs))==NULL) ! 855: return allocerr(txt,offset,fname,sizeof(phub_t*)*cfg->total_phubs); } ! 856: else ! 857: cfg->phub=NULL; ! 858: ! 859: for(i=0;i<cfg->total_phubs;i++) { ! 860: if(feof(instream)) break; ! 861: if((cfg->phub[i]=(phub_t *)MALLOC(sizeof(phub_t)))==NULL) ! 862: return allocerr(txt,offset,fname,sizeof(phub_t)); ! 863: memset(cfg->phub[i],0,sizeof(phub_t)); ! 864: #ifdef SCFG ! 865: get_str(cfg->phub[i]->name,instream); ! 866: #else ! 867: fread(str,11,1,instream); ! 868: offset+=11; ! 869: #endif ! 870: get_int(cfg->phub[i]->time,instream); ! 871: get_int(cfg->phub[i]->freq,instream); ! 872: get_int(cfg->phub[i]->days,instream); ! 873: get_int(cfg->phub[i]->node,instream); ! 874: get_alloc(&offset,cfg->phub[i]->call,LEN_CMD,instream); ! 875: for(j=0;j<32;j++) ! 876: get_int(n,instream); } ! 877: ! 878: cfg->total_phubs=i; ! 879: ! 880: get_str(cfg->sys_psname,instream); /* Site Name */ ! 881: ! 882: for(j=0;j<32;j++) ! 883: get_int(n,instream); ! 884: ! 885: /* Internet */ ! 886: ! 887: get_str(cfg->sys_inetaddr,instream); /* Internet address */ ! 888: get_str(cfg->inetmail_sem,instream); ! 889: prep_path(cfg->inetmail_sem); ! 890: get_int(cfg->inetmail_misc,instream); ! 891: get_int(cfg->inetmail_cost,instream); ! 892: ! 893: fclose(instream); ! 894: if(txt->readit && txt->readit[0]) ! 895: lprintf(txt->readit,fname); ! 896: return(TRUE); ! 897: } ! 898: ! 899: #endif ! 900: ! 901: void free_node_cfg(scfg_t* cfg) ! 902: { ! 903: FREE_AND_NULL(cfg->mdm_result); ! 904: } ! 905: ! 906: void free_main_cfg(scfg_t* cfg) ! 907: { ! 908: int i; ! 909: ! 910: for(i=0;i<cfg->sys_nodes;i++) ! 911: FREE_AND_NULL(cfg->node_path[i]); ! 912: FREE_AND_NULL(cfg->node_path); ! 913: for(i=0;i<cfg->total_shells;i++) ! 914: FREE_AND_NULL(cfg->shell[i]); ! 915: FREE_AND_NULL(cfg->shell); ! 916: } ! 917: ! 918: void free_msgs_cfg(scfg_t* cfg) ! 919: { ! 920: int i; ! 921: ! 922: for(i=0;i<cfg->total_grps;i++) ! 923: FREE_AND_NULL(cfg->grp[i]); ! 924: FREE_AND_NULL(cfg->grp); ! 925: ! 926: for(i=0;i<cfg->total_subs;i++) ! 927: FREE_AND_NULL(cfg->sub[i]); ! 928: FREE_AND_NULL(cfg->sub); ! 929: ! 930: FREE_AND_NULL(cfg->faddr); ! 931: cfg->total_faddrs=0; ! 932: ! 933: for(i=0;i<cfg->total_qhubs;i++) { ! 934: FREE_AND_NULL(cfg->qhub[i]->mode); ! 935: FREE_AND_NULL(cfg->qhub[i]->conf); ! 936: FREE_AND_NULL(cfg->qhub[i]->sub); ! 937: FREE_AND_NULL(cfg->qhub[i]); } ! 938: FREE_AND_NULL(cfg->qhub); ! 939: cfg->qhub=NULL; ! 940: ! 941: for(i=0;i<cfg->total_phubs;i++) ! 942: FREE_AND_NULL(cfg->phub[i]); ! 943: FREE_AND_NULL(cfg->phub); ! 944: ! 945: } ! 946: ! 947: /************************************************************/ ! 948: /* Create data and sub-dirs off data if not already created */ ! 949: /************************************************************/ ! 950: void make_data_dirs(scfg_t* cfg) ! 951: { ! 952: char str[MAX_PATH+1]; ! 953: ! 954: md(cfg->data_dir); ! 955: sprintf(str,"%ssubs",cfg->data_dir); ! 956: md(str); ! 957: sprintf(str,"%sdirs",cfg->data_dir); ! 958: md(str); ! 959: sprintf(str,"%stext",cfg->data_dir); ! 960: md(str); ! 961: sprintf(str,"%smsgs",cfg->data_dir); ! 962: md(str); ! 963: sprintf(str,"%suser",cfg->data_dir); ! 964: md(str); ! 965: sprintf(str,"%suser/ptrs",cfg->data_dir); ! 966: md(str); ! 967: sprintf(str,"%slogs",cfg->data_dir); ! 968: md(str); ! 969: sprintf(str,"%sqnet",cfg->data_dir); ! 970: md(str); ! 971: sprintf(str,"%sfile",cfg->data_dir); ! 972: md(str); ! 973: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.