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