Annotation of sbbs/sbbs2/echo/read_cfg.c, revision 1.1.1.1

1.1       root        1: /* READ_CFG.C */
                      2: 
                      3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
                      4: 
                      5: /* Portions written by Allen Christiansen 1994-1996                                            */
                      6: 
                      7: #include <dos.h>
                      8: #include <mem.h>
                      9: #include <time.h>
                     10: #include <errno.h>
                     11: #include <stdio.h>
                     12: #include <conio.h>
                     13: #include <ctype.h>
                     14: #include <fcntl.h>
                     15: #include <share.h>
                     16: #include <malloc.h>
                     17: #include <stdarg.h>
                     18: #include <stdlib.h>
                     19: #include <string.h>
                     20: #include <process.h>
                     21: #include <sys\stat.h>
                     22: 
                     23: #include "crc32.h"
                     24: #include "sbbsdefs.h"
                     25: #include "sbbsecho.h"
                     26: 
                     27: #ifdef __WATCOMC__
                     28:     #define O_DENYNONE SH_DENYNO
                     29: #endif
                     30: 
                     31: extern uchar node_swap;
                     32: extern long misc;
                     33: extern config_t cfg;
                     34: 
                     35: /****************************************************************************/
                     36: /* Network open function. Opens all files DENYALL and retries LOOP_NOPEN    */
                     37: /* number of times if the attempted file is already open or denying access  */
                     38: /* for some other reason.   All files are opened in BINARY mode.            */
                     39: /****************************************************************************/
                     40: int nopen(char *str, int access)
                     41: {
                     42:     char logstr[256];
                     43:     int file,share,count=0;
                     44: 
                     45: if(access&O_DENYNONE) {
                     46:        access&=~O_DENYNONE;
                     47:        share=SH_DENYNO; }
                     48: else if(access==O_RDONLY) share=SH_DENYWR;
                     49: else share=SH_DENYRW;
                     50: while(((file=sopen(str,O_BINARY|access,share,S_IWRITE))==-1)
                     51:     && errno==EACCES && count++<LOOP_NOPEN);
                     52: if(file==-1 && errno==EACCES)
                     53:     printf("\7\nNOPEN: ACCESS DENIED\n\7");
                     54: return(file);
                     55: }
                     56: 
                     57: /****************************************************************************/
                     58: /* This function performs an nopen, but returns a file stream with a buffer */
                     59: /* allocated.                                                               */
                     60: /****************************************************************************/
                     61: FILE *fnopen(int *file, char *str, int access)
                     62: {
                     63:     char mode[128];
                     64:     FILE *stream;
                     65: 
                     66: if(access&O_WRONLY) {
                     67:        access&=~O_WRONLY;
                     68:        access|=O_RDWR; }        /* fdopen can't open WRONLY */
                     69: 
                     70: if(((*file)=nopen(str,access))==-1)
                     71:     return(NULL);
                     72: 
                     73: if(access&O_APPEND) {
                     74:        if(access&(O_RDONLY|O_RDWR))
                     75:         strcpy(mode,"a+");
                     76:     else
                     77:         strcpy(mode,"a"); }
                     78: else {
                     79:        if(access&(O_WRONLY|O_RDWR))
                     80:         strcpy(mode,"r+");
                     81:     else
                     82:         strcpy(mode,"r"); }
                     83: stream=fdopen((*file),mode);
                     84: if(stream==NULL) {
                     85:        printf("\7\nFDOPEN(%s) FAILED\n",mode);
                     86:     close(*file);
                     87:     return(NULL); }
                     88: setvbuf(stream,NULL,_IOFBF,16*1024);
                     89: return(stream);
                     90: }
                     91: /******************************************************************************
                     92:  Here we take a string and put a terminator in place of the first TAB or SPACE
                     93: ******************************************************************************/
                     94: char *cleanstr(char *instr)
                     95: {
                     96:        int i;
                     97: 
                     98: for(i=0;instr[i];i++)
                     99:        if((uchar)instr[i]<=SP)
                    100:                break;
                    101: instr[i]=0;
                    102: return(instr);
                    103: }
                    104: /****************************************************************************/
                    105: /* Returns the FidoNet address kept in str as ASCII.                        */
                    106: /****************************************************************************/
                    107: faddr_t atofaddr(char *instr)
                    108: {
                    109:        char *p,str[51];
                    110:     faddr_t addr;
                    111: 
                    112: sprintf(str,"%.50s",instr);
                    113: cleanstr(str);
                    114: if(!stricmp(str,"ALL")) {
                    115:        addr.zone=addr.net=addr.node=addr.point=0xffff;
                    116:        return(addr); }
                    117: addr.zone=addr.net=addr.node=addr.point=0;
                    118: if((p=strchr(str,':'))!=NULL) {
                    119:        if(!strnicmp(str,"ALL:",4))
                    120:                addr.zone=0xffff;
                    121:        else
                    122:                addr.zone=atoi(str);
                    123:        p++;
                    124:        if(!strnicmp(p,"ALL",3))
                    125:                addr.net=0xffff;
                    126:        else
                    127:                addr.net=atoi(p); }
                    128: else {
                    129: #ifdef SCFG
                    130:     if(total_faddrs)
                    131:         addr.zone=faddr[0].zone;
                    132:     else
                    133: #endif
                    134:         addr.zone=1;
                    135:     addr.net=atoi(str); }
                    136: if(!addr.zone)              /* no such thing as zone 0 */
                    137:     addr.zone=1;
                    138: if((p=strchr(str,'/'))!=NULL) {
                    139:        p++;
                    140:        if(!strnicmp(p,"ALL",3))
                    141:                addr.node=0xffff;
                    142:        else
                    143:                addr.node=atoi(p); }
                    144: else {
                    145:        if(!addr.net) {
                    146: #ifdef SCFG
                    147:                if(total_faddrs)
                    148:                        addr.net=faddr[0].net;
                    149:                else
                    150: #endif
                    151:                        addr.net=1; }
                    152:        addr.node=atoi(str); }
                    153: if((p=strchr(str,'.'))!=NULL) {
                    154:        p++;
                    155:        if(!strnicmp(p,"ALL",3))
                    156:                addr.point=0xffff;
                    157:        else
                    158:                addr.point=atoi(p); }
                    159: return(addr);
                    160: }
                    161: 
                    162: /****************************************************************************/
                    163: /* Returns an ASCII string for FidoNet address 'addr'                       */
                    164: /****************************************************************************/
                    165: char *faddrtoa(faddr_t addr)
                    166: {
                    167:     static char str[25];
                    168:        char tmp[25];
                    169: 
                    170: if(addr.zone==0xffff)
                    171:        strcpy(str,"ALL");
                    172: else {
                    173:        sprintf(str,"%u:",addr.zone);
                    174:        if(addr.net==0xffff)
                    175:                strcat(str,"ALL");
                    176:        else {
                    177:                sprintf(tmp,"%u/",addr.net);
                    178:                strcat(str,tmp);
                    179:                if(addr.node==0xffff)
                    180:                        strcat(str,"ALL");
                    181:                else {
                    182:                        sprintf(tmp,"%u",addr.node);
                    183:                        strcat(str,tmp);
                    184:                        if(addr.point==0xffff)
                    185:                                strcat(str,".ALL");
                    186:                        else if(addr.point) {
                    187:                                sprintf(tmp,".%u",addr.point);
                    188:                                strcat(str,tmp); } } } }
                    189: return(str);
                    190: }
                    191: /******************************************************************************
                    192:  This function returns the number of the node in the SBBSECHO.CFG file which
                    193:  matches the address passed to it (or cfg.nodecfgs if no match).
                    194:  ******************************************************************************/
                    195: int matchnode(faddr_t addr, int exact)
                    196: {
                    197:        int i;
                    198: 
                    199: if(exact!=2) {
                    200:        for(i=0;i<cfg.nodecfgs;i++)                             /* Look for exact match */
                    201:                if(!memcmp(&cfg.nodecfg[i].faddr,&addr,sizeof(faddr_t)))
                    202:                        break;
                    203:        if(exact || i<cfg.nodecfgs)
                    204:                return(i); }
                    205: 
                    206: for(i=0;i<cfg.nodecfgs;i++)                                    /* Look for point match */
                    207:        if(cfg.nodecfg[i].faddr.point==0xffff
                    208:                && addr.zone==cfg.nodecfg[i].faddr.zone
                    209:                && addr.net==cfg.nodecfg[i].faddr.net
                    210:                && addr.node==cfg.nodecfg[i].faddr.node)
                    211:                break;
                    212: if(i<cfg.nodecfgs)
                    213:     return(i);
                    214: 
                    215: for(i=0;i<cfg.nodecfgs;i++)                                    /* Look for node match */
                    216:        if(cfg.nodecfg[i].faddr.node==0xffff
                    217:                && addr.zone==cfg.nodecfg[i].faddr.zone
                    218:                && addr.net==cfg.nodecfg[i].faddr.net)
                    219:                break;
                    220: if(i<cfg.nodecfgs)
                    221:     return(i);
                    222: 
                    223: for(i=0;i<cfg.nodecfgs;i++)                                    /* Look for net match */
                    224:        if(cfg.nodecfg[i].faddr.net==0xffff
                    225:                && addr.zone==cfg.nodecfg[i].faddr.zone)
                    226:                break;
                    227: if(i<cfg.nodecfgs)
                    228:        return(i);
                    229: 
                    230: for(i=0;i<cfg.nodecfgs;i++)                                    /* Look for total wild */
                    231:        if(cfg.nodecfg[i].faddr.zone==0xffff)
                    232:         break;
                    233: return(i);
                    234: }
                    235: /****************************************************************************/
                    236: /* Returns 32-crc of string (not counting terminating NULL)                            */
                    237: /****************************************************************************/
                    238: ulong crc32(char *str)
                    239: {
                    240:        int i=0;
                    241:        ulong crc=0xffffffffUL;
                    242: 
                    243:        while(str[i])
                    244:                crc=ucrc32(str[i++],crc);
                    245:        crc=~crc;
                    246:        return(crc);
                    247: }
                    248: 
                    249: void read_cfg()
                    250: {
                    251:        uchar str[1025],tmp[512],*p,*tp;
                    252:        short attr;
                    253:        int i,j,file;
                    254:        FILE *stream;
                    255:        faddr_t addr,route_addr;
                    256: 
                    257: 
                    258: /****** READ IN SBBSECHO.CFG FILE *******/
                    259: 
                    260: printf("\n\nReading %s\n",cfg.cfgfile);
                    261: if((stream=fnopen(&file,cfg.cfgfile,O_RDONLY))==NULL) {
                    262:     printf("Unable to open %s for read.\n",cfg.cfgfile);
                    263:     exit(1); }
                    264: 
                    265: cfg.maxpktsize=DFLT_PKT_SIZE;
                    266: cfg.maxbdlsize=DFLT_BDL_SIZE;
                    267: cfg.badecho=-1;
                    268: cfg.log=LOG_DEFAULTS;
                    269: 
                    270: while(1) {
                    271:     if(!fgets(str,256,stream))
                    272:         break;
                    273:     truncsp(str);
                    274:     p=str;
                    275:     while(*p && *p<=SP) p++;
                    276:     if(*p==';')
                    277:         continue;
                    278:     sprintf(tmp,"%-.25s",p);
                    279:     tp=strchr(tmp,SP);
                    280:     if(tp)
                    281:         *tp=0;                              /* Chop off at space */
                    282:     strupr(tmp);                            /* Convert code to uppercase */
                    283:     while(*p>SP) p++;                       /* Skip code */
                    284:     while(*p && *p<=SP) p++;                /* Skip white space */
                    285: 
                    286:     if(!strcmp(tmp,"PACKER")) {             /* Archive Definition */
                    287:                if((cfg.arcdef=(arcdef_t *)REALLOC(cfg.arcdef
                    288:             ,sizeof(arcdef_t)*(cfg.arcdefs+1)))==NULL) {
                    289:                        printf("\nError allocating %u bytes of memory for arcdef #%u.\n"
                    290:                 ,sizeof(arcdef_t)*(cfg.arcdefs+1),cfg.arcdefs+1);
                    291:             exit(1); }
                    292:         sprintf(cfg.arcdef[cfg.arcdefs].name,"%-.25s",p);
                    293:         tp=cfg.arcdef[cfg.arcdefs].name;
                    294:         while(*tp && *tp>SP) tp++;
                    295:         *tp=0;
                    296:         while(*p && *p>SP) p++;
                    297:         while(*p && *p<=SP) p++;
                    298:         cfg.arcdef[cfg.arcdefs].byteloc=atoi(p);
                    299:         while(*p && *p>SP) p++;
                    300:         while(*p && *p<=SP) p++;
                    301:         sprintf(cfg.arcdef[cfg.arcdefs].hexid,"%-.25s",p);
                    302:         tp=cfg.arcdef[cfg.arcdefs].hexid;
                    303:         while(*tp && *tp>SP) tp++;
                    304:         *tp=0;
                    305:         while(fgets(str,256,stream) && strnicmp(str,"END",3)) {
                    306:             p=str;
                    307:             while(*p && *p<=SP) p++;
                    308:             if(!strnicmp(p,"PACK ",5)) {
                    309:                 p+=5;
                    310:                 while(*p && *p<=SP) p++;
                    311:                 sprintf(cfg.arcdef[cfg.arcdefs].pack,"%-.80s",p);
                    312:                 truncsp(cfg.arcdef[cfg.arcdefs].pack);
                    313:                 continue; }
                    314:             if(!strnicmp(p,"UNPACK ",7)) {
                    315:                 p+=7;
                    316:                 while(*p && *p<=SP) p++;
                    317:                 sprintf(cfg.arcdef[cfg.arcdefs].unpack,"%-.80s",p);
                    318:                 truncsp(cfg.arcdef[cfg.arcdefs].unpack); } }
                    319:         ++cfg.arcdefs;
                    320:         continue; }
                    321: 
                    322:        if(!strcmp(tmp,"REGNUM"))
                    323:                continue;
                    324: 
                    325:        if(!strcmp(tmp,"NOTIFY")) {
                    326:                cfg.notify=atoi(cleanstr(p));
                    327:                continue; }
                    328: 
                    329:        if(!strcmp(tmp,"LOG")) {
                    330:                cleanstr(p);
                    331:                if(!stricmp(p,"ALL"))
                    332:                        cfg.log=0xffffffffUL;
                    333:                else if(!stricmp(p,"DEFAULT"))
                    334:                        cfg.log=LOG_DEFAULTS;
                    335:                else if(!stricmp(p,"NONE"))
                    336:                        cfg.log=0L;
                    337:                else
                    338:                        cfg.log=strtol(cleanstr(p),0,16);
                    339:                continue; }
                    340: 
                    341:     if(!strcmp(tmp,"NOSWAP")) {
                    342:         node_swap=0;
                    343:         continue; }
                    344: 
                    345:        if(!strcmp(tmp,"SECURE_ECHOMAIL")) {
                    346:                misc|=SECURE;
                    347:                continue; }
                    348: 
                    349:     if(!strcmp(tmp,"CHECKMEM")) {
                    350:         misc|=CHECKMEM;
                    351:         continue; }
                    352: 
                    353:     if(!strcmp(tmp,"STORE_SEENBY")) {
                    354:         misc|=STORE_SEENBY;
                    355:         continue; }
                    356: 
                    357:     if(!strcmp(tmp,"STORE_PATH")) {
                    358:         misc|=STORE_PATH;
                    359:         continue; }
                    360: 
                    361:     if(!strcmp(tmp,"STORE_KLUDGE")) {
                    362:         misc|=STORE_KLUDGE;
                    363:         continue; }
                    364: 
                    365:     if(!strcmp(tmp,"FUZZY_ZONE")) {
                    366:         misc|=FUZZY_ZONE;
                    367:         continue; }
                    368: 
                    369:        if(!strcmp(tmp,"FAST_OPEN")) {
                    370:                continue; }
                    371: 
                    372:     if(!strcmp(tmp,"FLO_MAILER")) {
                    373:         misc|=FLO_MAILER;
                    374:         continue; }
                    375: 
                    376:        if(!strcmp(tmp,"ELIST_ONLY")) {
                    377:                misc|=ELIST_ONLY;
                    378:                continue; }
                    379: 
                    380:        if(!strcmp(tmp,"KILL_EMPTY")) {
                    381:                misc|=KILL_EMPTY_MAIL;
                    382:                continue; }
                    383: 
                    384:     if(!strcmp(tmp,"AREAFILE")) {
                    385:         sprintf(cfg.areafile,"%-.80s",cleanstr(p));
                    386:         continue; }
                    387: 
                    388:     if(!strcmp(tmp,"LOGFILE")) {
                    389:         sprintf(cfg.logfile,"%-.80s",cleanstr(p));
                    390:         continue; }
                    391: 
                    392:     if(!strcmp(tmp,"INBOUND")) {            /* Inbound directory */
                    393:         sprintf(cfg.inbound,"%-.80s",cleanstr(p));
                    394:         if(cfg.inbound[strlen(cfg.inbound)-1]!='\\')
                    395:             strcat(cfg.inbound,"\\");
                    396:         continue; }
                    397: 
                    398:     if(!strcmp(tmp,"SECURE_INBOUND")) {     /* Secure Inbound directory */
                    399:         sprintf(cfg.secure,"%-.80s",cleanstr(p));
                    400:         if(cfg.secure[strlen(cfg.secure)-1]!='\\')
                    401:             strcat(cfg.secure,"\\");
                    402:         continue; }
                    403: 
                    404:     if(!strcmp(tmp,"OUTBOUND")) {           /* Outbound directory */
                    405:         sprintf(cfg.outbound,"%-.80s",cleanstr(p));
                    406:         if(cfg.outbound[strlen(cfg.outbound)-1]!='\\')
                    407:             strcat(cfg.outbound,"\\");
                    408:         continue; }
                    409: 
                    410:     if(!strcmp(tmp,"ARCSIZE")) {            /* Maximum bundle size */
                    411:         cfg.maxbdlsize=atol(p);
                    412:         continue; }
                    413: 
                    414:     if(!strcmp(tmp,"PKTSIZE")) {            /* Maximum packet size */
                    415:         cfg.maxpktsize=atol(p);
                    416:         continue; }
                    417: 
                    418:     if(!strcmp(tmp,"USEPACKER")) {          /* Which packer to use */
                    419:                if(!*p)
                    420:                        continue;
                    421:                strcpy(str,p);
                    422:                p=str;
                    423:                while(*p && *p>SP) p++;
                    424:                if(!*p)
                    425:                        continue;
                    426:                *p=0;
                    427:                p++;
                    428:                for(i=0;i<cfg.arcdefs;i++)
                    429:                        if(!strnicmp(cfg.arcdef[i].name,str
                    430:                                ,strlen(cfg.arcdef[i].name)))
                    431:                                break;
                    432:                if(i==cfg.arcdefs)                              /* i = number of arcdef til done */
                    433:                        i=0xffff;                                       /* Uncompressed type if not found */
                    434:                while(*p) {
                    435:                        while(*p && *p<=SP) p++;
                    436:                        if(!*p)
                    437:                                break;
                    438:                        addr=atofaddr(p);
                    439:                        while(*p && *p>SP) p++;
                    440:                        j=matchnode(addr,1);
                    441:                        if(j==cfg.nodecfgs) {
                    442:                                cfg.nodecfgs++;
                    443:                                if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    444:                                        ,sizeof(nodecfg_t)*(j+1)))==NULL) {
                    445:                                        printf("\nError allocating memory for nodecfg #%u.\n"
                    446:                                                ,j+1);
                    447:                                        exit(1); }
                    448:                                memset(&cfg.nodecfg[j],0,sizeof(nodecfg_t));
                    449:                                cfg.nodecfg[j].faddr=addr; }
                    450:                        cfg.nodecfg[j].arctype=i; } }
                    451: 
                    452:     if(!strcmp(tmp,"PKTPWD")) {         /* Packet Password */
                    453:         if(!*p)
                    454:             continue;
                    455:         addr=atofaddr(p);
                    456:         while(*p && *p>SP) p++;         /* Skip address */
                    457:         while(*p && *p<=SP) p++;        /* Find beginning of password */
                    458:                j=matchnode(addr,1);
                    459:         if(j==cfg.nodecfgs) {
                    460:             cfg.nodecfgs++;
                    461:             if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    462:                 ,sizeof(nodecfg_t)*(j+1)))==NULL) {
                    463:                                printf("\nError allocating memory for nodecfg #%u.\n"
                    464:                     ,j+1);
                    465:                 exit(1); }
                    466:             memset(&cfg.nodecfg[j],0,sizeof(nodecfg_t));
                    467:             cfg.nodecfg[j].faddr=addr; }
                    468:         sprintf(cfg.nodecfg[j].pktpwd,"%.8s",p); }
                    469: 
                    470:        if(!strcmp(tmp,"PKTTYPE")) {            /* Packet Type to Use */
                    471:                if(!*p)
                    472:                        continue;
                    473:                strcpy(str,p);
                    474:                p=str;
                    475:                while(*p && *p>SP) p++;
                    476:                *p=0;
                    477:                p++;
                    478:                while(*p) {
                    479:                        while(*p && *p<=SP) p++;
                    480:                        if(!*p)
                    481:                                break;
                    482:                        addr=atofaddr(p);
                    483:                        while(*p && *p>SP) p++;
                    484:                        j=matchnode(addr,1);
                    485:                        if(j==cfg.nodecfgs) {
                    486:                                cfg.nodecfgs++;
                    487:                                if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    488:                                        ,sizeof(nodecfg_t)*(j+1)))==NULL) {
                    489:                                        printf("\nError allocating memory for nodecfg #%u.\n"
                    490:                                                ,j+1);
                    491:                                        exit(1); }
                    492:                                memset(&cfg.nodecfg[j],0,sizeof(nodecfg_t));
                    493:                                cfg.nodecfg[j].faddr=addr; }
                    494:                        if(!strcmp(str,"2+"))
                    495:                                cfg.nodecfg[j].pkt_type=PKT_TWO_PLUS;
                    496:                        else if(!strcmp(str,"2.2"))
                    497:                                cfg.nodecfg[j].pkt_type=PKT_TWO_TWO;
                    498:                        else if(!strcmp(str,"2"))
                    499:                                cfg.nodecfg[j].pkt_type=PKT_TWO; } }
                    500: 
                    501:        if(!strcmp(tmp,"SEND_NOTIFY")) {    /* Nodes to send notify lists to */
                    502:                while(*p) {
                    503:             while(*p && *p<=SP) p++;
                    504:             if(!*p)
                    505:                 break;
                    506:             addr=atofaddr(p);
                    507:             while(*p && *p>SP) p++;
                    508:                        j=matchnode(addr,1);
                    509:             if(j==cfg.nodecfgs) {
                    510:                 cfg.nodecfgs++;
                    511:                 if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    512:                     ,sizeof(nodecfg_t)*(j+1)))==NULL) {
                    513:                                        printf("\nError allocating memory for nodecfg #%u.\n"
                    514:                         ,j+1);
                    515:                     exit(1); }
                    516:                 memset(&cfg.nodecfg[j],0,sizeof(nodecfg_t));
                    517:                 cfg.nodecfg[j].faddr=addr; }
                    518:                        cfg.nodecfg[j].attr|=SEND_NOTIFY; } }
                    519: 
                    520:     if(!strcmp(tmp,"PASSIVE")
                    521:         || !strcmp(tmp,"HOLD")
                    522:         || !strcmp(tmp,"CRASH")
                    523:         || !strcmp(tmp,"DIRECT")) {         /* Set node attributes */
                    524:         if(!strcmp(tmp,"PASSIVE"))
                    525:             attr=ATTR_PASSIVE;
                    526:         else if(!strcmp(tmp,"CRASH"))
                    527:             attr=ATTR_CRASH;
                    528:         else if(!strcmp(tmp,"HOLD"))
                    529:             attr=ATTR_HOLD;
                    530:         else if(!strcmp(tmp,"DIRECT"))
                    531:             attr=ATTR_DIRECT;
                    532:         while(*p) {
                    533:             while(*p && *p<=SP) p++;
                    534:             if(!*p)
                    535:                 break;
                    536:             addr=atofaddr(p);
                    537:             while(*p && *p>SP) p++;
                    538:                        j=matchnode(addr,1);
                    539:             if(j==cfg.nodecfgs) {
                    540:                 cfg.nodecfgs++;
                    541:                 if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    542:                     ,sizeof(nodecfg_t)*(j+1)))==NULL) {
                    543:                                        printf("\nError allocating memory for nodecfg #%u.\n"
                    544:                         ,j+1);
                    545:                     exit(1); }
                    546:                 memset(&cfg.nodecfg[j],0,sizeof(nodecfg_t));
                    547:                 cfg.nodecfg[j].faddr=addr; }
                    548:             cfg.nodecfg[j].attr|=attr; } }
                    549: 
                    550:        if(!strcmp(tmp,"ROUTE_TO")) {
                    551:                while(*p && *p<=SP) p++;
                    552:                if(*p) {
                    553:                        route_addr=atofaddr(p);
                    554:                        while(*p && *p>SP) p++; }
                    555:         while(*p) {
                    556:             while(*p && *p<=SP) p++;
                    557:             if(!*p)
                    558:                 break;
                    559:             addr=atofaddr(p);
                    560:             while(*p && *p>SP) p++;
                    561:                        j=matchnode(addr,1);
                    562:             if(j==cfg.nodecfgs) {
                    563:                 cfg.nodecfgs++;
                    564:                 if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    565:                     ,sizeof(nodecfg_t)*(j+1)))==NULL) {
                    566:                                        printf("\nError allocating memory for nodecfg #%u.\n"
                    567:                         ,j+1);
                    568:                     exit(1); }
                    569:                 memset(&cfg.nodecfg[j],0,sizeof(nodecfg_t));
                    570:                 cfg.nodecfg[j].faddr=addr; }
                    571:                        cfg.nodecfg[j].route=route_addr; } }
                    572: 
                    573:     if(!strcmp(tmp,"AREAFIX")) {            /* Areafix stuff here */
                    574:                if(!*p)
                    575:                        continue;
                    576:                addr=atofaddr(p);
                    577:                i=matchnode(addr,1);
                    578:                if(i==cfg.nodecfgs) {
                    579:                        cfg.nodecfgs++;
                    580:                        if((cfg.nodecfg=(nodecfg_t *)REALLOC(cfg.nodecfg
                    581:                                ,sizeof(nodecfg_t)*(i+1)))==NULL) {
                    582:                                printf("\nError allocating memory for nodecfg #%u.\n"
                    583:                                        ,i+1);
                    584:                                exit(1); }
                    585:                        memset(&cfg.nodecfg[i],0,sizeof(nodecfg_t));
                    586:                        cfg.nodecfg[i].faddr=addr; }
                    587:                cfg.nodecfg[i].flag=NULL;
                    588:                while(*p && *p>SP) p++;                 /* Get to the end of the address */
                    589:                while(*p && *p<=SP) p++;                /* Skip over whitespace chars */
                    590:                tp=p;
                    591:                while(*p && *p>SP) p++;                 /* Find end of password         */
                    592:                *p=0;                                                   /* and terminate the string */
                    593:                ++p;
                    594:                sprintf(cfg.nodecfg[i].password,"%-.25s",tp);
                    595:                while(*p && *p<=SP) p++;                /* Search for more chars */
                    596:                if(!*p)                                                 /* Nothing else there */
                    597:                        continue;
                    598:                while(*p) {
                    599:                        tp=p;
                    600:                        while(*p && *p>SP) p++;         /* Find end of this flag */
                    601:                        *p=0;                                           /* and terminate it      */
                    602:                        ++p;
                    603:                        for(j=0;j<cfg.nodecfg[i].numflags;j++)
                    604:                                if(!strnicmp(cfg.nodecfg[i].flag[j].flag,tp
                    605:                                        ,strlen(cfg.nodecfg[i].flag[j].flag)))
                    606:                                        break;
                    607:                        if(j==cfg.nodecfg[i].numflags) {
                    608:                                if((cfg.nodecfg[i].flag=
                    609:                                        (flag_t *)REALLOC(cfg.nodecfg[i].flag
                    610:                                        ,sizeof(flag_t)*(j+1)))==NULL) {
                    611:                                        printf("\nError allocating memory for nodecfg #%u "
                    612:                                                "flag #%u.\n",cfg.nodecfgs,j+1);
                    613:                                        exit(1); }
                    614:                                cfg.nodecfg[i].numflags++;
                    615:                                sprintf(cfg.nodecfg[i].flag[j].flag,"%.4s",tp); }
                    616:                        while(*p && *p<=SP) p++; } }
                    617: 
                    618:     if(!strcmp(tmp,"ECHOLIST")) {           /* Echolists go here */
                    619:                if((cfg.listcfg=(echolist_t *)REALLOC(cfg.listcfg
                    620:                        ,sizeof(echolist_t)*(cfg.listcfgs+1)))==NULL) {
                    621:                        printf("\nError allocating memory for echolist cfg #%u.\n"
                    622:                                ,cfg.listcfgs+1);
                    623:                        exit(1); }
                    624:                memset(&cfg.listcfg[cfg.listcfgs],0,sizeof(echolist_t));
                    625:                ++cfg.listcfgs;
                    626:                /* Need to forward requests? */
                    627:                if(!strnicmp(p,"FORWARD ",8) || !strnicmp(p,"HUB ",4)) {
                    628:                        if(!strnicmp(p,"HUB ",4))
                    629:                                cfg.listcfg[cfg.listcfgs-1].misc|=NOFWD;
                    630:             while(*p && *p>SP) p++;
                    631:             while(*p && *p<=SP) p++;
                    632:             if(*p)
                    633:                                cfg.listcfg[cfg.listcfgs-1].forward=atofaddr(p);
                    634:             while(*p && *p>SP) p++;
                    635:                        while(*p && *p<=SP) p++;
                    636:                        if(*p && !(cfg.listcfg[cfg.listcfgs-1].misc&NOFWD)) {
                    637:                                tp=p;
                    638:                                while(*p && *p>SP) p++;
                    639:                                *p=0;
                    640:                                ++p;
                    641:                                while(*p && *p<=SP) p++;
                    642:                                sprintf(cfg.listcfg[cfg.listcfgs-1].password,"%.71s",tp); } }
                    643:                else
                    644:                        cfg.listcfg[cfg.listcfgs-1].misc|=NOFWD;
                    645:                if(!*p)
                    646:                        continue;
                    647:                tp=p;
                    648:                while(*p && *p>SP) p++;
                    649:                *p=0;
                    650:                p++;
                    651: 
                    652:                sprintf(cfg.listcfg[cfg.listcfgs-1].listpath,"%-.128s",tp);
                    653:                cfg.listcfg[cfg.listcfgs-1].numflags=0;
                    654:                cfg.listcfg[cfg.listcfgs-1].flag=NULL;
                    655:                while(*p && *p<=SP) p++;                /* Skip over whitespace chars */
                    656:                while(*p) {
                    657:                        tp=p;
                    658:                        while(*p && *p>SP) p++;         /* Find end of this flag */
                    659:                        *p=0;                                           /* and terminate it      */
                    660:                        ++p;
                    661:                        for(j=0;j<cfg.listcfg[cfg.listcfgs-1].numflags;j++)
                    662:                                if(!strnicmp(cfg.listcfg[cfg.listcfgs-1].flag[j].flag,tp
                    663:                                        ,strlen(cfg.listcfg[cfg.listcfgs-1].flag[j].flag)))
                    664:                                        break;
                    665:                        if(j==cfg.listcfg[cfg.listcfgs-1].numflags) {
                    666:                                if((cfg.listcfg[cfg.listcfgs-1].flag=
                    667:                                        (flag_t *)REALLOC(cfg.listcfg[cfg.listcfgs-1].flag
                    668:                                        ,sizeof(flag_t)*(j+1)))==NULL) {
                    669:                                        printf("\nError allocating memory for listcfg #%u "
                    670:                                                "flag #%u.\n",cfg.listcfgs,j+1);
                    671:                                        exit(1); }
                    672:                                cfg.listcfg[cfg.listcfgs-1].numflags++;
                    673:                                sprintf(cfg.listcfg[cfg.listcfgs-1].flag[j].flag,"%.4s",tp); }
                    674:                        while(*p && *p<=SP) p++; } }
                    675: 
                    676: //    printf("Unrecognized line in SBBSECHO.CFG file.\n");
                    677: }
                    678: fclose(stream);
                    679: printf("\n");
                    680: }
                    681: 

unix.superglobalmegacorp.com

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