Annotation of sbbs/sbbs2/scfg/wrcnf2.c, revision 1.1.1.1

1.1       root        1: #line 2 "WRCNF2.C"
                      2: 
                      3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
                      4: 
                      5: #include "scfg.h"
                      6: 
                      7: extern int no_msghdr,all_msghdr;
                      8: extern int no_dirchk;
                      9: 
                     10: extern char *crlf;
                     11: extern char nulbuf[];
                     12: extern int     pslen;
                     13: 
                     14: #define put_int(var,stream) fwrite(&var,1,sizeof(var),stream)
                     15: #define put_str(var,stream) { pslen=strlen(var); \
                     16:                                                        fwrite(var,1,pslen > sizeof(var) \
                     17:                                                                ? sizeof(var) : pslen ,stream); \
                     18:                                                        fwrite(nulbuf,1,pslen > sizeof(var) \
                     19:                                 ? 0 : sizeof(var)-pslen,stream); }
                     20: 
                     21: void backup(char *org)
                     22: {
                     23:        char old[128],new[128];
                     24:        int i,x;
                     25: 
                     26: x=strlen(org)-1;
                     27: if(x<=0)
                     28:        return;
                     29: strcpy(old,org);
                     30: strcpy(new,org);
                     31: for(i=backup_level;i;i--) {
                     32:        new[x]=(i-1)+'0';
                     33:        if(i==backup_level)
                     34:                remove(new);
                     35:        if(i==1) {
                     36:                rename(org,new);
                     37:                continue; }
                     38:        old[x]=(i-2)+'0';
                     39:        rename(old,new); }
                     40: }
                     41: 
                     42: 
                     43: void write_file_cfg()
                     44: {
                     45:        char    str[128],cmd[LEN_CMD+1],c;
                     46:        int     i,j,k,file;
                     47:        short   n;
                     48:        long    l=0;
                     49:        FILE    *stream;
                     50: 
                     51: upop("Writing FILE.CNF...");
                     52: sprintf(str,"%sFILE.CNF",ctrl_dir);
                     53: backup(str);
                     54: 
                     55: if((file=nopen(str,O_WRONLY|O_CREAT|O_TRUNC))==-1
                     56:        || (stream=fdopen(file,"wb"))==NULL) {
                     57:        errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT|O_TRUNC);
                     58:     return; }
                     59: setvbuf(stream,NULL,_IOFBF,2048);
                     60: 
                     61: put_int(min_dspace,stream);
                     62: put_int(max_batup,stream);
                     63: put_int(max_batdn,stream);
                     64: put_int(max_userxfer,stream);
                     65: put_int(l,stream);                                     /* unused */
                     66: put_int(cdt_up_pct,stream);
                     67: put_int(cdt_dn_pct,stream);
                     68: put_int(l,stream);                                     /* unused */
                     69: put_str(cmd,stream);
                     70: put_int(leech_pct,stream);
                     71: put_int(leech_sec,stream);
                     72: n=0;
                     73: for(i=0;i<32;i++)
                     74:        put_int(n,stream);
                     75: 
                     76: /* Extractable File Types */
                     77: 
                     78: put_int(total_fextrs,stream);
                     79: for(i=0;i<total_fextrs;i++) {
                     80:        put_str(fextr[i]->ext,stream);
                     81:        put_str(fextr[i]->cmd,stream);
                     82:        put_str(fextr[i]->ar,stream);
                     83:        n=0;
                     84:        for(j=0;j<8;j++)
                     85:                put_int(n,stream); }
                     86: 
                     87: /* Compressable File Types */
                     88: 
                     89: put_int(total_fcomps,stream);
                     90: for(i=0;i<total_fcomps;i++) {
                     91:        put_str(fcomp[i]->ext,stream);
                     92:        put_str(fcomp[i]->cmd,stream);
                     93:        put_str(fcomp[i]->ar,stream);
                     94:        n=0;
                     95:        for(j=0;j<8;j++)
                     96:         put_int(n,stream); }
                     97: 
                     98: /* Viewable File Types */
                     99: 
                    100: put_int(total_fviews,stream);
                    101: for(i=0;i<total_fviews;i++) {
                    102:        put_str(fview[i]->ext,stream);
                    103:        put_str(fview[i]->cmd,stream);
                    104:        put_str(fview[i]->ar,stream);
                    105:        n=0;
                    106:        for(j=0;j<8;j++)
                    107:         put_int(n,stream); }
                    108: 
                    109: /* Testable File Types */
                    110: 
                    111: put_int(total_ftests,stream);
                    112: for(i=0;i<total_ftests;i++) {
                    113:        put_str(ftest[i]->ext,stream);
                    114:        put_str(ftest[i]->cmd,stream);
                    115:        put_str(ftest[i]->workstr,stream);
                    116:        put_str(ftest[i]->ar,stream);
                    117:        n=0;
                    118:        for(j=0;j<8;j++)
                    119:         put_int(n,stream); }
                    120: 
                    121: /* Download Events */
                    122: 
                    123: put_int(total_dlevents,stream);
                    124: for(i=0;i<total_dlevents;i++) {
                    125:        put_str(dlevent[i]->ext,stream);
                    126:        put_str(dlevent[i]->cmd,stream);
                    127:        put_str(dlevent[i]->workstr,stream);
                    128:        put_str(dlevent[i]->ar,stream);
                    129:        n=0;
                    130:        for(j=0;j<8;j++)
                    131:         put_int(n,stream); }
                    132: 
                    133: /* File Transfer Protocols */
                    134: 
                    135: put_int(total_prots,stream);
                    136: for(i=0;i<total_prots;i++) {
                    137:        put_int(prot[i]->mnemonic,stream);
                    138:        put_str(prot[i]->name,stream);
                    139:        put_str(prot[i]->ulcmd,stream);
                    140:        put_str(prot[i]->dlcmd,stream);
                    141:        put_str(prot[i]->batulcmd,stream);
                    142:        put_str(prot[i]->batdlcmd,stream);
                    143:        put_str(prot[i]->blindcmd,stream);
                    144:        put_str(prot[i]->bicmd,stream);
                    145:        put_int(prot[i]->misc,stream);
                    146:        put_str(prot[i]->ar,stream);
                    147:        n=0;
                    148:        for(j=0;j<8;j++)
                    149:                put_int(n,stream); }
                    150: 
                    151: /* Alternate File Paths */
                    152: 
                    153: put_int(altpaths,stream);
                    154: for(i=0;i<altpaths;i++) {
                    155:        backslash(altpath[i]);
                    156:        fwrite(altpath[i],LEN_DIR+1,1,stream);
                    157:        n=0;
                    158:        for(j=0;j<8;j++)
                    159:                put_int(n,stream); }
                    160: 
                    161: /* File Libraries */
                    162: 
                    163: put_int(total_libs,stream);
                    164: for(i=0;i<total_libs;i++) {
                    165:        put_str(lib[i]->lname,stream);
                    166:        put_str(lib[i]->sname,stream);
                    167:        put_str(lib[i]->ar,stream);
                    168:        n=0;
                    169:        for(j=0;j<32;j++)
                    170:                put_int(n,stream);
                    171:        n=0xffff;
                    172:        for(j=0;j<16;j++)
                    173:                put_int(n,stream); }
                    174: 
                    175: /* File Directories */
                    176: 
                    177: put_int(total_dirs,stream);
                    178: for(j=0;j<total_libs;j++)
                    179:     for(i=0;i<total_dirs;i++)
                    180:         if(dir[i]->lib==j) {
                    181:                        put_int(dir[i]->lib,stream);
                    182:                        put_str(dir[i]->lname,stream);
                    183:                        put_str(dir[i]->sname,stream);
                    184:                        put_str(dir[i]->code,stream);
                    185:                        if(dir[i]->data_dir[0])
                    186:                                backslash(dir[i]->data_dir);
                    187:                        md(dir[i]->data_dir);
                    188:                        put_str(dir[i]->data_dir,stream);
                    189:                        put_str(dir[i]->ar,stream);
                    190:                        put_str(dir[i]->ul_ar,stream);
                    191:                        put_str(dir[i]->dl_ar,stream);
                    192:                        put_str(dir[i]->op_ar,stream);
                    193:                        backslash(dir[i]->path);
                    194:                        put_str(dir[i]->path,stream);
                    195:                        if(dir[i]->misc&DIR_FCHK) {
                    196:                                strcpy(str,dir[i]->path);
                    197:                                md(str); }
                    198: 
                    199:                        put_str(dir[i]->upload_sem,stream);
                    200:                        put_int(dir[i]->maxfiles,stream);
                    201:                        put_str(dir[i]->exts,stream);
                    202:                        put_int(dir[i]->misc,stream);
                    203:                        put_int(dir[i]->seqdev,stream);
                    204:                        put_int(dir[i]->sort,stream);
                    205:                        put_str(dir[i]->ex_ar,stream);
                    206:                        put_int(dir[i]->maxage,stream);
                    207:                        put_int(dir[i]->up_pct,stream);
                    208:                        put_int(dir[i]->dn_pct,stream);
                    209:                        c=0;
                    210:                        put_int(c,stream);
                    211:                        n=0;
                    212:                        for(k=0;k<8;k++)
                    213:                                put_int(n,stream);
                    214:                        n=0xffff;
                    215:                        for(k=0;k<16;k++)
                    216:                                put_int(n,stream);
                    217:                        }
                    218: 
                    219: /* Text File Sections */
                    220: 
                    221: put_int(total_txtsecs,stream);
                    222: for(i=0;i<total_txtsecs;i++) {
                    223:        sprintf(str,"%sTEXT\\%s",data_dir,txtsec[i]->code);
                    224:        md(str);
                    225:        put_str(txtsec[i]->name,stream);
                    226:        put_str(txtsec[i]->code,stream);
                    227:        put_str(txtsec[i]->ar,stream);
                    228:        n=0;
                    229:        for(j=0;j<8;j++)
                    230:                put_int(n,stream); }
                    231: 
                    232: fclose(stream);
                    233: }
                    234: 
                    235: void free_file_cfg()
                    236: {
                    237:        int i;
                    238: 
                    239: for(i=0;i<total_fextrs;i++)
                    240:        FREE(fextr[i]);
                    241: FREE(fextr);
                    242: 
                    243: for(i=0;i<total_fcomps;i++)
                    244:        FREE(fcomp[i]);
                    245: FREE(fcomp);
                    246: 
                    247: for(i=0;i<total_fviews;i++)
                    248:        FREE(fview[i]);
                    249: FREE(fview);
                    250: 
                    251: for(i=0;i<total_ftests;i++)
                    252:        FREE(ftest[i]);
                    253: FREE(ftest);
                    254: 
                    255: for(i=0;i<total_dlevents;i++)
                    256:        FREE(dlevent[i]);
                    257: FREE(dlevent);
                    258: 
                    259: for(i=0;i<total_prots;i++)
                    260:        FREE(prot[i]);
                    261: FREE(prot);
                    262: 
                    263: for(i=0;i<altpaths;i++)
                    264:        FREE(altpath[i]);
                    265: FREE(altpath);
                    266: 
                    267: for(i=0;i<total_libs;i++)
                    268:        FREE(lib[i]);
                    269: FREE(lib);
                    270: 
                    271: for(i=0;i<total_dirs;i++)
                    272:        FREE(dir[i]);
                    273: FREE(dir);
                    274: 
                    275: for(i=0;i<total_txtsecs;i++)
                    276:        FREE(txtsec[i]);
                    277: FREE(txtsec);
                    278: }
                    279: 
                    280: 
                    281: void write_chat_cfg()
                    282: {
                    283:        char    str[128];
                    284:        int     i,j,file;
                    285:        short   n;
                    286:        FILE    *stream;
                    287: 
                    288: upop("Writing CHAT.CNF...");
                    289: sprintf(str,"%sCHAT.CNF",ctrl_dir);
                    290: backup(str);
                    291: 
                    292: if((file=nopen(str,O_WRONLY|O_CREAT|O_TRUNC))==-1
                    293:        || (stream=fdopen(file,"wb"))==NULL) {
                    294:        errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT|O_TRUNC);
                    295:     return; }
                    296: setvbuf(stream,NULL,_IOFBF,2048);
                    297: 
                    298: put_int(total_gurus,stream);
                    299: for(i=0;i<total_gurus;i++) {
                    300:     put_str(guru[i]->name,stream);
                    301:     put_str(guru[i]->code,stream);
                    302:     put_str(guru[i]->ar,stream);
                    303:     n=0;
                    304:     for(j=0;j<8;j++)
                    305:         put_int(n,stream);
                    306:     }
                    307: 
                    308: put_int(total_actsets,stream);
                    309: for(i=0;i<total_actsets;i++)
                    310:        put_str(actset[i]->name,stream);
                    311: 
                    312: put_int(total_chatacts,stream);
                    313: for(i=0;i<total_chatacts;i++) {
                    314:        put_int(chatact[i]->actset,stream);
                    315:        put_str(chatact[i]->cmd,stream);
                    316:        put_str(chatact[i]->out,stream);
                    317:        n=0;
                    318:        for(j=0;j<8;j++)
                    319:                put_int(n,stream);
                    320:        }
                    321: 
                    322: put_int(total_chans,stream);
                    323: for(i=0;i<total_chans;i++) {
                    324:        put_int(chan[i]->actset,stream);
                    325:        put_str(chan[i]->name,stream);
                    326:        put_str(chan[i]->code,stream);
                    327:        put_str(chan[i]->ar,stream);
                    328:        put_int(chan[i]->cost,stream);
                    329:        put_int(chan[i]->guru,stream);
                    330:        put_int(chan[i]->misc,stream);
                    331:        n=0;
                    332:        for(j=0;j<8;j++)
                    333:                put_int(n,stream);
                    334:        }
                    335: 
                    336: put_int(total_pages,stream);
                    337: for(i=0;i<total_pages;i++) {
                    338:     put_int(page[i]->cmd,stream);
                    339:     put_int(page[i]->ar,stream);
                    340:     put_int(page[i]->misc,stream);
                    341:     n=0;
                    342:     for(j=0;j<8;j++)
                    343:         put_int(n,stream);
                    344:     }
                    345: 
                    346: fclose(stream);
                    347: }
                    348: 
                    349: void free_chat_cfg()
                    350: {
                    351:        int i;
                    352: 
                    353: for(i=0;i<total_actsets;i++)
                    354:        FREE(actset[i]);
                    355: FREE(actset);
                    356: 
                    357: for(i=0;i<total_chatacts;i++)
                    358:        FREE(chatact[i]);
                    359: FREE(chatact);
                    360: 
                    361: for(i=0;i<total_chans;i++)
                    362:        FREE(chan[i]);
                    363: FREE(chan);
                    364: 
                    365: for(i=0;i<total_gurus;i++)
                    366:        FREE(guru[i]);
                    367: FREE(guru);
                    368: 
                    369: for(i=0;i<total_pages;i++)
                    370:        FREE(page[i]);
                    371: FREE(page);
                    372: 
                    373: }
                    374: 
                    375: void write_xtrn_cfg()
                    376: {
                    377:        uchar   str[128],c;
                    378:        int     i,j,sec,file;
                    379:        short   n;
                    380:        long    l;
                    381:        FILE    *stream;
                    382: 
                    383: upop("Writing XTRN.CNF...");
                    384: sprintf(str,"%sXTRN.CNF",ctrl_dir);
                    385: backup(str);
                    386: 
                    387: if((file=nopen(str,O_WRONLY|O_CREAT|O_TRUNC))==-1
                    388:        || (stream=fdopen(file,"wb"))==NULL) {
                    389:        errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT|O_TRUNC);
                    390:     return; }
                    391: setvbuf(stream,NULL,_IOFBF,2048);
                    392: 
                    393: put_int(total_swaps,stream);
                    394: for(i=0;i<total_swaps;i++)
                    395:        put_str(swap[i]->cmd,stream);
                    396: 
                    397: put_int(total_xedits,stream);
                    398: for(i=0;i<total_xedits;i++) {
                    399:        put_str(xedit[i]->name,stream);
                    400:        put_str(xedit[i]->code,stream);
                    401:        put_str(xedit[i]->lcmd,stream);
                    402:        put_str(xedit[i]->rcmd,stream);
                    403:        put_int(xedit[i]->misc,stream);
                    404:        put_str(xedit[i]->ar,stream);
                    405:        put_int(xedit[i]->type,stream);
                    406:        c=0;
                    407:        put_int(c,stream);
                    408:        n=0;
                    409:        for(j=0;j<7;j++)
                    410:                put_int(n,stream);
                    411:        }
                    412: 
                    413: put_int(total_xtrnsecs,stream);
                    414: for(i=0;i<total_xtrnsecs;i++) {
                    415:        put_str(xtrnsec[i]->name,stream);
                    416:        put_str(xtrnsec[i]->code,stream);
                    417:        put_str(xtrnsec[i]->ar,stream);
                    418:        n=0;
                    419:        for(j=0;j<8;j++)
                    420:                put_int(n,stream);
                    421:        }
                    422: 
                    423: put_int(total_xtrns,stream);
                    424: for(sec=0;sec<total_xtrnsecs;sec++)
                    425:        for(i=0;i<total_xtrns;i++) {
                    426:                if(xtrn[i]->sec!=sec)
                    427:                        continue;
                    428:                put_int(xtrn[i]->sec,stream);
                    429:                put_str(xtrn[i]->name,stream);
                    430:                put_str(xtrn[i]->code,stream);
                    431:                put_str(xtrn[i]->ar,stream);
                    432:                put_str(xtrn[i]->run_ar,stream);
                    433:                put_int(xtrn[i]->type,stream);
                    434:                put_int(xtrn[i]->misc,stream);
                    435:                put_int(xtrn[i]->event,stream);
                    436:                put_int(xtrn[i]->cost,stream);
                    437:                put_str(xtrn[i]->cmd,stream);
                    438:                put_str(xtrn[i]->clean,stream);
                    439:                put_str(xtrn[i]->path,stream);
                    440:                put_int(xtrn[i]->textra,stream);
                    441:                put_int(xtrn[i]->maxtime,stream);
                    442:                n=0;
                    443:                for(j=0;j<7;j++)
                    444:                        put_int(n,stream);
                    445:                }
                    446: 
                    447: put_int(total_events,stream);
                    448: for(i=0;i<total_events;i++) {
                    449:        put_str(event[i]->code,stream);
                    450:        put_str(event[i]->cmd,stream);
                    451:        put_int(event[i]->days,stream);
                    452:        put_int(event[i]->time,stream);
                    453:        put_int(event[i]->node,stream);
                    454:        put_int(event[i]->misc,stream);
                    455:        put_int(event[i]->dir,stream);
                    456:        n=0;
                    457:        for(j=0;j<8;j++)
                    458:                put_int(n,stream);
                    459:        }
                    460: 
                    461: put_int(total_os2pgms,stream);
                    462: for(i=0;i<total_os2pgms;i++)
                    463:        put_str(os2pgm[i]->name,stream);
                    464: for(i=0;i<total_os2pgms;i++)
                    465:        put_int(os2pgm[i]->misc,stream);
                    466: 
                    467: fclose(stream);
                    468: }
                    469: 
                    470: void free_xtrn_cfg()
                    471: {
                    472:        int i;
                    473: 
                    474: for(i=0;i<total_swaps;i++)
                    475:        FREE(swap[i]);
                    476: FREE(swap);
                    477: 
                    478: for(i=0;i<total_xedits;i++)
                    479:        FREE(xedit[i]);
                    480: FREE(xedit);
                    481: 
                    482: for(i=0;i<total_xtrnsecs;i++)
                    483:        FREE(xtrnsec[i]);
                    484: FREE(xtrnsec);
                    485: 
                    486: for(i=0;i<total_xtrns;i++)
                    487:        FREE(xtrn[i]);
                    488: FREE(xtrn);
                    489: 
                    490: for(i=0;i<total_events;i++)
                    491:        FREE(event[i]);
                    492: FREE(event);
                    493: 
                    494: }

unix.superglobalmegacorp.com

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