|
|
1.1 root 1: /* scfglib2.c */
2:
3: /* Synchronet configuration library routines */
4:
1.1.1.2 ! root 5: /* $Id: scfglib2.c,v 1.35 2004/09/11 03:36:18 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 2004 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: /****************************************************************************/
42: /* Reads in LIBS.CNF and initializes the associated variables */
43: /****************************************************************************/
1.1.1.2 ! root 44: BOOL read_file_cfg(scfg_t* cfg, char* error)
1.1 root 45: {
1.1.1.2 ! root 46: char str[MAX_PATH+1],fname[13],c,cmd[LEN_CMD+1];
1.1 root 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) {
1.1.1.2 ! root 54: sprintf(error,"%d (%s) opening %s",errno,STRERROR(errno),str);
! 55: return(FALSE);
! 56: }
1.1 root 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);
1.1.1.2 ! root 72: get_int(cfg->file_misc,instream);
1.1 root 73:
1.1.1.2 ! root 74: for(i=0;i<30;i++)
1.1 root 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)
1.1.1.2 ! root 85: return allocerr(instream,error,offset,fname,sizeof(fextr_t*)*cfg->total_fextrs);
! 86: } else
1.1 root 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)
1.1.1.2 ! root 93: return allocerr(instream,error,offset,fname,sizeof(fextr_t));
1.1 root 94: memset(cfg->fextr[i],0,sizeof(fextr_t));
95: get_str(cfg->fextr[i]->ext,instream);
1.1.1.2 ! root 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:
1.1 root 100: for(j=0;j<8;j++)
101: get_int(n,instream);
1.1.1.2 ! root 102: }
1.1 root 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)
1.1.1.2 ! root 113: return allocerr(instream,error,offset,fname,sizeof(fcomp_t*)*cfg->total_fcomps);
! 114: } else
1.1 root 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)
1.1.1.2 ! root 121: return allocerr(instream,error,offset,fname,sizeof(fcomp_t));
1.1 root 122: memset(cfg->fcomp[i],0,sizeof(fcomp_t));
123: get_str(cfg->fcomp[i]->ext,instream);
1.1.1.2 ! root 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:
1.1 root 128: for(j=0;j<8;j++)
129: get_int(n,instream);
1.1.1.2 ! root 130: }
1.1 root 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)
1.1.1.2 ! root 141: return allocerr(instream,error,offset,fname,sizeof(fview_t*)*cfg->total_fviews);
! 142: } else
1.1 root 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)
1.1.1.2 ! root 148: return allocerr(instream,error,offset,fname,sizeof(fview_t));
1.1 root 149: memset(cfg->fview[i],0,sizeof(fview_t));
150: get_str(cfg->fview[i]->ext,instream);
1.1.1.2 ! root 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:
1.1 root 155: for(j=0;j<8;j++)
156: get_int(n,instream);
1.1.1.2 ! root 157: }
1.1 root 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)
1.1.1.2 ! root 168: return allocerr(instream,error,offset,fname,sizeof(ftest_t*)*cfg->total_ftests);
! 169: } else
1.1 root 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)
1.1.1.2 ! root 175: return allocerr(instream,error,offset,fname,sizeof(ftest_t));
1.1 root 176: memset(cfg->ftest[i],0,sizeof(ftest_t));
177: get_str(cfg->ftest[i]->ext,instream);
1.1.1.2 ! root 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:
1.1 root 183: for(j=0;j<8;j++)
184: get_int(n,instream);
1.1.1.2 ! root 185: }
1.1 root 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)
1.1.1.2 ! root 197: return allocerr(instream,error,offset,fname,sizeof(dlevent_t*)*cfg->total_dlevents);
! 198: } else
1.1 root 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)
1.1.1.2 ! root 204: return allocerr(instream,error,offset,fname,sizeof(dlevent_t));
1.1 root 205: memset(cfg->dlevent[i],0,sizeof(dlevent_t));
206: get_str(cfg->dlevent[i]->ext,instream);
1.1.1.2 ! root 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:
1.1 root 212: for(j=0;j<8;j++)
213: get_int(n,instream);
1.1.1.2 ! root 214: }
1.1 root 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)
1.1.1.2 ! root 226: return allocerr(instream,error,offset,fname,sizeof(prot_t*)*cfg->total_prots);
! 227: } else
1.1 root 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)
1.1.1.2 ! root 233: return allocerr(instream,error,offset,fname,sizeof(prot_t));
1.1 root 234: memset(cfg->prot[i],0,sizeof(prot_t));
235:
236: get_int(cfg->prot[i]->mnemonic,instream);
1.1.1.2 ! root 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);
1.1 root 244: get_int(cfg->prot[i]->misc,instream);
1.1.1.2 ! root 245: get_str(cfg->prot[i]->arstr,instream);
! 246: cfg->prot[i]->ar=ARSTR(cfg->prot[i]->arstr,cfg);
! 247:
1.1 root 248: for(j=0;j<8;j++)
249: get_int(n,instream);
1.1.1.2 ! root 250: }
! 251: cfg->total_prots=i;
1.1 root 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)
1.1.1.2 ! root 261: return allocerr(instream,error,offset,fname,sizeof(char *)*cfg->altpaths);
! 262: } else
1.1 root 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)
1.1.1.2 ! root 272: return allocerr(instream,error,offset,fname,j);
1.1 root 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)
1.1.1.2 ! root 289: return allocerr(instream,error,offset,fname,sizeof(lib_t *)*cfg->total_libs);
! 290: } else
1.1 root 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)
1.1.1.2 ! root 296: return allocerr(instream,error,offset,fname,sizeof(lib_t));
1.1 root 297: memset(cfg->lib[i],0,sizeof(lib_t));
298: cfg->lib[i]->offline_dir=INVALID_DIR;
299:
1.1.1.2 ! root 300: get_str(cfg->lib[i]->lname,instream);
! 301: get_str(cfg->lib[i]->sname,instream);
1.1 root 302:
1.1.1.2 ! root 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: }
1.1 root 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)
1.1.1.2 ! root 329: return allocerr(instream,error,offset,fname,sizeof(dir_t *)*(cfg->total_dirs+1));
! 330: } else
1.1 root 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)
1.1.1.2 ! root 336: return allocerr(instream,error,offset,fname,sizeof(dir_t));
1.1 root 337: memset(cfg->dir[i],0,sizeof(dir_t));
338:
339: get_int(cfg->dir[i]->lib,instream);
1.1.1.2 ! root 340: get_str(cfg->dir[i]->lname,instream);
! 341: get_str(cfg->dir[i]->sname,instream);
1.1 root 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:
1.1.1.2 ! root 352: get_str(cfg->dir[i]->code_suffix,instream);
1.1 root 353:
354: get_str(cfg->dir[i]->data_dir,instream);
1.1.1.2 ! root 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:
1.1 root 370: get_int(cfg->dir[i]->maxfiles,instream);
371: if(cfg->dir[i]->maxfiles>MAX_FILES)
372: cfg->dir[i]->maxfiles=MAX_FILES;
1.1.1.2 ! root 373: get_str(cfg->dir[i]->exts,instream);
1.1 root 374: get_int(cfg->dir[i]->misc,instream);
375: get_int(cfg->dir[i]->seqdev,instream);
376: get_int(cfg->dir[i]->sort,instream);
1.1.1.2 ! root 377: get_str(cfg->dir[i]->ex_arstr,instream);
! 378: cfg->dir[i]->ex_ar=ARSTR(cfg->dir[i]->ex_arstr,cfg);
! 379:
1.1 root 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++)
1.1.1.2 ! root 385: get_int(n,instream);
! 386: }
1.1 root 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)
1.1.1.2 ! root 399: return allocerr(instream,error,offset,fname,sizeof(txtsec_t *)*cfg->total_txtsecs);
! 400: } else
1.1 root 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)
1.1.1.2 ! root 406: return allocerr(instream,error,offset,fname,sizeof(txtsec_t));
1.1 root 407: memset(cfg->txtsec[i],0,sizeof(txtsec_t));
408:
1.1.1.2 ! root 409: get_str(cfg->txtsec[i]->name,instream);
1.1 root 410: get_str(cfg->txtsec[i]->code,instream);
1.1.1.2 ! root 411: get_str(cfg->txtsec[i]->arstr,instream);
! 412: cfg->txtsec[i]->ar=ARSTR(cfg->txtsec[i]->arstr,cfg);
! 413:
1.1 root 414: for(j=0;j<8;j++)
415: get_int(n,instream);
1.1.1.2 ! root 416: }
1.1 root 417: cfg->total_txtsecs=i;
418:
419: fclose(instream);
1.1.1.2 ! root 420: return(TRUE);
1.1 root 421: }
422:
423: /****************************************************************************/
424: /* Reads in XTRN.CNF and initializes the associated variables */
425: /****************************************************************************/
1.1.1.2 ! root 426: BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
1.1 root 427: {
1.1.1.2 ! root 428: char str[MAX_PATH+1],fname[13],c;
1.1 root 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) {
1.1.1.2 ! root 436: sprintf(error,"%d (%s) opening %s",errno,STRERROR(errno),str);
! 437: return(FALSE);
! 438: }
1.1 root 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)
1.1.1.2 ! root 448: return allocerr(instream,error,offset,fname,sizeof(swap_t *)*cfg->total_swaps);
! 449: } else
1.1 root 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)
1.1.1.2 ! root 455: return allocerr(instream,error,offset,fname,sizeof(swap_t));
! 456: get_str(cfg->swap[i]->cmd,instream);
! 457: }
1.1 root 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)
1.1.1.2 ! root 468: return allocerr(instream,error,offset,fname,sizeof(xedit_t *)*cfg->total_xedits);
! 469: } else
1.1 root 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)
1.1.1.2 ! root 475: return allocerr(instream,error,offset,fname,sizeof(xedit_t));
1.1 root 476: memset(cfg->xedit[i],0,sizeof(xedit_t));
477:
1.1.1.2 ! root 478: get_str(cfg->xedit[i]->name,instream);
1.1 root 479: get_str(cfg->xedit[i]->code,instream);
1.1.1.2 ! root 480: get_str(cfg->xedit[i]->lcmd,instream);
! 481: get_str(cfg->xedit[i]->rcmd,instream);
1.1 root 482:
483: get_int(cfg->xedit[i]->misc,instream);
1.1.1.2 ! root 484: get_str(cfg->xedit[i]->arstr,instream);
! 485: cfg->xedit[i]->ar=ARSTR(cfg->xedit[i]->arstr,cfg);
! 486:
1.1 root 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);
1.1.1.2 ! root 491: }
1.1 root 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)
1.1.1.2 ! root 504: return allocerr(instream,error,offset,fname,sizeof(xtrnsec_t *)*cfg->total_xtrnsecs);
! 505: } else
1.1 root 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)
1.1.1.2 ! root 511: return allocerr(instream,error,offset,fname,sizeof(xtrnsec_t));
1.1 root 512: memset(cfg->xtrnsec[i],0,sizeof(xtrnsec_t));
513:
1.1.1.2 ! root 514: get_str(cfg->xtrnsec[i]->name,instream);
1.1 root 515: get_str(cfg->xtrnsec[i]->code,instream);
1.1.1.2 ! root 516: get_str(cfg->xtrnsec[i]->arstr,instream);
! 517: cfg->xtrnsec[i]->ar=ARSTR(cfg->xtrnsec[i]->arstr,cfg);
! 518:
1.1 root 519: for(j=0;j<8;j++)
520: get_int(n,instream);
1.1.1.2 ! root 521: }
1.1 root 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)
1.1.1.2 ! root 533: return allocerr(instream,error,offset,fname,sizeof(xtrn_t *)*cfg->total_xtrns);
! 534: } else
1.1 root 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)
1.1.1.2 ! root 540: return allocerr(instream,error,offset,fname,sizeof(xtrn_t));
1.1 root 541: memset(cfg->xtrn[i],0,sizeof(xtrn_t));
542:
543: get_int(cfg->xtrn[i]->sec,instream);
1.1.1.2 ! root 544: get_str(cfg->xtrn[i]->name,instream);
1.1 root 545: get_str(cfg->xtrn[i]->code,instream);
1.1.1.2 ! root 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:
1.1 root 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);
1.1.1.2 ! root 555: get_str(cfg->xtrn[i]->cmd,instream);
! 556: get_str(cfg->xtrn[i]->clean,instream);
! 557: get_str(cfg->xtrn[i]->path,instream);
1.1 root 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);
1.1.1.2 ! root 562: }
1.1 root 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)
1.1.1.2 ! root 574: return allocerr(instream,error,offset,fname,sizeof(event_t *)*cfg->total_events);
! 575: } else
1.1 root 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)
1.1.1.2 ! root 581: return allocerr(instream,error,offset,fname,sizeof(event_t));
1.1 root 582: memset(cfg->event[i],0,sizeof(event_t));
583:
584: get_str(cfg->event[i]->code,instream);
1.1.1.2 ! root 585: get_str(cfg->event[i]->cmd,instream);
1.1 root 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);
1.1.1.2 ! root 590: get_str(cfg->event[i]->dir,instream);
! 591: get_int(cfg->event[i]->freq,instream);
! 592: get_int(cfg->event[i]->mdays,instream);
1.1 root 593:
1.1.1.2 ! root 594: for(j=0;j<5;j++)
1.1 root 595: get_int(n,instream);
1.1.1.2 ! root 596: }
1.1 root 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)
1.1.1.2 ! root 607: return allocerr(instream,error,offset,fname,sizeof(natvpgm_t *)*cfg->total_natvpgms);
! 608: } else
1.1 root 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)
1.1.1.2 ! root 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: }
1.1 root 618: cfg->total_natvpgms=i;
619: for(i=0;i<cfg->total_natvpgms;i++) {
620: if(feof(instream)) break;
1.1.1.2 ! root 621: get_int(cfg->natvpgm[i]->misc,instream);
! 622: }
1.1 root 623:
1.1.1.2 ! root 624: /*******************/
! 625: /* Global Hot Keys */
! 626: /*******************/
1.1 root 627:
1.1.1.2 ! root 628: get_int(cfg->total_hotkeys,instream);
1.1 root 629:
1.1.1.2 ! root 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;
1.1 root 635:
1.1.1.2 ! root 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;
1.1 root 649:
1.1.1.2 ! root 650: /************************************/
! 651: /* External Program-related Toggles */
! 652: /************************************/
! 653: get_int(cfg->xtrn_misc,instream);
1.1 root 654:
1.1.1.2 ! root 655: fclose(instream);
! 656: return(TRUE);
! 657: }
1.1 root 658:
659: /****************************************************************************/
660: /* Reads in CHAT.CNF and initializes the associated variables */
661: /****************************************************************************/
1.1.1.2 ! root 662: BOOL read_chat_cfg(scfg_t* cfg, char* error)
1.1 root 663: {
1.1.1.2 ! root 664: char str[MAX_PATH+1],fname[13];
1.1 root 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) {
1.1.1.2 ! root 672: sprintf(error,"%d (%s) opening %s",errno,STRERROR(errno),str);
! 673: return(FALSE);
! 674: }
1.1 root 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)
1.1.1.2 ! root 684: return allocerr(instream,error,offset,fname,sizeof(guru_t *)*cfg->total_gurus);
! 685: } else
1.1 root 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)
1.1.1.2 ! root 691: return allocerr(instream,error,offset,fname,sizeof(guru_t));
1.1 root 692: memset(cfg->guru[i],0,sizeof(guru_t));
693:
1.1.1.2 ! root 694: get_str(cfg->guru[i]->name,instream);
1.1 root 695: get_str(cfg->guru[i]->code,instream);
696:
1.1.1.2 ! root 697: get_str(cfg->guru[i]->arstr,instream);
! 698: cfg->guru[i]->ar=ARSTR(cfg->guru[i]->arstr,cfg);
! 699:
1.1 root 700: for(j=0;j<8;j++)
701: get_int(n,instream);
1.1.1.2 ! root 702: }
1.1 root 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)
1.1.1.2 ! root 714: return allocerr(instream,error,offset,fname,sizeof(actset_t *)*cfg->total_actsets);
! 715: } else
1.1 root 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)
1.1.1.2 ! root 721: return allocerr(instream,error,offset,fname,sizeof(actset_t));
! 722: get_str(cfg->actset[i]->name,instream);
! 723: }
1.1 root 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)
1.1.1.2 ! root 736: return allocerr(instream,error,offset,fname,sizeof(chatact_t *)*cfg->total_chatacts);
! 737: } else
1.1 root 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)
1.1.1.2 ! root 743: return allocerr(instream,error,offset,fname,sizeof(chatact_t));
1.1 root 744: memset(cfg->chatact[i],0,sizeof(chatact_t));
745:
746: get_int(cfg->chatact[i]->actset,instream);
1.1.1.2 ! root 747: get_str(cfg->chatact[i]->cmd,instream);
! 748: get_str(cfg->chatact[i]->out,instream);
1.1 root 749: for(j=0;j<8;j++)
750: get_int(n,instream);
1.1.1.2 ! root 751: }
1.1 root 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)
1.1.1.2 ! root 764: return allocerr(instream,error,offset,fname,sizeof(chan_t *)*cfg->total_chans);
! 765: } else
1.1 root 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)
1.1.1.2 ! root 771: return allocerr(instream,error,offset,fname,sizeof(chan_t));
1.1 root 772: memset(cfg->chan[i],0,sizeof(chan_t));
773:
774: get_int(cfg->chan[i]->actset,instream);
1.1.1.2 ! root 775: get_str(cfg->chan[i]->name,instream);
1.1 root 776:
777: get_str(cfg->chan[i]->code,instream);
778:
1.1.1.2 ! root 779: get_str(cfg->chan[i]->arstr,instream);
! 780: cfg->chan[i]->ar=ARSTR(cfg->chan[i]->arstr,cfg);
! 781:
1.1 root 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++)
1.1.1.2 ! root 786: get_int(n,instream);
! 787: }
1.1 root 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)
1.1.1.2 ! root 799: return allocerr(instream,error,offset,fname,sizeof(page_t *)*cfg->total_pages);
! 800: } else
1.1 root 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)
1.1.1.2 ! root 806: return allocerr(instream,error,offset,fname,sizeof(page_t));
1.1 root 807: memset(cfg->page[i],0,sizeof(page_t));
808:
1.1.1.2 ! root 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);
1.1 root 813:
814: get_int(cfg->page[i]->misc,instream);
815: for(j=0;j<8;j++)
816: get_int(n,instream);
1.1.1.2 ! root 817: }
1.1 root 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: {
1.1.1.2 ! root 847: int c=0;
! 848: ulong l=0UL;
1.1 root 849:
850: strupr(str);
851: while(str[c]) {
852: if(str[c]>='A' && str[c]<='Z')
853: l|=FLAG(str[c]);
1.1.1.2 ! root 854: c++;
! 855: }
1.1 root 856: return(l);
857: }
858:
859: /*****************************************************************************/
860: /* Converts a long into an ASCII Flag string (A-Z) that represents bits 0-25 */
861: /*****************************************************************************/
862: char *ltoaf(long l,char *str)
863: {
1.1.1.2 ! root 864: int c=0;
1.1 root 865:
866: while(c<26) {
867: if(l&(long)(1L<<c))
868: str[c]='A'+c;
1.1.1.2 ! root 869: else str[c]=' ';
! 870: c++;
! 871: }
1.1 root 872: str[c]=0;
873: return(str);
874: }
875:
876: /****************************************************************************/
877: /* Returns the actual attribute code from a string of ATTR characters */
878: /****************************************************************************/
879: uchar attrstr(char *str)
880: {
881: uchar atr;
882: ulong l=0;
883:
884: atr=LIGHTGRAY;
885: while(str[l]) {
1.1.1.2 ! root 886: switch(toupper(str[l])) {
1.1 root 887: case 'H': /* High intensity */
888: atr|=HIGH;
889: break;
890: case 'I': /* Blink */
891: atr|=BLINK;
892: break;
893: case 'K': /* Black */
894: atr=(atr&0xf8)|BLACK;
895: break;
896: case 'W': /* White */
897: atr=(atr&0xf8)|LIGHTGRAY;
898: break;
899: case 'R':
900: atr=(uchar)((atr&0xf8)|RED);
901: break;
902: case 'G':
903: atr=(uchar)((atr&0xf8)|GREEN);
904: break;
905: case 'Y': /* Yellow */
906: atr=(uchar)((atr&0xf8)|BROWN);
907: break;
908: case 'B':
909: atr=(uchar)((atr&0xf8)|BLUE);
910: break;
911: case 'M':
912: atr=(uchar)((atr&0xf8)|MAGENTA);
913: break;
914: case 'C':
915: atr=(uchar)((atr&0xf8)|CYAN);
916: break;
1.1.1.2 ! root 917: case '0': /* Black Background */
! 918: atr=(uchar)(atr&0x8f);
! 919: break;
1.1 root 920: case '1': /* Red Background */
1.1.1.2 ! root 921: atr=(uchar)((atr&0x8f)|BG_RED);
1.1 root 922: break;
923: case '2': /* Green Background */
1.1.1.2 ! root 924: atr=(uchar)((atr&0x8f)|BG_GREEN);
1.1 root 925: break;
926: case '3': /* Yellow Background */
1.1.1.2 ! root 927: atr=(uchar)((atr&0x8f)|BG_BROWN);
1.1 root 928: break;
929: case '4': /* Blue Background */
1.1.1.2 ! root 930: atr=(uchar)((atr&0x8f)|BG_BLUE);
1.1 root 931: break;
932: case '5': /* Magenta Background */
1.1.1.2 ! root 933: atr=(uchar)((atr&0x8f)|BG_MAGENTA);
1.1 root 934: break;
935: case '6': /* Cyan Background */
1.1.1.2 ! root 936: atr=(uchar)((atr&0x8f)|BG_CYAN);
! 937: break;
! 938: case '7': /* White Background */
! 939: atr=(uchar)((atr&0x8f)|BG_LIGHTGRAY);
! 940: break;
! 941: }
! 942: l++;
! 943: }
1.1 root 944: return(atr);
945: }
946:
947: void free_file_cfg(scfg_t* cfg)
948: {
949: uint i;
950:
1.1.1.2 ! root 951: if(cfg->fextr!=NULL) {
! 952: for(i=0;i<cfg->total_fextrs;i++) {
! 953: FREE_AR(cfg->fextr[i]->ar);
! 954: FREE_AND_NULL(cfg->fextr[i]);
! 955: }
! 956: FREE_AND_NULL(cfg->fextr);
! 957: }
! 958:
! 959: if(cfg->fcomp!=NULL) {
! 960: for(i=0;i<cfg->total_fcomps;i++) {
! 961: FREE_AR(cfg->fcomp[i]->ar);
! 962: FREE_AND_NULL(cfg->fcomp[i]);
! 963: }
! 964: FREE_AND_NULL(cfg->fcomp);
! 965: }
! 966:
! 967: if(cfg->fview!=NULL) {
! 968: for(i=0;i<cfg->total_fviews;i++) {
! 969: FREE_AR(cfg->fview[i]->ar);
! 970: FREE_AND_NULL(cfg->fview[i]);
! 971: }
! 972: FREE_AND_NULL(cfg->fview);
! 973: }
! 974:
! 975: if(cfg->ftest!=NULL) {
! 976: for(i=0;i<cfg->total_ftests;i++) {
! 977: FREE_AR(cfg->ftest[i]->ar);
! 978: FREE_AND_NULL(cfg->ftest[i]);
! 979: }
! 980: FREE_AND_NULL(cfg->ftest);
! 981: }
! 982:
! 983: if(cfg->dlevent!=NULL) {
! 984: for(i=0;i<cfg->total_dlevents;i++) {
! 985: FREE_AR(cfg->dlevent[i]->ar);
! 986: FREE_AND_NULL(cfg->dlevent[i]);
! 987: }
! 988: FREE_AND_NULL(cfg->dlevent);
! 989: }
! 990:
! 991: if(cfg->prot!=NULL) {
! 992: for(i=0;i<cfg->total_prots;i++) {
! 993: FREE_AR(cfg->prot[i]->ar);
! 994: FREE_AND_NULL(cfg->prot[i]);
! 995: }
! 996: FREE_AND_NULL(cfg->prot);
! 997: }
! 998:
! 999: if(cfg->altpath!=NULL) {
! 1000: for(i=0;i<cfg->altpaths;i++)
! 1001: FREE_AND_NULL(cfg->altpath[i]);
! 1002: FREE_AND_NULL(cfg->altpath);
! 1003: }
! 1004:
! 1005: if(cfg->lib!=NULL) {
! 1006: for(i=0;i<cfg->total_libs;i++) {
! 1007: FREE_AR(cfg->lib[i]->ar);
! 1008: FREE_AND_NULL(cfg->lib[i]);
! 1009: }
! 1010: FREE_AND_NULL(cfg->lib);
! 1011: }
! 1012:
! 1013: if(cfg->dir!=NULL) {
! 1014: for(i=0;i<cfg->total_dirs;i++) {
! 1015: #if 0 //ndef SCFG
! 1016: if(cfg->dir[i]->data_dir!=cfg->data_dir_dirs)
! 1017: FREE_AND_NULL(cfg->dir[i]->data_dir);
! 1018: #endif
! 1019: FREE_AR(cfg->dir[i]->ar);
! 1020: FREE_AR(cfg->dir[i]->ul_ar);
! 1021: FREE_AR(cfg->dir[i]->dl_ar);
! 1022: FREE_AR(cfg->dir[i]->op_ar);
! 1023: FREE_AR(cfg->dir[i]->ex_ar);
! 1024: FREE_AND_NULL(cfg->dir[i]);
! 1025: }
! 1026: FREE_AND_NULL(cfg->dir);
! 1027: }
! 1028:
! 1029: if(cfg->txtsec!=NULL) {
! 1030: for(i=0;i<cfg->total_txtsecs;i++) {
! 1031: FREE_AR(cfg->txtsec[i]->ar);
! 1032: FREE_AND_NULL(cfg->txtsec[i]);
! 1033: }
! 1034: FREE_AND_NULL(cfg->txtsec);
! 1035: }
1.1 root 1036: }
1037:
1038: void free_chat_cfg(scfg_t* cfg)
1039: {
1040: int i;
1041:
1.1.1.2 ! root 1042: if(cfg->actset!=NULL) {
! 1043: for(i=0;i<cfg->total_actsets;i++) {
! 1044: FREE_AND_NULL(cfg->actset[i]);
! 1045: }
! 1046: FREE_AND_NULL(cfg->actset);
! 1047: }
! 1048:
! 1049: if(cfg->chatact!=NULL) {
! 1050: for(i=0;i<cfg->total_chatacts;i++) {
! 1051: FREE_AND_NULL(cfg->chatact[i]);
! 1052: }
! 1053: FREE_AND_NULL(cfg->chatact);
! 1054: }
! 1055:
! 1056: if(cfg->chan!=NULL) {
! 1057: for(i=0;i<cfg->total_chans;i++) {
! 1058: FREE_AR(cfg->chan[i]->ar);
! 1059: FREE_AND_NULL(cfg->chan[i]);
! 1060: }
! 1061: FREE_AND_NULL(cfg->chan);
! 1062: }
! 1063:
! 1064: if(cfg->guru!=NULL) {
! 1065: for(i=0;i<cfg->total_gurus;i++) {
! 1066: FREE_AR(cfg->guru[i]->ar);
! 1067: FREE_AND_NULL(cfg->guru[i]);
! 1068: }
! 1069: FREE_AND_NULL(cfg->guru);
! 1070: }
! 1071:
! 1072: if(cfg->page!=NULL) {
! 1073: for(i=0;i<cfg->total_pages;i++) {
! 1074: FREE_AR(cfg->page[i]->ar);
! 1075: FREE_AND_NULL(cfg->page[i]);
! 1076: }
! 1077: FREE_AND_NULL(cfg->page);
! 1078: }
1.1 root 1079:
1080: }
1081:
1082: void free_xtrn_cfg(scfg_t* cfg)
1083: {
1084: int i;
1085:
1.1.1.2 ! root 1086: if(cfg->swap!=NULL) {
! 1087: for(i=0;i<cfg->total_swaps;i++) {
! 1088: FREE_AND_NULL(cfg->swap[i]);
! 1089: }
! 1090: FREE_AND_NULL(cfg->swap);
! 1091: }
1.1 root 1092:
1.1.1.2 ! root 1093: if(cfg->xedit!=NULL) {
! 1094: for(i=0;i<cfg->total_xedits;i++) {
! 1095: FREE_AR(cfg->xedit[i]->ar);
! 1096: FREE_AND_NULL(cfg->xedit[i]);
! 1097: }
! 1098: FREE_AND_NULL(cfg->xedit);
! 1099: }
! 1100:
! 1101: if(cfg->xtrnsec!=NULL) {
! 1102: for(i=0;i<cfg->total_xtrnsecs;i++) {
! 1103: FREE_AR(cfg->xtrnsec[i]->ar);
! 1104: FREE_AND_NULL(cfg->xtrnsec[i]);
! 1105: }
! 1106: FREE_AND_NULL(cfg->xtrnsec);
! 1107: }
! 1108:
! 1109: if(cfg->xtrn!=NULL) {
! 1110: for(i=0;i<cfg->total_xtrns;i++) {
! 1111: FREE_AR(cfg->xtrn[i]->ar);
! 1112: FREE_AR(cfg->xtrn[i]->run_ar);
! 1113: FREE_AND_NULL(cfg->xtrn[i]);
! 1114: }
! 1115: FREE_AND_NULL(cfg->xtrn);
! 1116: }
! 1117:
! 1118: if(cfg->event!=NULL) {
! 1119: for(i=0;i<cfg->total_events;i++) {
! 1120: FREE_AND_NULL(cfg->event[i]);
! 1121: }
! 1122: FREE_AND_NULL(cfg->event);
! 1123: }
! 1124:
! 1125: if(cfg->natvpgm!=NULL) {
! 1126: for(i=0;i<cfg->total_natvpgms;i++) {
! 1127: FREE_AND_NULL(cfg->natvpgm[i]);
! 1128: }
! 1129: FREE_AND_NULL(cfg->natvpgm);
! 1130: }
1.1 root 1131: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.