Annotation of sbbs/src/sbbs3/scfglib2.c, revision 1.1.1.1

1.1       root        1: /* scfglib2.c */
                      2: 
                      3: /* Synchronet configuration library routines */
                      4: 
                      5: /* $Id: scfglib2.c,v 1.39 2005/09/20 03:39:52 deuce 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 2004 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: /****************************************************************************/
                     42: /* Reads in LIBS.CNF and initializes the associated variables                          */
                     43: /****************************************************************************/
                     44: BOOL read_file_cfg(scfg_t* cfg, char* error)
                     45: {
                     46:        char    str[MAX_PATH+1],fname[13],c,cmd[LEN_CMD+1];
                     47:        short   i,j,n;
                     48:        long    offset=0,t;
                     49:        FILE    *instream;
                     50: 
                     51:        strcpy(fname,"file.cnf");
                     52:        sprintf(str,"%s%s",cfg->ctrl_dir,fname);
                     53:        if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
                     54:                sprintf(error,"%d (%s) opening %s",errno,STRERROR(errno),str);
                     55:                return(FALSE); 
                     56:        }
                     57: 
                     58:        get_int(cfg->min_dspace,instream);
                     59:        get_int(cfg->max_batup,instream);
                     60: 
                     61:        get_int(cfg->max_batdn,instream);
                     62: 
                     63:        get_int(cfg->max_userxfer,instream);
                     64: 
                     65:        get_int(t,instream);    /* unused - was cdt_byte_value */
                     66:        get_int(cfg->cdt_up_pct,instream);
                     67:        get_int(cfg->cdt_dn_pct,instream);
                     68:        get_int(t,instream);    /* unused - was temp_ext */
                     69:        get_str(cmd,instream);  /* unused - was temp_cmd */
                     70:        get_int(cfg->leech_pct,instream);
                     71:        get_int(cfg->leech_sec,instream);
                     72:        get_int(cfg->file_misc,instream);
                     73: 
                     74:        for(i=0;i<30;i++)
                     75:                get_int(n,instream);
                     76: 
                     77:        /**************************/
                     78:        /* Extractable File Types */
                     79:        /**************************/
                     80: 
                     81:        get_int(cfg->total_fextrs,instream);
                     82: 
                     83:        if(cfg->total_fextrs) {
                     84:                if((cfg->fextr=(fextr_t **)malloc(sizeof(fextr_t *)*cfg->total_fextrs))==NULL)
                     85:                        return allocerr(instream,error,offset,fname,sizeof(fextr_t*)*cfg->total_fextrs); 
                     86:        } else
                     87:                cfg->fextr=NULL;
                     88: 
                     89:        for(i=0; i<cfg->total_fextrs; i++) {
                     90:                if(feof(instream))
                     91:                        break;
                     92:                if((cfg->fextr[i]=(fextr_t *)malloc(sizeof(fextr_t)))==NULL)
                     93:                        return allocerr(instream,error,offset,fname,sizeof(fextr_t));
                     94:                memset(cfg->fextr[i],0,sizeof(fextr_t));
                     95:                get_str(cfg->fextr[i]->ext,instream);
                     96:                get_str(cfg->fextr[i]->cmd,instream);
                     97:                get_str(cfg->fextr[i]->arstr,instream);
                     98:                cfg->fextr[i]->ar=ARSTR(cfg->fextr[i]->arstr,cfg);
                     99: 
                    100:                for(j=0;j<8;j++)
                    101:                        get_int(n,instream);
                    102:        }
                    103:        cfg->total_fextrs=i;
                    104: 
                    105:        /***************************/
                    106:        /* Compressable File Types */
                    107:        /***************************/
                    108: 
                    109:        get_int(cfg->total_fcomps,instream);
                    110: 
                    111:        if(cfg->total_fcomps) {
                    112:                if((cfg->fcomp=(fcomp_t **)malloc(sizeof(fcomp_t *)*cfg->total_fcomps))==NULL)
                    113:                        return allocerr(instream,error,offset,fname,sizeof(fcomp_t*)*cfg->total_fcomps); 
                    114:        } else
                    115:                cfg->fcomp=NULL;
                    116: 
                    117:        for(i=0; i<cfg->total_fcomps; i++) {
                    118:                if(feof(instream))
                    119:                        break;
                    120:                if((cfg->fcomp[i]=(fcomp_t *)malloc(sizeof(fcomp_t)))==NULL)
                    121:                        return allocerr(instream,error,offset,fname,sizeof(fcomp_t));
                    122:                memset(cfg->fcomp[i],0,sizeof(fcomp_t));
                    123:                get_str(cfg->fcomp[i]->ext,instream);
                    124:                get_str(cfg->fcomp[i]->cmd,instream);
                    125:                get_str(cfg->fcomp[i]->arstr,instream);
                    126:                cfg->fcomp[i]->ar=ARSTR(cfg->fcomp[i]->arstr,cfg);
                    127: 
                    128:                for(j=0;j<8;j++)
                    129:                        get_int(n,instream);
                    130:        }
                    131:        cfg->total_fcomps=i;
                    132: 
                    133:        /***********************/
                    134:        /* Viewable File Types */
                    135:        /***********************/
                    136: 
                    137:        get_int(cfg->total_fviews,instream);
                    138: 
                    139:        if(cfg->total_fviews) {
                    140:                if((cfg->fview=(fview_t **)malloc(sizeof(fview_t *)*cfg->total_fviews))==NULL)
                    141:                        return allocerr(instream,error,offset,fname,sizeof(fview_t*)*cfg->total_fviews); 
                    142:        } else
                    143:                cfg->fview=NULL;
                    144: 
                    145:        for(i=0; i<cfg->total_fviews; i++) {
                    146:                if(feof(instream)) break;
                    147:                if((cfg->fview[i]=(fview_t *)malloc(sizeof(fview_t)))==NULL)
                    148:                        return allocerr(instream,error,offset,fname,sizeof(fview_t));
                    149:                memset(cfg->fview[i],0,sizeof(fview_t));
                    150:                get_str(cfg->fview[i]->ext,instream);
                    151:                get_str(cfg->fview[i]->cmd,instream);
                    152:                get_str(cfg->fview[i]->arstr,instream);
                    153:                cfg->fview[i]->ar=ARSTR(cfg->fview[i]->arstr,cfg);
                    154: 
                    155:                for(j=0;j<8;j++)
                    156:                        get_int(n,instream);
                    157:        }
                    158:        cfg->total_fviews=i;
                    159: 
                    160:        /***********************/
                    161:        /* Testable File Types */
                    162:        /***********************/
                    163: 
                    164:        get_int(cfg->total_ftests,instream);
                    165: 
                    166:        if(cfg->total_ftests) {
                    167:                if((cfg->ftest=(ftest_t **)malloc(sizeof(ftest_t *)*cfg->total_ftests))==NULL)
                    168:                        return allocerr(instream,error,offset,fname,sizeof(ftest_t*)*cfg->total_ftests); 
                    169:        } else
                    170:                cfg->ftest=NULL;
                    171: 
                    172:        for(i=0; i<cfg->total_ftests; i++) {
                    173:                if(feof(instream)) break;
                    174:                if((cfg->ftest[i]=(ftest_t *)malloc(sizeof(ftest_t)))==NULL)
                    175:                        return allocerr(instream,error,offset,fname,sizeof(ftest_t));
                    176:                memset(cfg->ftest[i],0,sizeof(ftest_t));
                    177:                get_str(cfg->ftest[i]->ext,instream);
                    178:                get_str(cfg->ftest[i]->cmd,instream);
                    179:                get_str(cfg->ftest[i]->workstr,instream);
                    180:                get_str(cfg->ftest[i]->arstr,instream);
                    181:                cfg->ftest[i]->ar=ARSTR(cfg->ftest[i]->arstr,cfg);
                    182: 
                    183:                for(j=0;j<8;j++)
                    184:                        get_int(n,instream);
                    185:        }
                    186:        cfg->total_ftests=i;
                    187: 
                    188:        /*******************/
                    189:        /* Download events */
                    190:        /*******************/
                    191: 
                    192:        get_int(cfg->total_dlevents,instream);
                    193: 
                    194:        if(cfg->total_dlevents) {
                    195:                if((cfg->dlevent=(dlevent_t **)malloc(sizeof(dlevent_t *)*cfg->total_dlevents))
                    196:                        ==NULL)
                    197:                        return allocerr(instream,error,offset,fname,sizeof(dlevent_t*)*cfg->total_dlevents); 
                    198:        } else
                    199:                cfg->dlevent=NULL;
                    200: 
                    201:        for(i=0; i<cfg->total_dlevents; i++) {
                    202:                if(feof(instream)) break;
                    203:                if((cfg->dlevent[i]=(dlevent_t *)malloc(sizeof(dlevent_t)))==NULL)
                    204:                        return allocerr(instream,error,offset,fname,sizeof(dlevent_t));
                    205:                memset(cfg->dlevent[i],0,sizeof(dlevent_t));
                    206:                get_str(cfg->dlevent[i]->ext,instream);
                    207:                get_str(cfg->dlevent[i]->cmd,instream);
                    208:                get_str(cfg->dlevent[i]->workstr,instream);
                    209:                get_str(cfg->dlevent[i]->arstr,instream);
                    210:                cfg->dlevent[i]->ar=ARSTR(cfg->dlevent[i]->arstr,cfg);
                    211: 
                    212:                for(j=0;j<8;j++)
                    213:                        get_int(n,instream);
                    214:        }
                    215:        cfg->total_dlevents=i;
                    216: 
                    217: 
                    218:        /***************************/
                    219:        /* File Transfer Protocols */
                    220:        /***************************/
                    221: 
                    222:        get_int(cfg->total_prots,instream);
                    223: 
                    224:        if(cfg->total_prots) {
                    225:                if((cfg->prot=(prot_t **)malloc(sizeof(prot_t *)*cfg->total_prots))==NULL)
                    226:                        return allocerr(instream,error,offset,fname,sizeof(prot_t*)*cfg->total_prots); 
                    227:        } else
                    228:                cfg->prot=NULL;
                    229: 
                    230:        for(i=0;i<cfg->total_prots;i++) {
                    231:                if(feof(instream)) break;
                    232:                if((cfg->prot[i]=(prot_t *)malloc(sizeof(prot_t)))==NULL)
                    233:                        return allocerr(instream,error,offset,fname,sizeof(prot_t));
                    234:                memset(cfg->prot[i],0,sizeof(prot_t));
                    235: 
                    236:                get_int(cfg->prot[i]->mnemonic,instream);
                    237:                get_str(cfg->prot[i]->name,instream);
                    238:                get_str(cfg->prot[i]->ulcmd,instream);
                    239:                get_str(cfg->prot[i]->dlcmd,instream);
                    240:                get_str(cfg->prot[i]->batulcmd,instream);
                    241:                get_str(cfg->prot[i]->batdlcmd,instream);
                    242:                get_str(cfg->prot[i]->blindcmd,instream);
                    243:                get_str(cfg->prot[i]->bicmd,instream);
                    244:                get_int(cfg->prot[i]->misc,instream);
                    245:                get_str(cfg->prot[i]->arstr,instream);
                    246:                cfg->prot[i]->ar=ARSTR(cfg->prot[i]->arstr,cfg);
                    247: 
                    248:                for(j=0;j<8;j++)
                    249:                        get_int(n,instream);
                    250:        }
                    251:        cfg->total_prots=i;
                    252: 
                    253:        /************************/
                    254:        /* Alternate File Paths */
                    255:        /************************/
                    256: 
                    257:        get_int(cfg->altpaths,instream);
                    258: 
                    259:        if(cfg->altpaths) {
                    260:                if((cfg->altpath=(char **)malloc(sizeof(char *)*cfg->altpaths))==NULL)
                    261:                        return allocerr(instream,error,offset,fname,sizeof(char *)*cfg->altpaths); 
                    262:        } else
                    263:                cfg->altpath=NULL;
                    264: 
                    265:        for(i=0;i<cfg->altpaths;i++) {
                    266:                if(feof(instream)) break;
                    267:                fread(str,LEN_DIR+1,1,instream);
                    268:                offset+=LEN_DIR+1;
                    269:                backslash(str);
                    270:                j=LEN_DIR+1;
                    271:                if((cfg->altpath[i]=(char *)malloc(j))==NULL)
                    272:                        return allocerr(instream,error,offset,fname,j);
                    273:                memset(cfg->altpath[i],0,j);
                    274:                strcpy(cfg->altpath[i],str);
                    275:                for(j=0;j<8;j++)
                    276:                        get_int(n,instream);
                    277:                }
                    278: 
                    279:        cfg->altpaths=i;
                    280: 
                    281:        /******************/
                    282:        /* File Libraries */
                    283:        /******************/
                    284: 
                    285:        get_int(cfg->total_libs,instream);
                    286: 
                    287:        if(cfg->total_libs) {
                    288:                if((cfg->lib=(lib_t **)malloc(sizeof(lib_t *)*cfg->total_libs))==NULL)
                    289:                        return allocerr(instream,error,offset,fname,sizeof(lib_t *)*cfg->total_libs);
                    290:        } else
                    291:                cfg->lib=NULL;
                    292: 
                    293:        for(i=0;i<cfg->total_libs;i++) {
                    294:                if(feof(instream)) break;
                    295:                if((cfg->lib[i]=(lib_t *)malloc(sizeof(lib_t)))==NULL)
                    296:                        return allocerr(instream,error,offset,fname,sizeof(lib_t));
                    297:                memset(cfg->lib[i],0,sizeof(lib_t));
                    298:                cfg->lib[i]->offline_dir=INVALID_DIR;
                    299: 
                    300:                get_str(cfg->lib[i]->lname,instream);
                    301:                get_str(cfg->lib[i]->sname,instream);
                    302: 
                    303:                get_str(cfg->lib[i]->arstr,instream);
                    304:                cfg->lib[i]->ar=ARSTR(cfg->lib[i]->arstr,cfg);
                    305: 
                    306:                get_str(cfg->lib[i]->parent_path,instream);
                    307: 
                    308:                get_str(cfg->lib[i]->code_prefix,instream);
                    309: 
                    310:                get_int(c,instream);
                    311: 
                    312:                for(j=0;j<3;j++)
                    313:                        get_int(n,instream);    /* 0x0000 */
                    314: 
                    315:                for(j=0;j<16;j++)
                    316:                        get_int(n,instream);    /* 0xffff */
                    317:        }
                    318:        cfg->total_libs=i;
                    319: 
                    320:        /********************/
                    321:        /* File Directories */
                    322:        /********************/
                    323: 
                    324:        cfg->sysop_dir=cfg->user_dir=cfg->upload_dir=INVALID_DIR;
                    325:        get_int(cfg->total_dirs,instream);
                    326: 
                    327:        if(cfg->total_dirs) {
                    328:                if((cfg->dir=(dir_t **)malloc(sizeof(dir_t *)*(cfg->total_dirs+1)))==NULL)
                    329:                        return allocerr(instream,error,offset,fname,sizeof(dir_t *)*(cfg->total_dirs+1));
                    330:        } else
                    331:                cfg->dir=NULL;
                    332: 
                    333:        for(i=0;i<cfg->total_dirs;i++) {
                    334:                if(feof(instream)) break;
                    335:                if((cfg->dir[i]=(dir_t *)malloc(sizeof(dir_t)))==NULL)
                    336:                        return allocerr(instream,error,offset,fname,sizeof(dir_t));
                    337:                memset(cfg->dir[i],0,sizeof(dir_t));
                    338: 
                    339:                get_int(cfg->dir[i]->lib,instream);
                    340:                get_str(cfg->dir[i]->lname,instream);
                    341:                get_str(cfg->dir[i]->sname,instream);
                    342: 
                    343:                if(!stricmp(cfg->dir[i]->sname,"SYSOP"))                        /* Sysop upload directory */
                    344:                        cfg->sysop_dir=i;
                    345:                else if(!stricmp(cfg->dir[i]->sname,"USER"))            /* User to User xfer dir */
                    346:                        cfg->user_dir=i;
                    347:                else if(!stricmp(cfg->dir[i]->sname,"UPLOADS"))  /* Upload directory */
                    348:                        cfg->upload_dir=i;
                    349:                else if(!stricmp(cfg->dir[i]->sname,"OFFLINE")) /* Offline files dir */
                    350:                        cfg->lib[cfg->dir[i]->lib]->offline_dir=i;
                    351: 
                    352:                get_str(cfg->dir[i]->code_suffix,instream);
                    353: 
                    354:                get_str(cfg->dir[i]->data_dir,instream);
                    355: 
                    356:                get_str(cfg->dir[i]->arstr,instream);
                    357:                get_str(cfg->dir[i]->ul_arstr,instream);
                    358:                get_str(cfg->dir[i]->dl_arstr,instream);
                    359:                get_str(cfg->dir[i]->op_arstr,instream);
                    360: 
                    361:                cfg->dir[i]->ar=ARSTR(cfg->dir[i]->arstr,cfg);
                    362:                cfg->dir[i]->ul_ar=ARSTR(cfg->dir[i]->ul_arstr,cfg);
                    363:                cfg->dir[i]->dl_ar=ARSTR(cfg->dir[i]->dl_arstr,cfg);
                    364:                cfg->dir[i]->op_ar=ARSTR(cfg->dir[i]->op_arstr,cfg);
                    365: 
                    366:                get_str(cfg->dir[i]->path,instream);
                    367: 
                    368:                get_str(cfg->dir[i]->upload_sem,instream);
                    369: 
                    370:                get_int(cfg->dir[i]->maxfiles,instream);
                    371:                if(cfg->dir[i]->maxfiles>MAX_FILES)
                    372:                        cfg->dir[i]->maxfiles=MAX_FILES;
                    373:                get_str(cfg->dir[i]->exts,instream);
                    374:                get_int(cfg->dir[i]->misc,instream);
                    375:                get_int(cfg->dir[i]->seqdev,instream);
                    376:                get_int(cfg->dir[i]->sort,instream);
                    377:                get_str(cfg->dir[i]->ex_arstr,instream);
                    378:                cfg->dir[i]->ex_ar=ARSTR(cfg->dir[i]->ex_arstr,cfg);
                    379: 
                    380:                get_int(cfg->dir[i]->maxage,instream);
                    381:                get_int(cfg->dir[i]->up_pct,instream);
                    382:                get_int(cfg->dir[i]->dn_pct,instream);
                    383:                get_int(c,instream);
                    384:                for(j=0;j<24;j++)
                    385:                        get_int(n,instream); 
                    386:        }
                    387: 
                    388:        cfg->total_dirs=i;
                    389: 
                    390:        /**********************/
                    391:        /* Text File Sections */
                    392:        /**********************/
                    393: 
                    394:        get_int(cfg->total_txtsecs,instream);
                    395: 
                    396: 
                    397:        if(cfg->total_txtsecs) {
                    398:                if((cfg->txtsec=(txtsec_t **)malloc(sizeof(txtsec_t *)*cfg->total_txtsecs))==NULL)
                    399:                        return allocerr(instream,error,offset,fname,sizeof(txtsec_t *)*cfg->total_txtsecs); 
                    400:        } else
                    401:                cfg->txtsec=NULL;
                    402: 
                    403:        for(i=0;i<cfg->total_txtsecs;i++) {
                    404:                if(feof(instream)) break;
                    405:                if((cfg->txtsec[i]=(txtsec_t *)malloc(sizeof(txtsec_t)))==NULL)
                    406:                        return allocerr(instream,error,offset,fname,sizeof(txtsec_t));
                    407:                memset(cfg->txtsec[i],0,sizeof(txtsec_t));
                    408: 
                    409:                get_str(cfg->txtsec[i]->name,instream);
                    410:                get_str(cfg->txtsec[i]->code,instream);
                    411:                get_str(cfg->txtsec[i]->arstr,instream);
                    412:                cfg->txtsec[i]->ar=ARSTR(cfg->txtsec[i]->arstr,cfg);
                    413: 
                    414:                for(j=0;j<8;j++)
                    415:                        get_int(n,instream);
                    416:        }
                    417:        cfg->total_txtsecs=i;
                    418: 
                    419:        fclose(instream);
                    420:        return(TRUE);
                    421: }
                    422: 
                    423: /****************************************************************************/
                    424: /* Reads in XTRN.CNF and initializes the associated variables                          */
                    425: /****************************************************************************/
                    426: BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
                    427: {
                    428:        char    str[MAX_PATH+1],fname[13],c;
                    429:        short   i,j,n;
                    430:        long    offset=0;
                    431:        FILE    *instream;
                    432: 
                    433:        strcpy(fname,"xtrn.cnf");
                    434:        sprintf(str,"%s%s",cfg->ctrl_dir,fname);
                    435:        if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
                    436:                sprintf(error,"%d (%s) opening %s",errno,STRERROR(errno),str);
                    437:                return(FALSE); 
                    438:        }
                    439: 
                    440:        /*************/
                    441:        /* Swap list */
                    442:        /*************/
                    443: 
                    444:        get_int(cfg->total_swaps,instream);
                    445: 
                    446:        if(cfg->total_swaps) {
                    447:                if((cfg->swap=(swap_t **)malloc(sizeof(swap_t *)*cfg->total_swaps))==NULL)
                    448:                        return allocerr(instream,error,offset,fname,sizeof(swap_t *)*cfg->total_swaps); 
                    449:        } else
                    450:                cfg->swap=NULL;
                    451: 
                    452:        for(i=0;i<cfg->total_swaps;i++) {
                    453:                if(feof(instream)) break;
                    454:                if((cfg->swap[i]=(swap_t *)malloc(sizeof(swap_t)))==NULL)
                    455:                        return allocerr(instream,error,offset,fname,sizeof(swap_t));
                    456:                get_str(cfg->swap[i]->cmd,instream); 
                    457:        }
                    458:        cfg->total_swaps=i;
                    459: 
                    460:        /********************/
                    461:        /* External Editors */
                    462:        /********************/
                    463: 
                    464:        get_int(cfg->total_xedits,instream);
                    465: 
                    466:        if(cfg->total_xedits) {
                    467:                if((cfg->xedit=(xedit_t **)malloc(sizeof(xedit_t *)*cfg->total_xedits))==NULL)
                    468:                        return allocerr(instream,error,offset,fname,sizeof(xedit_t *)*cfg->total_xedits); 
                    469:        } else
                    470:                cfg->xedit=NULL;
                    471: 
                    472:        for(i=0;i<cfg->total_xedits;i++) {
                    473:                if(feof(instream)) break;
                    474:                if((cfg->xedit[i]=(xedit_t *)malloc(sizeof(xedit_t)))==NULL)
                    475:                        return allocerr(instream,error,offset,fname,sizeof(xedit_t));
                    476:                memset(cfg->xedit[i],0,sizeof(xedit_t));
                    477: 
                    478:                get_str(cfg->xedit[i]->name,instream);
                    479:                get_str(cfg->xedit[i]->code,instream);
                    480:                get_str(cfg->xedit[i]->lcmd,instream);
                    481:                get_str(cfg->xedit[i]->rcmd,instream);
                    482: 
                    483:                get_int(cfg->xedit[i]->misc,instream);
                    484:                get_str(cfg->xedit[i]->arstr,instream);
                    485:                cfg->xedit[i]->ar=ARSTR(cfg->xedit[i]->arstr,cfg);
                    486: 
                    487:                get_int(cfg->xedit[i]->type,instream);
                    488:                get_int(c,instream);
                    489:                for(j=0;j<7;j++)
                    490:                        get_int(n,instream);
                    491:        }
                    492:        cfg->total_xedits=i;
                    493: 
                    494: 
                    495:        /*****************************/
                    496:        /* External Program Sections */
                    497:        /*****************************/
                    498: 
                    499:        get_int(cfg->total_xtrnsecs,instream);
                    500: 
                    501:        if(cfg->total_xtrnsecs) {
                    502:                if((cfg->xtrnsec=(xtrnsec_t **)malloc(sizeof(xtrnsec_t *)*cfg->total_xtrnsecs))
                    503:                        ==NULL)
                    504:                        return allocerr(instream,error,offset,fname,sizeof(xtrnsec_t *)*cfg->total_xtrnsecs);
                    505:        } else
                    506:                cfg->xtrnsec=NULL;
                    507: 
                    508:        for(i=0;i<cfg->total_xtrnsecs;i++) {
                    509:                if(feof(instream)) break;
                    510:                if((cfg->xtrnsec[i]=(xtrnsec_t *)malloc(sizeof(xtrnsec_t)))==NULL)
                    511:                        return allocerr(instream,error,offset,fname,sizeof(xtrnsec_t));
                    512:                memset(cfg->xtrnsec[i],0,sizeof(xtrnsec_t));
                    513: 
                    514:                get_str(cfg->xtrnsec[i]->name,instream);
                    515:                get_str(cfg->xtrnsec[i]->code,instream);
                    516:                get_str(cfg->xtrnsec[i]->arstr,instream);
                    517:                cfg->xtrnsec[i]->ar=ARSTR(cfg->xtrnsec[i]->arstr,cfg);
                    518: 
                    519:                for(j=0;j<8;j++)
                    520:                        get_int(n,instream);
                    521:        }
                    522:        cfg->total_xtrnsecs=i;
                    523: 
                    524: 
                    525:        /*********************/
                    526:        /* External Programs */
                    527:        /*********************/
                    528: 
                    529:        get_int(cfg->total_xtrns,instream);
                    530: 
                    531:        if(cfg->total_xtrns) {
                    532:                if((cfg->xtrn=(xtrn_t **)malloc(sizeof(xtrn_t *)*cfg->total_xtrns))==NULL)
                    533:                        return allocerr(instream,error,offset,fname,sizeof(xtrn_t *)*cfg->total_xtrns);
                    534:        } else
                    535:                cfg->xtrn=NULL;
                    536: 
                    537:        for(i=0;i<cfg->total_xtrns;i++) {
                    538:                if(feof(instream)) break;
                    539:                if((cfg->xtrn[i]=(xtrn_t *)malloc(sizeof(xtrn_t)))==NULL)
                    540:                        return allocerr(instream,error,offset,fname,sizeof(xtrn_t));
                    541:                memset(cfg->xtrn[i],0,sizeof(xtrn_t));
                    542: 
                    543:                get_int(cfg->xtrn[i]->sec,instream);
                    544:                get_str(cfg->xtrn[i]->name,instream);
                    545:                get_str(cfg->xtrn[i]->code,instream);
                    546:                get_str(cfg->xtrn[i]->arstr,instream);
                    547:                get_str(cfg->xtrn[i]->run_arstr,instream);
                    548:                cfg->xtrn[i]->ar=ARSTR(cfg->xtrn[i]->arstr,cfg);
                    549:                cfg->xtrn[i]->run_ar=ARSTR(cfg->xtrn[i]->run_arstr,cfg);
                    550: 
                    551:                get_int(cfg->xtrn[i]->type,instream);
                    552:                get_int(cfg->xtrn[i]->misc,instream);
                    553:                get_int(cfg->xtrn[i]->event,instream);
                    554:                get_int(cfg->xtrn[i]->cost,instream);
                    555:                get_str(cfg->xtrn[i]->cmd,instream);
                    556:                get_str(cfg->xtrn[i]->clean,instream);
                    557:                get_str(cfg->xtrn[i]->path,instream);
                    558:                get_int(cfg->xtrn[i]->textra,instream);
                    559:                get_int(cfg->xtrn[i]->maxtime,instream);
                    560:                for(j=0;j<7;j++)
                    561:                        get_int(n,instream);
                    562:        }
                    563:        cfg->total_xtrns=i;
                    564: 
                    565: 
                    566:        /****************/
                    567:        /* Timed Events */
                    568:        /****************/
                    569: 
                    570:        get_int(cfg->total_events,instream);
                    571: 
                    572:        if(cfg->total_events) {
                    573:                if((cfg->event=(event_t **)malloc(sizeof(event_t *)*cfg->total_events))==NULL)
                    574:                        return allocerr(instream,error,offset,fname,sizeof(event_t *)*cfg->total_events);
                    575:        } else
                    576:                cfg->event=NULL;
                    577: 
                    578:        for(i=0;i<cfg->total_events;i++) {
                    579:                if(feof(instream)) break;
                    580:                if((cfg->event[i]=(event_t *)malloc(sizeof(event_t)))==NULL)
                    581:                        return allocerr(instream,error,offset,fname,sizeof(event_t));
                    582:                memset(cfg->event[i],0,sizeof(event_t));
                    583: 
                    584:                get_str(cfg->event[i]->code,instream);
                    585:                get_str(cfg->event[i]->cmd,instream);
                    586:                get_int(cfg->event[i]->days,instream);
                    587:                get_int(cfg->event[i]->time,instream);
                    588:                get_int(cfg->event[i]->node,instream);
                    589:                get_int(cfg->event[i]->misc,instream);
                    590:                get_str(cfg->event[i]->dir,instream);
                    591:                get_int(cfg->event[i]->freq,instream);
                    592:                get_int(cfg->event[i]->mdays,instream);
                    593: 
                    594:                for(j=0;j<5;j++)
                    595:                        get_int(n,instream);
                    596:        }
                    597:        cfg->total_events=i;
                    598: 
                    599:        /********************************/
                    600:        /* Native (32-bit) Program list */
                    601:        /********************************/
                    602: 
                    603:        get_int(cfg->total_natvpgms,instream);
                    604: 
                    605:        if(cfg->total_natvpgms) {
                    606:                if((cfg->natvpgm=(natvpgm_t **)malloc(sizeof(natvpgm_t *)*cfg->total_natvpgms))==NULL)
                    607:                        return allocerr(instream,error,offset,fname,sizeof(natvpgm_t *)*cfg->total_natvpgms);
                    608:        } else
                    609:                cfg->natvpgm=NULL;
                    610: 
                    611:        for(i=0;i<cfg->total_natvpgms;i++) {
                    612:                if(feof(instream)) break;
                    613:                if((cfg->natvpgm[i]=(natvpgm_t *)malloc(sizeof(natvpgm_t)))==NULL)
                    614:                        return allocerr(instream,error,offset,fname,sizeof(natvpgm_t));
                    615:                get_str(cfg->natvpgm[i]->name,instream);
                    616:                cfg->natvpgm[i]->misc=0; 
                    617:        }
                    618:        cfg->total_natvpgms=i;
                    619:        for(i=0;i<cfg->total_natvpgms;i++) {
                    620:                if(feof(instream)) break;
                    621:                get_int(cfg->natvpgm[i]->misc,instream);
                    622:        }
                    623: 
                    624:        /*******************/
                    625:        /* Global Hot Keys */
                    626:        /*******************/
                    627: 
                    628:        get_int(cfg->total_hotkeys,instream);
                    629: 
                    630:        if(cfg->total_hotkeys) {
                    631:                if((cfg->hotkey=(hotkey_t **)malloc(sizeof(hotkey_t *)*cfg->total_hotkeys))==NULL)
                    632:                        return allocerr(instream,error,offset,fname,sizeof(hotkey_t *)*cfg->total_hotkeys);
                    633:        } else
                    634:                cfg->hotkey=NULL;
                    635: 
                    636:        for(i=0;i<cfg->total_hotkeys;i++) {
                    637:                if(feof(instream)) break;
                    638:                if((cfg->hotkey[i]=(hotkey_t *)malloc(sizeof(hotkey_t)))==NULL)
                    639:                        return allocerr(instream,error,offset,fname,sizeof(hotkey_t));
                    640:                memset(cfg->hotkey[i],0,sizeof(hotkey_t));
                    641: 
                    642:                get_int(cfg->hotkey[i]->key,instream);
                    643:                get_str(cfg->hotkey[i]->cmd,instream);
                    644: 
                    645:                for(j=0;j<8;j++)
                    646:                        get_int(n,instream);
                    647:        }
                    648:        cfg->total_hotkeys=i;
                    649: 
                    650:        /************************************/
                    651:        /* External Program-related Toggles */
                    652:        /************************************/
                    653:        get_int(cfg->xtrn_misc,instream);
                    654: 
                    655:        fclose(instream);
                    656:        return(TRUE);
                    657: }
                    658: 
                    659: /****************************************************************************/
                    660: /* Reads in CHAT.CNF and initializes the associated variables                          */
                    661: /****************************************************************************/
                    662: BOOL read_chat_cfg(scfg_t* cfg, char* error)
                    663: {
                    664:        char    str[MAX_PATH+1],fname[13];
                    665:        short   i,j,n;
                    666:        long    offset=0;
                    667:        FILE    *instream;
                    668: 
                    669:        strcpy(fname,"chat.cnf");
                    670:        sprintf(str,"%s%s",cfg->ctrl_dir,fname);
                    671:        if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
                    672:                sprintf(error,"%d (%s) opening %s",errno,STRERROR(errno),str);
                    673:                return(FALSE);
                    674:        }
                    675: 
                    676:        /*********/
                    677:        /* Gurus */
                    678:        /*********/
                    679: 
                    680:        get_int(cfg->total_gurus,instream);
                    681: 
                    682:        if(cfg->total_gurus) {
                    683:                if((cfg->guru=(guru_t **)malloc(sizeof(guru_t *)*cfg->total_gurus))==NULL)
                    684:                        return allocerr(instream,error,offset,fname,sizeof(guru_t *)*cfg->total_gurus);
                    685:        } else
                    686:                cfg->guru=NULL;
                    687: 
                    688:        for(i=0;i<cfg->total_gurus;i++) {
                    689:                if(feof(instream)) break;
                    690:                if((cfg->guru[i]=(guru_t *)malloc(sizeof(guru_t)))==NULL)
                    691:                        return allocerr(instream,error,offset,fname,sizeof(guru_t));
                    692:                memset(cfg->guru[i],0,sizeof(guru_t));
                    693: 
                    694:                get_str(cfg->guru[i]->name,instream);
                    695:                get_str(cfg->guru[i]->code,instream);
                    696: 
                    697:                get_str(cfg->guru[i]->arstr,instream);
                    698:                cfg->guru[i]->ar=ARSTR(cfg->guru[i]->arstr,cfg);
                    699: 
                    700:                for(j=0;j<8;j++)
                    701:                        get_int(n,instream);
                    702:        }
                    703:        cfg->total_chans=i;
                    704: 
                    705: 
                    706:        /********************/
                    707:        /* Chat Action Sets */
                    708:        /********************/
                    709: 
                    710:        get_int(cfg->total_actsets,instream);
                    711: 
                    712:        if(cfg->total_actsets) {
                    713:                if((cfg->actset=(actset_t **)malloc(sizeof(actset_t *)*cfg->total_actsets))==NULL)
                    714:                        return allocerr(instream,error,offset,fname,sizeof(actset_t *)*cfg->total_actsets);
                    715:        } else
                    716:                cfg->actset=NULL;
                    717: 
                    718:        for(i=0;i<cfg->total_actsets;i++) {
                    719:                if(feof(instream)) break;
                    720:                if((cfg->actset[i]=(actset_t *)malloc(sizeof(actset_t)))==NULL)
                    721:                        return allocerr(instream,error,offset,fname,sizeof(actset_t));
                    722:                get_str(cfg->actset[i]->name,instream);
                    723:        }
                    724:        cfg->total_actsets=i;
                    725: 
                    726: 
                    727:        /****************/
                    728:        /* Chat Actions */
                    729:        /****************/
                    730: 
                    731:        get_int(cfg->total_chatacts,instream);
                    732: 
                    733:        if(cfg->total_chatacts) {
                    734:                if((cfg->chatact=(chatact_t **)malloc(sizeof(chatact_t *)*cfg->total_chatacts))
                    735:                        ==NULL)
                    736:                        return allocerr(instream,error,offset,fname,sizeof(chatact_t *)*cfg->total_chatacts);
                    737:        } else
                    738:                cfg->chatact=NULL;
                    739: 
                    740:        for(i=0;i<cfg->total_chatacts;i++) {
                    741:                if(feof(instream)) break;
                    742:                if((cfg->chatact[i]=(chatact_t *)malloc(sizeof(chatact_t)))==NULL)
                    743:                        return allocerr(instream,error,offset,fname,sizeof(chatact_t));
                    744:                memset(cfg->chatact[i],0,sizeof(chatact_t));
                    745: 
                    746:                get_int(cfg->chatact[i]->actset,instream);
                    747:                get_str(cfg->chatact[i]->cmd,instream);
                    748:                get_str(cfg->chatact[i]->out,instream);
                    749:                for(j=0;j<8;j++)
                    750:                        get_int(n,instream);
                    751:        }
                    752: 
                    753:        cfg->total_chatacts=i;
                    754: 
                    755: 
                    756:        /***************************/
                    757:        /* Multinode Chat Channels */
                    758:        /***************************/
                    759: 
                    760:        get_int(cfg->total_chans,instream);
                    761: 
                    762:        if(cfg->total_chans) {
                    763:                if((cfg->chan=(chan_t **)malloc(sizeof(chan_t *)*cfg->total_chans))==NULL)
                    764:                        return allocerr(instream,error,offset,fname,sizeof(chan_t *)*cfg->total_chans);
                    765:        } else
                    766:                cfg->chan=NULL;
                    767: 
                    768:        for(i=0;i<cfg->total_chans;i++) {
                    769:                if(feof(instream)) break;
                    770:                if((cfg->chan[i]=(chan_t *)malloc(sizeof(chan_t)))==NULL)
                    771:                        return allocerr(instream,error,offset,fname,sizeof(chan_t));
                    772:                memset(cfg->chan[i],0,sizeof(chan_t));
                    773: 
                    774:                get_int(cfg->chan[i]->actset,instream);
                    775:                get_str(cfg->chan[i]->name,instream);
                    776: 
                    777:                get_str(cfg->chan[i]->code,instream);
                    778: 
                    779:                get_str(cfg->chan[i]->arstr,instream);
                    780:                cfg->chan[i]->ar=ARSTR(cfg->chan[i]->arstr,cfg);
                    781: 
                    782:                get_int(cfg->chan[i]->cost,instream);
                    783:                get_int(cfg->chan[i]->guru,instream);
                    784:                get_int(cfg->chan[i]->misc,instream);
                    785:                for(j=0;j<8;j++)
                    786:                        get_int(n,instream);
                    787:        }
                    788:        cfg->total_chans=i;
                    789: 
                    790: 
                    791:        /**************/
                    792:        /* Chat Pages */
                    793:        /**************/
                    794: 
                    795:        get_int(cfg->total_pages,instream);
                    796: 
                    797:        if(cfg->total_pages) {
                    798:                if((cfg->page=(page_t **)malloc(sizeof(page_t *)*cfg->total_pages))==NULL)
                    799:                        return allocerr(instream,error,offset,fname,sizeof(page_t *)*cfg->total_pages);
                    800:        } else
                    801:                cfg->page=NULL;
                    802: 
                    803:        for(i=0;i<cfg->total_pages;i++) {
                    804:                if(feof(instream)) break;
                    805:                if((cfg->page[i]=(page_t *)malloc(sizeof(page_t)))==NULL)
                    806:                        return allocerr(instream,error,offset,fname,sizeof(page_t));
                    807:                memset(cfg->page[i],0,sizeof(page_t));
                    808: 
                    809:                get_str(cfg->page[i]->cmd,instream);
                    810: 
                    811:                get_str(cfg->page[i]->arstr,instream);
                    812:                cfg->page[i]->ar=ARSTR(cfg->page[i]->arstr,cfg);
                    813: 
                    814:                get_int(cfg->page[i]->misc,instream);
                    815:                for(j=0;j<8;j++)
                    816:                        get_int(n,instream);
                    817:        }
                    818:        cfg->total_pages=i;
                    819: 
                    820: 
                    821:        fclose(instream);
                    822:        return(TRUE);
                    823: }
                    824: 
                    825: /****************************************************************************/
                    826: /* Read one line of up to 256 characters from the file pointed to by           */
                    827: /* 'stream' and put upto 'maxlen' number of character into 'outstr' and     */
                    828: /* truncate spaces off end of 'outstr'.                                     */
                    829: /****************************************************************************/
                    830: char *readline(long *offset, char *outstr, int maxlen, FILE *instream)
                    831: {
                    832:        char str[257];
                    833: 
                    834:        if(fgets(str,256,instream)==NULL)
                    835:                return(NULL);
                    836:        sprintf(outstr,"%.*s",maxlen,str);
                    837:        truncsp(outstr);
                    838:        (*offset)+=maxlen;
                    839:        return(outstr);
                    840: }
                    841: 
                    842: /****************************************************************************/
                    843: /* Turns char string of flags into a long                                                                      */
                    844: /****************************************************************************/
                    845: long aftol(char *str)
                    846: {
                    847:        char    ch;
                    848:        size_t  c=0;
                    849:        ulong   l=0UL;
                    850: 
                    851:        while(str[c]) {
                    852:                ch=toupper(str[c]);
                    853:                if(ch>='A' && ch<='Z')
                    854:                        l|=FLAG(ch);
                    855:                c++; 
                    856:        }
                    857:        return(l);
                    858: }
                    859: 
                    860: /*****************************************************************************/
                    861: /* Converts a long into an ASCII Flag string (A-Z) that represents bits 0-25 */
                    862: /*****************************************************************************/
                    863: char *ltoaf(long l,char *str)
                    864: {
                    865:        size_t  c=0;
                    866: 
                    867:        while(c<26) {
                    868:                if(l&(long)(1L<<c))
                    869:                        str[c]='A'+c;
                    870:                else str[c]=' ';
                    871:                c++; 
                    872:        }
                    873:        str[c]=0;
                    874:        return(str);
                    875: }
                    876: 
                    877: /****************************************************************************/
                    878: /* Returns the actual attribute code from a string of ATTR characters       */
                    879: /****************************************************************************/
                    880: uchar attrstr(char *str)
                    881: {
                    882:        uchar atr;
                    883:        ulong l=0;
                    884: 
                    885:        atr=LIGHTGRAY;
                    886:        while(str[l]) {
                    887:                switch(toupper(str[l])) {
                    888:                        case 'H':       /* High intensity */
                    889:                                atr|=HIGH;
                    890:                                break;
                    891:                        case 'I':       /* Blink */
                    892:                                atr|=BLINK;
                    893:                                break;
                    894:                        case 'K':       /* Black */
                    895:                                atr=(atr&0xf8)|BLACK;
                    896:                                break;
                    897:                        case 'W':       /* White */
                    898:                                atr=(atr&0xf8)|LIGHTGRAY;
                    899:                                break;
                    900:                        case 'R':
                    901:                                atr=(uchar)((atr&0xf8)|RED);
                    902:                                break;
                    903:                        case 'G':
                    904:                                atr=(uchar)((atr&0xf8)|GREEN);
                    905:                                break;
                    906:                        case 'Y':   /* Yellow */
                    907:                                atr=(uchar)((atr&0xf8)|BROWN);
                    908:                                break;
                    909:                        case 'B':
                    910:                                atr=(uchar)((atr&0xf8)|BLUE);
                    911:                                break;
                    912:                        case 'M':
                    913:                                atr=(uchar)((atr&0xf8)|MAGENTA);
                    914:                                break;
                    915:                        case 'C':
                    916:                                atr=(uchar)((atr&0xf8)|CYAN);
                    917:                                break;
                    918:                        case '0':       /* Black Background */
                    919:                                atr=(uchar)(atr&0x8f);
                    920:                                break;
                    921:                        case '1':       /* Red Background */
                    922:                                atr=(uchar)((atr&0x8f)|BG_RED);
                    923:                                break;
                    924:                        case '2':       /* Green Background */
                    925:                                atr=(uchar)((atr&0x8f)|BG_GREEN);
                    926:                                break;
                    927:                        case '3':       /* Yellow Background */
                    928:                                atr=(uchar)((atr&0x8f)|BG_BROWN);
                    929:                                break;
                    930:                        case '4':       /* Blue Background */
                    931:                                atr=(uchar)((atr&0x8f)|BG_BLUE);
                    932:                                break;
                    933:                        case '5':       /* Magenta Background */
                    934:                                atr=(uchar)((atr&0x8f)|BG_MAGENTA);
                    935:                                break;
                    936:                        case '6':       /* Cyan Background */
                    937:                                atr=(uchar)((atr&0x8f)|BG_CYAN);
                    938:                                break; 
                    939:                        case '7':       /* White Background */
                    940:                                atr=(uchar)((atr&0x8f)|BG_LIGHTGRAY);
                    941:                                break;
                    942:                        }
                    943:                l++; 
                    944:        }
                    945:        return(atr);
                    946: }
                    947: 
                    948: void free_file_cfg(scfg_t* cfg)
                    949: {
                    950:        uint i;
                    951: 
                    952:        if(cfg->fextr!=NULL) {
                    953:                for(i=0;i<cfg->total_fextrs;i++) {
                    954:                        FREE_AR(cfg->fextr[i]->ar);
                    955:                        FREE_AND_NULL(cfg->fextr[i]);
                    956:                }
                    957:                FREE_AND_NULL(cfg->fextr);
                    958:        }
                    959: 
                    960:        if(cfg->fcomp!=NULL) {
                    961:                for(i=0;i<cfg->total_fcomps;i++) {
                    962:                        FREE_AR(cfg->fcomp[i]->ar);
                    963:                        FREE_AND_NULL(cfg->fcomp[i]);
                    964:                }
                    965:                FREE_AND_NULL(cfg->fcomp);
                    966:        }
                    967: 
                    968:        if(cfg->fview!=NULL) {
                    969:                for(i=0;i<cfg->total_fviews;i++) {
                    970:                        FREE_AR(cfg->fview[i]->ar);
                    971:                        FREE_AND_NULL(cfg->fview[i]);
                    972:                }
                    973:                FREE_AND_NULL(cfg->fview);
                    974:        }
                    975: 
                    976:        if(cfg->ftest!=NULL) {
                    977:                for(i=0;i<cfg->total_ftests;i++) {
                    978:                        FREE_AR(cfg->ftest[i]->ar);
                    979:                        FREE_AND_NULL(cfg->ftest[i]);
                    980:                }
                    981:                FREE_AND_NULL(cfg->ftest);
                    982:        }
                    983: 
                    984:        if(cfg->dlevent!=NULL) {
                    985:                for(i=0;i<cfg->total_dlevents;i++) {
                    986:                        FREE_AR(cfg->dlevent[i]->ar);
                    987:                        FREE_AND_NULL(cfg->dlevent[i]);
                    988:                }
                    989:                FREE_AND_NULL(cfg->dlevent);
                    990:        }
                    991: 
                    992:        if(cfg->prot!=NULL) {
                    993:                for(i=0;i<cfg->total_prots;i++) {
                    994:                        FREE_AR(cfg->prot[i]->ar);
                    995:                        FREE_AND_NULL(cfg->prot[i]);
                    996:                }
                    997:                FREE_AND_NULL(cfg->prot);
                    998:        }
                    999: 
                   1000:        if(cfg->altpath!=NULL) {
                   1001:                for(i=0;i<cfg->altpaths;i++)
                   1002:                        FREE_AND_NULL(cfg->altpath[i]);
                   1003:                FREE_AND_NULL(cfg->altpath);
                   1004:        }
                   1005: 
                   1006:        if(cfg->lib!=NULL) {
                   1007:                for(i=0;i<cfg->total_libs;i++) {
                   1008:                        FREE_AR(cfg->lib[i]->ar);
                   1009:                        FREE_AND_NULL(cfg->lib[i]);
                   1010:                }
                   1011:                FREE_AND_NULL(cfg->lib);
                   1012:        }
                   1013: 
                   1014:        if(cfg->dir!=NULL) {
                   1015:                for(i=0;i<cfg->total_dirs;i++) {
                   1016: #if 0 /*ndef SCFG */
                   1017:                        if(cfg->dir[i]->data_dir!=cfg->data_dir_dirs) 
                   1018:                                FREE_AND_NULL(cfg->dir[i]->data_dir);
                   1019: #endif
                   1020:                        FREE_AR(cfg->dir[i]->ar);
                   1021:                        FREE_AR(cfg->dir[i]->ul_ar);
                   1022:                        FREE_AR(cfg->dir[i]->dl_ar);
                   1023:                        FREE_AR(cfg->dir[i]->op_ar);
                   1024:                        FREE_AR(cfg->dir[i]->ex_ar);
                   1025:                        FREE_AND_NULL(cfg->dir[i]);
                   1026:                }
                   1027:                FREE_AND_NULL(cfg->dir);
                   1028:        }
                   1029: 
                   1030:        if(cfg->txtsec!=NULL) {
                   1031:                for(i=0;i<cfg->total_txtsecs;i++) {
                   1032:                        FREE_AR(cfg->txtsec[i]->ar);
                   1033:                        FREE_AND_NULL(cfg->txtsec[i]);
                   1034:                }
                   1035:                FREE_AND_NULL(cfg->txtsec);
                   1036:        }
                   1037: }
                   1038: 
                   1039: void free_chat_cfg(scfg_t* cfg)
                   1040: {
                   1041:        int i;
                   1042: 
                   1043:        if(cfg->actset!=NULL) {
                   1044:                for(i=0;i<cfg->total_actsets;i++) {
                   1045:                        FREE_AND_NULL(cfg->actset[i]);
                   1046:                }
                   1047:                FREE_AND_NULL(cfg->actset);
                   1048:        }
                   1049: 
                   1050:        if(cfg->chatact!=NULL) {
                   1051:                for(i=0;i<cfg->total_chatacts;i++) {
                   1052:                        FREE_AND_NULL(cfg->chatact[i]);
                   1053:                }
                   1054:                FREE_AND_NULL(cfg->chatact);
                   1055:        }
                   1056: 
                   1057:        if(cfg->chan!=NULL) {
                   1058:                for(i=0;i<cfg->total_chans;i++) {
                   1059:                        FREE_AR(cfg->chan[i]->ar);
                   1060:                        FREE_AND_NULL(cfg->chan[i]);
                   1061:                }
                   1062:                FREE_AND_NULL(cfg->chan);
                   1063:        }
                   1064: 
                   1065:        if(cfg->guru!=NULL) {
                   1066:                for(i=0;i<cfg->total_gurus;i++) {
                   1067:                        FREE_AR(cfg->guru[i]->ar);
                   1068:                        FREE_AND_NULL(cfg->guru[i]);
                   1069:                }
                   1070:                FREE_AND_NULL(cfg->guru);
                   1071:        }
                   1072: 
                   1073:        if(cfg->page!=NULL) {
                   1074:                for(i=0;i<cfg->total_pages;i++) {
                   1075:                        FREE_AR(cfg->page[i]->ar);
                   1076:                        FREE_AND_NULL(cfg->page[i]);
                   1077:                }
                   1078:                FREE_AND_NULL(cfg->page);
                   1079:        }
                   1080: 
                   1081: }
                   1082: 
                   1083: void free_xtrn_cfg(scfg_t* cfg)
                   1084: {
                   1085:        int i;
                   1086: 
                   1087:        if(cfg->swap!=NULL) {
                   1088:                for(i=0;i<cfg->total_swaps;i++) {
                   1089:                        FREE_AND_NULL(cfg->swap[i]);
                   1090:                }
                   1091:                FREE_AND_NULL(cfg->swap);
                   1092:        }
                   1093: 
                   1094:        if(cfg->xedit!=NULL) {
                   1095:                for(i=0;i<cfg->total_xedits;i++) {
                   1096:                        FREE_AR(cfg->xedit[i]->ar);
                   1097:                        FREE_AND_NULL(cfg->xedit[i]);
                   1098:                }
                   1099:                FREE_AND_NULL(cfg->xedit);
                   1100:        }
                   1101: 
                   1102:        if(cfg->xtrnsec!=NULL) {
                   1103:                for(i=0;i<cfg->total_xtrnsecs;i++) {
                   1104:                        FREE_AR(cfg->xtrnsec[i]->ar);
                   1105:                        FREE_AND_NULL(cfg->xtrnsec[i]);
                   1106:                }
                   1107:                FREE_AND_NULL(cfg->xtrnsec);
                   1108:        }
                   1109: 
                   1110:        if(cfg->xtrn!=NULL) {
                   1111:                for(i=0;i<cfg->total_xtrns;i++) {
                   1112:                        FREE_AR(cfg->xtrn[i]->ar);
                   1113:                        FREE_AR(cfg->xtrn[i]->run_ar);
                   1114:                        FREE_AND_NULL(cfg->xtrn[i]);
                   1115:                }
                   1116:                FREE_AND_NULL(cfg->xtrn);
                   1117:        }
                   1118: 
                   1119:        if(cfg->event!=NULL) {
                   1120:                for(i=0;i<cfg->total_events;i++) {
                   1121:                        FREE_AND_NULL(cfg->event[i]);
                   1122:                }
                   1123:                FREE_AND_NULL(cfg->event);
                   1124:        }
                   1125: 
                   1126:        if(cfg->natvpgm!=NULL) {
                   1127:                for(i=0;i<cfg->total_natvpgms;i++) {
                   1128:                        FREE_AND_NULL(cfg->natvpgm[i]);
                   1129:                }
                   1130:                FREE_AND_NULL(cfg->natvpgm);
                   1131:        }
                   1132: }

unix.superglobalmegacorp.com

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