Annotation of sbbs/sbbs3/ars.c, revision 1.1.1.2

1.1       root        1: /* ars.c */
                      2: 
                      3: /* Synchronet Access Requirement String (ARS) functions */
                      4: 
1.1.1.2 ! root        5: /* $Id: ars.c,v 1.8 2004/10/17 06:46:31 rswindell Exp $ */
1.1       root        6: 
                      7: /****************************************************************************
                      8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                     10:  *                                                                                                                                                     *
1.1.1.2 ! root       11:  * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html         *
1.1       root       12:  *                                                                                                                                                     *
                     13:  * This program is free software; you can redistribute it and/or                       *
                     14:  * modify it under the terms of the GNU General Public License                         *
                     15:  * as published by the Free Software Foundation; either version 2                      *
                     16:  * of the License, or (at your option) any later version.                                      *
                     17:  * See the GNU General Public License for more details: gpl.txt or                     *
                     18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     19:  *                                                                                                                                                     *
                     20:  * Anonymous FTP access to the most recent released source is available at     *
                     21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     22:  *                                                                                                                                                     *
                     23:  * Anonymous CVS access to the development source and modification history     *
                     24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     26:  *     (just hit return, no password is necessary)                                                     *
                     27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     28:  *                                                                                                                                                     *
                     29:  * For Synchronet coding style and modification guidelines, see                                *
                     30:  * http://www.synchro.net/source.html                                                                          *
                     31:  *                                                                                                                                                     *
                     32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     33:  * format) via e-mail to [email protected]                                                                      *
                     34:  *                                                                                                                                                     *
                     35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     36:  ****************************************************************************/
                     37: 
                     38: #include "sbbs.h"
                     39: 
1.1.1.2 ! root       40: const uchar* nular=""; // AR_NULL
        !            41: 
1.1       root       42: /* Converts ASCII ARS string into binary ARS buffer */
                     43: 
                     44: #ifdef __BORLANDC__    /* Eliminate warning when buildling Baja */
                     45: #pragma argsused
                     46: #endif
                     47: uchar* arstr(ushort* count, char* str, scfg_t* cfg)
                     48: {
                     49:        char *p;
                     50:        uchar ar[256],*ar_buf;
                     51:        uint i,j,n,artype=AR_LEVEL,not=0,equal=0;
                     52: 
                     53:        for(i=j=0;str[i];i++) {
1.1.1.2 ! root       54:                if(str[i]==' ')
1.1       root       55:                        continue;
                     56: 
                     57:                if(str[i]=='(') {
                     58:                        if(not)
                     59:                                ar[j++]=AR_NOT;
                     60:                        not=equal=0;
                     61:                        ar[j++]=AR_BEGNEST;
                     62:                        continue; }
                     63: 
                     64:                if(str[i]==')') {
                     65:                        ar[j++]=AR_ENDNEST;
                     66:                        continue; }
                     67: 
                     68:                if(str[i]=='|') {
                     69:                        ar[j++]=AR_OR;
                     70:                        continue; }
                     71:     
                     72:                if(str[i]=='!') {
                     73:                        not=1;
                     74:                        continue; }
                     75: 
                     76:                if(str[i]=='=') {
                     77:                        equal=1;
                     78:                        continue; }
                     79: 
                     80:                if(str[i]=='&')
                     81:                        continue;
                     82: 
                     83:                if(isalpha(str[i])) {
1.1.1.2 ! root       84:                        if(!strnicmp(str+i,"OR",2)) {
1.1       root       85:                                ar[j++]=AR_OR;
                     86:                                i++;
                     87:                                continue; }
                     88: 
1.1.1.2 ! root       89:                        if(!strnicmp(str+i,"AND",3)) {    /* AND is ignored */
1.1       root       90:                                i+=2;
                     91:                                continue; }
                     92: 
1.1.1.2 ! root       93:                        if(!strnicmp(str+i,"NOT",3)) {
1.1       root       94:                                not=1;
                     95:                                i+=2;
                     96:                                continue; }
                     97: 
1.1.1.2 ! root       98:                        if(!strnicmp(str+i,"EQUAL TO",8)) {
1.1       root       99:                                equal=1;
                    100:                                i+=7;
                    101:                                continue; }
                    102: 
1.1.1.2 ! root      103:                        if(!strnicmp(str+i,"EQUAL",5)) {
1.1       root      104:                                equal=1;
                    105:                                i+=4;
                    106:                                continue; }
                    107: 
1.1.1.2 ! root      108:                        if(!strnicmp(str+i,"EQUALS",6)) {
1.1       root      109:                                equal=1;
                    110:                                i+=5;
                    111:                                continue; } }
                    112: 
                    113:                if(str[i]=='$') {
1.1.1.2 ! root      114:                        switch(toupper(str[i+1])) {
1.1       root      115:                                case 'A':
                    116:                                        artype=AR_AGE;
                    117:                                        break;
                    118:                                case 'B':
                    119:                                        artype=AR_BPS;
                    120:                                        break;
                    121:                                case 'C':
                    122:                                        artype=AR_CREDIT;
                    123:                                        break;
                    124:                                case 'D':
                    125:                                        artype=AR_UDFR;
                    126:                                        break;
                    127:                                case 'E':
                    128:                                        artype=AR_EXPIRE;
                    129:                                        break;
                    130:                                case 'F':
                    131:                                        artype=AR_FLAG1;
                    132:                                        break;
                    133:                                case 'G':
                    134:                                        artype=AR_LOCAL;
                    135:                                        if(not)
                    136:                                                ar[j++]=AR_NOT;
                    137:                                        not=0;
                    138:                                        ar[j++]=artype;
                    139:                                        break;
                    140:                                case 'H':
                    141:                                        artype=AR_SUB;
                    142:                                        break;
                    143:                                case 'I':
                    144:                                        artype=AR_LIB;
                    145:                                        break;
                    146:                                case 'J':
                    147:                                        artype=AR_DIR;
                    148:                                        break;
                    149:                                case 'K':
                    150:                                        artype=AR_UDR;
                    151:                                        break;
                    152:                                case 'L':
                    153:                                        artype=AR_LEVEL;
                    154:                                        break;
                    155:                                case 'M':
                    156:                                        artype=AR_GROUP;
                    157:                                        break;
                    158:                                case 'N':
                    159:                                        artype=AR_NODE;
                    160:                                        break;
                    161:                                case 'O':
                    162:                                        artype=AR_TUSED;
                    163:                                        break;
                    164:                                case 'P':
                    165:                                        artype=AR_PCR;
                    166:                                        break;
                    167:                                case 'Q':
                    168:                                        artype=AR_RANDOM;
                    169:                                        break;
                    170:                                case 'R':
                    171:                                        artype=AR_TLEFT;
                    172:                                        break;
                    173:                                case 'S':
                    174:                                        artype=AR_SEX;
                    175:                                        break;
                    176:                                case 'T':
                    177:                                        artype=AR_TIME;
                    178:                                        break;
                    179:                                case 'U':
                    180:                                        artype=AR_USER;
                    181:                                        break;
                    182:                                case 'V':
                    183:                                        artype=AR_LOGONS;
                    184:                                        break;
                    185:                                case 'W':
                    186:                                        artype=AR_DAY;
                    187:                                        break;
                    188:                                case 'X':
                    189:                                        artype=AR_EXEMPT;
                    190:                                        break;
                    191:                                case 'Y':   /* Days since last on */
                    192:                                        artype=AR_LASTON;
                    193:                                        break;
                    194:                                case 'Z':
                    195:                                        artype=AR_REST;
                    196:                                        break;
                    197:                                case '[':
                    198:                                        artype=AR_ANSI;
                    199:                                        if(not)
                    200:                                                ar[j++]=AR_NOT;
                    201:                                        not=0;
                    202:                                        ar[j++]=artype;
                    203:                                        break;
                    204:                                case '0':
                    205:                                        artype=AR_NULL;
                    206:                                        break;
                    207:                                case '*':
                    208:                                        artype=AR_RIP;
                    209:                                        if(not)
                    210:                                                ar[j++]=AR_NOT;
                    211:                                        not=0;
                    212:                                        ar[j++]=artype;
                    213:                                        break;
                    214: 
                    215:                                }
                    216:                        i++;
                    217:                        continue; }
                    218: 
                    219:                if(isalpha(str[i])) {
                    220:                        n=i;
1.1.1.2 ! root      221:                        if(!strnicmp(str+i,"AGE",3)) {
1.1       root      222:                                artype=AR_AGE;
                    223:                                i+=2; }
1.1.1.2 ! root      224:                        else if(!strnicmp(str+i,"BPS",3)) {
1.1       root      225:                                artype=AR_BPS;
                    226:                                i+=2; }
1.1.1.2 ! root      227:                        else if(!strnicmp(str+i,"PCR",3)) {
1.1       root      228:                                artype=AR_PCR;
                    229:                                i+=2; }
1.1.1.2 ! root      230:                        else if(!strnicmp(str+i,"SEX",3)) {
1.1       root      231:                                artype=AR_SEX;
                    232:                                i+=2; }
1.1.1.2 ! root      233:                        else if(!strnicmp(str+i,"UDR",3)) {
1.1       root      234:                                artype=AR_UDR;
                    235:                                i+=2; }
1.1.1.2 ! root      236:                        else if(!strnicmp(str+i,"DAY",3)) {
1.1       root      237:                                artype=AR_DAY;
                    238:                                i+=2; }
1.1.1.2 ! root      239:                        else if(!strnicmp(str+i,"RIP",3)) {
1.1       root      240:                                artype=AR_RIP;
                    241:                                if(not)
                    242:                                        ar[j++]=AR_NOT;
                    243:                                not=0;
                    244:                                ar[j++]=artype;
                    245:                                i+=2; }
1.1.1.2 ! root      246:                        else if(!strnicmp(str+i,"WIP",3)) {
1.1       root      247:                                artype=AR_WIP;
                    248:                                if(not)
                    249:                                        ar[j++]=AR_NOT;
                    250:                                not=0;
                    251:                                ar[j++]=artype;
                    252:                                i+=2; }
1.1.1.2 ! root      253:                        else if(!strnicmp(str+i,"OS2",3)) {
1.1       root      254:                                artype=AR_OS2;
                    255:                                if(not)
                    256:                                        ar[j++]=AR_NOT;
                    257:                                not=0;
                    258:                                ar[j++]=artype;
                    259:                                i+=2; }
1.1.1.2 ! root      260:                        else if(!strnicmp(str+i,"DOS",3)) {
1.1       root      261:                                artype=AR_DOS;
                    262:                                if(not)
                    263:                                        ar[j++]=AR_NOT;
                    264:                                not=0;
                    265:                                ar[j++]=artype;
                    266:                                i+=2; }
1.1.1.2 ! root      267:                        else if(!strnicmp(str+i,"WIN32",5)) {
1.1       root      268:                                artype=AR_WIN32;
                    269:                                if(not)
                    270:                                        ar[j++]=AR_NOT;
                    271:                                not=0;
                    272:                                ar[j++]=artype;
                    273:                                i+=2; }
1.1.1.2 ! root      274:                        else if(!strnicmp(str+i,"UNIX",4)) {
1.1       root      275:                                artype=AR_UNIX;
                    276:                                if(not)
                    277:                                        ar[j++]=AR_NOT;
                    278:                                not=0;
                    279:                                ar[j++]=artype;
                    280:                                i+=2; }
1.1.1.2 ! root      281:                        else if(!strnicmp(str+i,"LINUX",5)) {
1.1       root      282:                                artype=AR_LINUX;
                    283:                                if(not)
                    284:                                        ar[j++]=AR_NOT;
                    285:                                not=0;
                    286:                                ar[j++]=artype;
                    287:                                i+=2; }
1.1.1.2 ! root      288:                        else if(!strnicmp(str+i,"PROT",4)) {
        !           289:                                artype=AR_PROT;
        !           290:                                if(not)
        !           291:                                        ar[j++]=AR_NOT;
        !           292:                                not=0;
        !           293:                                ar[j++]=artype;
        !           294:                                i+=2; }
        !           295:                        else if(!strnicmp(str+i,"SUBCODE",7)) {
1.1       root      296:                                artype=AR_SUBCODE;
                    297:                                i+=6; }
1.1.1.2 ! root      298:                        else if(!strnicmp(str+i,"SUB",3)) {
1.1       root      299:                                artype=AR_SUB;
                    300:                                i+=2; }
1.1.1.2 ! root      301:                        else if(!strnicmp(str+i,"LIB",3)) {
1.1       root      302:                                artype=AR_LIB;
                    303:                                i+=2; }
1.1.1.2 ! root      304:                        else if(!strnicmp(str+i,"DIRCODE",7)) {
1.1       root      305:                                artype=AR_DIRCODE;
                    306:                                i+=6; }
1.1.1.2 ! root      307:                        else if(!strnicmp(str+i,"DIR",3)) {
1.1       root      308:                                artype=AR_DIR;
                    309:                                i+=2; }
1.1.1.2 ! root      310:                        else if(!strnicmp(str+i,"ANSI",4)) {
1.1       root      311:                                artype=AR_ANSI;
                    312:                                if(not)
                    313:                                        ar[j++]=AR_NOT;
                    314:                                not=0;
                    315:                                ar[j++]=artype;
                    316:                                i+=3; }
1.1.1.2 ! root      317:                        else if(!strnicmp(str+i,"UDFR",4)) {
1.1       root      318:                                artype=AR_UDFR;
                    319:                                i+=3; }
1.1.1.2 ! root      320:                        else if(!strnicmp(str+i,"FLAG",4)) {
1.1       root      321:                                artype=AR_FLAG1;
                    322:                                i+=3; }
1.1.1.2 ! root      323:                        else if(!strnicmp(str+i,"NODE",4)) {
1.1       root      324:                                artype=AR_NODE;
                    325:                                i+=3; }
1.1.1.2 ! root      326:                        else if(!strnicmp(str+i,"NULL",4)) {
1.1       root      327:                                artype=AR_NULL;
                    328:                                i+=3; }
1.1.1.2 ! root      329:                        else if(!strnicmp(str+i,"USER",4)) {
1.1       root      330:                                artype=AR_USER;
                    331:                                i+=3; }
1.1.1.2 ! root      332:                        else if(!strnicmp(str+i,"TIME",4)) {
1.1       root      333:                                artype=AR_TIME;
                    334:                                i+=3; }
1.1.1.2 ! root      335:                        else if(!strnicmp(str+i,"REST",4)) {
1.1       root      336:                                artype=AR_REST;
                    337:                                i+=3; }
1.1.1.2 ! root      338:                        else if(!strnicmp(str+i,"LEVEL",5)) {
1.1       root      339:                                artype=AR_LEVEL;
                    340:                                i+=4; }
1.1.1.2 ! root      341:                        else if(!strnicmp(str+i,"TLEFT",5)) {
1.1       root      342:                                artype=AR_TLEFT;
                    343:                                i+=4; }
1.1.1.2 ! root      344:                        else if(!strnicmp(str+i,"TUSED",5)) {
1.1       root      345:                                artype=AR_TUSED;
                    346:                                i+=4; }
1.1.1.2 ! root      347:                        else if(!strnicmp(str+i,"LOCAL",5)) {
1.1       root      348:                                artype=AR_LOCAL;
                    349:                                if(not)
                    350:                                        ar[j++]=AR_NOT;
                    351:                                not=0;
                    352:                                ar[j++]=artype;
                    353:                                i+=4; }
1.1.1.2 ! root      354:                        else if(!strnicmp(str+i,"GROUP",5)) {
1.1       root      355:                                artype=AR_GROUP;
                    356:                                i+=4; }
1.1.1.2 ! root      357:                        else if(!strnicmp(str+i,"EXPIRE",6)) {
1.1       root      358:                                artype=AR_EXPIRE;
                    359:                                i+=5; }
1.1.1.2 ! root      360:                        else if(!strnicmp(str+i,"EXPERT",6)) {
1.1       root      361:                                artype=AR_EXPERT;
                    362:                                if(not)
                    363:                                        ar[j++]=AR_NOT;
                    364:                                not=0;
                    365:                                ar[j++]=artype;
                    366:                                i+=5; }
1.1.1.2 ! root      367:                        else if(!strnicmp(str+i,"SYSOP",5)) {
1.1       root      368:                                artype=AR_SYSOP;
                    369:                                if(not)
                    370:                                        ar[j++]=AR_NOT;
                    371:                                not=0;
                    372:                                ar[j++]=artype;
                    373:                                i+=4; }
1.1.1.2 ! root      374:                        else if(!strnicmp(str+i,"QUIET",5)) {
1.1       root      375:                                artype=AR_QUIET;
                    376:                                if(not)
                    377:                                        ar[j++]=AR_NOT;
                    378:                                not=0;
                    379:                                ar[j++]=artype;
                    380:                                i+=4; }
1.1.1.2 ! root      381:                        else if(!strnicmp(str+i,"EXEMPT",6)) {
1.1       root      382:                                artype=AR_EXEMPT;
                    383:                                i+=5; }
1.1.1.2 ! root      384:                        else if(!strnicmp(str+i,"RANDOM",6)) {
1.1       root      385:                                artype=AR_RANDOM;
                    386:                                i+=5; }
1.1.1.2 ! root      387:                        else if(!strnicmp(str+i,"LASTON",6)) {
1.1       root      388:                                artype=AR_LASTON;
                    389:                                i+=5; }
1.1.1.2 ! root      390:                        else if(!strnicmp(str+i,"LOGONS",6)) {
1.1       root      391:                                artype=AR_LOGONS;
                    392:                                i+=5; }
1.1.1.2 ! root      393:                        else if(!strnicmp(str+i,"CREDIT",6)) {
1.1       root      394:                                artype=AR_CREDIT;
                    395:                                i+=5; }
1.1.1.2 ! root      396:                        else if(!strnicmp(str+i,"MAIN_CMDS",9)) {
1.1       root      397:                                artype=AR_MAIN_CMDS;
                    398:                                i+=8; }
1.1.1.2 ! root      399:                        else if(!strnicmp(str+i,"FILE_CMDS",9)) {
1.1       root      400:                                artype=AR_FILE_CMDS;
                    401:                                i+=8; }
1.1.1.2 ! root      402:                        else if(!strnicmp(str+i,"SHELL",5)) {
        !           403:                                artype=AR_SHELL;
        !           404:                                i+=4; }
1.1       root      405:                        if(n!=i)            /* one of the above */
1.1.1.2 ! root      406:                                continue; 
        !           407:                }
1.1       root      408: 
                    409:                if(not)
                    410:                        ar[j++]=AR_NOT;
                    411:                if(equal)
                    412:                        ar[j++]=AR_EQUAL;
                    413:                not=equal=0;
                    414: 
                    415:                if(artype==AR_FLAG1 && isdigit(str[i])) {   /* flag set specified */
                    416:                        switch(str[i]) {
                    417:                                case '2':
                    418:                                        artype=AR_FLAG2;
                    419:                                        break;
                    420:                                case '3':
                    421:                                        artype=AR_FLAG3;
                    422:                                        break;
                    423:                                case '4':
                    424:                                        artype=AR_FLAG4;
                    425:                                        break; }
                    426:                        continue; }
                    427: 
                    428:                if(artype==AR_SUB && !isdigit(str[i]))
                    429:                        artype=AR_SUBCODE;
                    430:                if(artype==AR_DIR && !isdigit(str[i]))
                    431:                        artype=AR_DIRCODE;
                    432: 
                    433:                ar[j++]=artype;
                    434:                if(isdigit(str[i])) {
                    435:                        if(artype==AR_TIME) {
                    436:                                n=atoi(str+i)*60;
                    437:                                p=strchr(str+i,':');
                    438:                                if(p)
                    439:                                        n+=atoi(p+1);
                    440:                                *((short *)(ar+j))=n;
                    441:                                j+=2;
                    442:                                while(isdigit(str[i+1]) || str[i+1]==':') i++;
                    443:                                continue; }
                    444:                        n=atoi(str+i);
                    445:                        switch(artype) {
                    446:                                case AR_DAY:
                    447:                                        if(n>6)     /* not past saturday */
                    448:                                                n=6;
                    449:                                case AR_AGE:    /* byte operands */
                    450:                                case AR_PCR:
                    451:                                case AR_UDR:
                    452:                                case AR_UDFR:
                    453:                                case AR_NODE:
                    454:                                case AR_LEVEL:
                    455:                                case AR_TLEFT:
                    456:                                case AR_TUSED:
                    457:                                        ar[j++]=n;
                    458:                                        break;
                    459:                                case AR_BPS:    /* int operands */
                    460:                                        if(n<300)
                    461:                                                n*=100;
                    462:                                case AR_MAIN_CMDS:
                    463:                                case AR_FILE_CMDS:
                    464:                                case AR_EXPIRE:
                    465:                                case AR_CREDIT:
                    466:                                case AR_USER:
                    467:                                case AR_RANDOM:
                    468:                                case AR_LASTON:
                    469:                                case AR_LOGONS:
                    470:                                        *((short *)(ar+j))=n;
                    471:                                        j+=2;
                    472:                                        break;
                    473:                                case AR_GROUP:
                    474:                                case AR_LIB:
                    475:                                case AR_DIR:
                    476:                                case AR_SUB:
                    477:                                        if(n) n--;              /* convert to 0 base */
                    478:                                        *((short *)(ar+j))=n;
                    479:                                        j+=2;
                    480:                                        break;
                    481:                                default:                    /* invalid numeric AR type */
                    482:                                        j--;
                    483:                                        break; }
                    484:                        while(isdigit(str[i+1])) i++;
                    485:                        continue; }
1.1.1.2 ! root      486:                if(artype==AR_SUBCODE || artype==AR_DIRCODE || artype==AR_SHELL) {
1.1       root      487:                        for(n=0;n<8
                    488:                                && str[i]
1.1.1.2 ! root      489:                                && str[i]!=' '
1.1       root      490:                                && str[i]!='('
                    491:                                && str[i]!=')'
                    492:                                && str[i]!='='
                    493:                                && str[i]!='|'
                    494:                                ;n++)
1.1.1.2 ! root      495:                                ar[j++]=toupper(str[i++]);
1.1       root      496:                        ar[j++]=0;
                    497:                        continue; }
                    498:                switch(artype) {
                    499:                        case AR_FLAG1:
                    500:                        case AR_FLAG2:
                    501:                        case AR_FLAG3:
                    502:                        case AR_FLAG4:
                    503:                        case AR_EXEMPT:
                    504:                        case AR_SEX:
                    505:                        case AR_REST:
1.1.1.2 ! root      506:                                ar[j++]=toupper(str[i]);
1.1       root      507:                                break;
                    508:        #ifdef SBBS
                    509:                        case AR_SUB:
                    510:                                for(n=0;n<cfg->total_subs;n++)
                    511:                                        if(!strnicmp(str+i,cfg->sub[n]->code,strlen(cfg->sub[n]->code)))
                    512:                                                break;
                    513:                                if(n<cfg->total_subs) {
                    514:                                        *((short *)(ar+j))=n;
                    515:                                        j+=2; }
                    516:                                else        /* Unknown sub-board */
                    517:                                        j--;
                    518:                                while(isalpha(str[i+1])) i++;
                    519:                                break;
                    520:                        case AR_DIR:
                    521:                                for(n=0;n<cfg->total_dirs;n++)
                    522:                                        if(!strnicmp(str+i,cfg->dir[n]->code,strlen(cfg->dir[n]->code)))
                    523:                                                break;
                    524:                                if(n<cfg->total_dirs) {
                    525:                                        *((short *)(ar+j))=n;
                    526:                                        j+=2; }
                    527:                                else        /* Unknown directory */
                    528:                                        j--;
                    529:                                while(isalpha(str[i+1])) i++;
                    530:                                break;
                    531:        #endif
                    532:                        case AR_DAY:
1.1.1.2 ! root      533:                                if(toupper(str[i])=='S' 
        !           534:                                        && toupper(str[i+1])=='U')                              /* Sunday */
1.1       root      535:                                        ar[j++]=0;
1.1.1.2 ! root      536:                                else if(toupper(str[i])=='M')               /* Monday */
1.1       root      537:                                        ar[j++]=1;
1.1.1.2 ! root      538:                                else if(toupper(str[i])=='T' 
        !           539:                                        && toupper(str[i+1])=='U')                              /* Tuesday */
1.1       root      540:                                        ar[j++]=2;
1.1.1.2 ! root      541:                                else if(toupper(str[i])=='W')               /* Wednesday */
1.1       root      542:                                        ar[j++]=3;
1.1.1.2 ! root      543:                                else if(toupper(str[i])=='T' 
        !           544:                                        && toupper(str[i+1])=='H')                              /* Thursday */
1.1       root      545:                                        ar[j++]=4;
1.1.1.2 ! root      546:                                else if(toupper(str[i])=='F')               /* Friday */
1.1       root      547:                                        ar[j++]=5;
                    548:                                else ar[j++]=6;                             /* Saturday */
                    549:                                while(isalpha(str[i+1])) i++;
                    550:                                break;
                    551:                        default:        /* Badly formed ARS, digit expected */
                    552:                                j--;
                    553:                                break;
                    554:                } 
                    555:        }
                    556:        if(!j)
1.1.1.2 ! root      557:                return((uchar*)nular);  /* Save memory */
1.1       root      558: 
                    559:        ar[j++]=AR_NULL;
                    560:        /** DEBUG stuff
                    561:        for(i=0;i<j;i++)
                    562:                lprintf("%02X ",(uint)ar[i]);
                    563:        lputs("\r\n");
                    564:        ***/
                    565:        if((ar_buf=(uchar *)calloc(j+4,1))==NULL)       /* Padded for ushort dereferencing */
                    566:                return(NULL);
                    567:        memcpy(ar_buf,ar,j);
                    568:        if(count)
                    569:                (*count)=j;
                    570:        return(ar_buf);
                    571: }
                    572: 

unix.superglobalmegacorp.com

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