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

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

unix.superglobalmegacorp.com

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