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

1.1       root        1: /* baja.c */
                      2: 
                      3: /* Synchronet command shell/module compiler */
                      4: 
1.1.1.2 ! root        5: /* $Id: baja.c,v 1.32 2004/09/12 07:12:37 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: /* OS-specific */
                     39: #ifndef __unix__
                     40:        #include <io.h>
                     41:        #include <share.h>
                     42: #endif
                     43: #ifdef _WIN32
                     44:        #include <windows.h>
                     45: #endif
                     46: 
                     47: /* ANSI */
                     48: #include <stdio.h>
                     49: #include <string.h>
                     50: #include <ctype.h>
                     51: #include <fcntl.h>
1.1.1.2 ! root       52: #include <errno.h>
1.1       root       53: 
                     54: /* Synchronet-specific */
                     55: #include "cmdshell.h"
                     56: #include "ars_defs.h"
                     57: #include "crc32.h"
1.1.1.2 ! root       58: #include "genwrap.h"   /* portability wrappers */
        !            59: #include "dirwrap.h"   /* MAX_PATH */
1.1       root       60: 
                     61: #ifdef __BORLANDC__
                     62: unsigned _stklen=20000;        /* Set stack size in code, not header */
                     63: #endif
                     64: 
                     65: char **label_name=NULL
                     66:        ,**goto_file=NULL
                     67:        ,**goto_label=NULL
                     68:        ,**call_file=NULL
                     69:        ,**call_label=NULL;
                     70: 
                     71: ulong *var_name=NULL,vars=0;
                     72: 
                     73: char **define_str=NULL
                     74:        ,**define_val=NULL;
                     75: 
                     76: char *linestr="%s %d: %s\n";
                     77: char tmp[256];
                     78: 
                     79: uint *label_indx=NULL
                     80:        ,*goto_indx=NULL
                     81:        ,*goto_line=NULL
                     82:        ,*call_indx=NULL
                     83:        ,*call_line=NULL;
                     84: 
1.1.1.2 ! root       85: char bin_file[MAX_PATH+1];
        !            86: char output_dir[MAX_PATH+1];
        !            87: char include_dir[MAX_PATH+1];
        !            88: 
1.1       root       89: uint display=0,line=0,labels=0,gotos=0,calls=0,defines=0,case_sens=0;
1.1.1.2 ! root       90: BOOL pause_on_error=FALSE;
1.1       root       91: 
                     92: FILE *out=NULL;
                     93: 
1.1.1.2 ! root       94: void bail(int retval)
1.1       root       95: {
1.1.1.2 ! root       96:        if(out) 
        !            97:                fclose(out);
1.1       root       98: 
1.1.1.2 ! root       99:        if(retval!=0) {
        !           100:                if(bin_file[0]!=0)
        !           101:                        remove(bin_file);
        !           102:                if(pause_on_error) {
        !           103:                        printf("\nHit enter to contiue...");
        !           104:                        getchar();
        !           105:                }
        !           106:        }
1.1       root      107: 
1.1.1.2 ! root      108:        exit(retval);
1.1       root      109: }
                    110: 
                    111: /****************************************************************************/
                    112: /* Converts an ASCII Hex string into an ulong                                                          */
                    113: /****************************************************************************/
                    114: ulong ahtoul(char *str)
                    115: {
                    116:        ulong l,val=0;
                    117: 
                    118:        while((l=(*str++)|0x20)!=0x20)
                    119:                val=(l&0xf)+(l>>6&1)*9+val*16;
                    120:        return(val);
                    121: }
                    122: 
                    123: /* C Escape char */
                    124: 
                    125: uchar cesc(char ch)
                    126: {
                    127:        switch(ch) {
                    128:                case 'r':
                    129:                        return(CR);
                    130:                case 'n':
                    131:                        return(LF);
                    132:                case 't':
                    133:                        return(TAB);
                    134:                case 'b':
                    135:                        return(BS);
                    136:                case 'a':
                    137:                        return(BEL);
                    138:                case 'f':
                    139:                        return(FF);
                    140:                case 'v':
                    141:                        return(11);
                    142:                default:
                    143:                        return(ch); 
                    144:        }
                    145: }
                    146: 
                    147: long val(char *src, char *p)
                    148: {
                    149:        static int inside;
                    150:        long l;
                    151: 
                    152:        if(isdigit(*p) || *p=='-')      /* Dec, Hex, or Oct */
                    153:                l=strtol(p,&p,0);
                    154:        else if(*p=='\'') {  /* Char */
                    155:                p++;
                    156:                if(*p=='\\') {
                    157:                        p++;
                    158:                        l=cesc(*p); }
                    159:                else
                    160:                        l=*p;
                    161:                p++; }
                    162:        else if(*p=='.')    /* Bit */
                    163:                l=1L<<strtol(p+1,&p,0);
                    164:        else {
                    165:                printf("SYNTAX ERROR (expecting integer constant):\n");
                    166:                printf(linestr,src,line,*p ? p : "<end of line>");
1.1.1.2 ! root      167:                bail(1);
1.1       root      168:                return(0); }
                    169:        if(inside) {
                    170:                return(l); }
                    171:        inside=1;
                    172:        while(*p)
                    173:                switch(*(p++)) {
                    174:                        case '+':
                    175:                                l+=val(src,p);
                    176:                                break;
                    177:                        case '-':
                    178:                                l-=val(src,p);
                    179:                                break;
                    180:                        case '*':
                    181:                                l*=val(src,p);
                    182:                                break;
                    183:                        case '/':
                    184:                                l/=val(src,p);
                    185:                                break;
                    186:                        case '%':
                    187:                                l%=val(src,p);
                    188:                                break;
                    189:                        case '&':
                    190:                                l&=val(src,p);
                    191:                                break;
                    192:                        case '|':
                    193:                                l|=val(src,p);
                    194:                                break;
                    195:                        case '~':
                    196:                                l&=~val(src,p);
                    197:                                break;
                    198:                        case '^':
                    199:                                l^=val(src,p);
                    200:                                break;
                    201:                        case '>':
                    202:                                if(*p=='>') {
                    203:                                        p++;
                    204:                                        l>>=val(src,p); }
                    205:                                break;
                    206:                        case '<':
                    207:                                if(*p=='<') {
                    208:                                        p++;
                    209:                                        l<<=val(src,p); }
                    210:                                break;
1.1.1.2 ! root      211:                        case ' ':
1.1       root      212:                        case '#':
                    213:                                inside=0;
                    214:                                return(l); }
                    215:        inside=0;
                    216:        return(l);
                    217: }
                    218: 
                    219: 
                    220: void writecstr(uchar *p)
                    221: {
                    222:        char str[1024];
                    223:        int j=0,inquotes=0;
                    224: 
                    225:        while(*p) {
                    226:                if(*p=='"') {   /* ignore quotes */
                    227:                        if(inquotes)
                    228:                                break;
                    229:                        inquotes=1;
                    230:                        p++;
                    231:                        continue; }
                    232:                if(*p=='\\')    { /* escape */
                    233:                        p++;
                    234:                        if(isdigit(*p)) {
1.1.1.2 ! root      235:                                sprintf(tmp,"%.3s",p);
        !           236:                                str[j]=atoi(tmp);               /* decimal, NOT octal */
1.1       root      237:                                if(isdigit(*(++p)))     /* skip up to 3 digits */
                    238:                                        if(isdigit(*(++p)))
                    239:                                                p++;
                    240:                                j++;
                    241:                                continue; }
                    242:                        switch(*(p++)) {
                    243:                                case 'x':
                    244:                                        tmp[0]=*(p++);
                    245:                                        tmp[1]=0;
                    246:                                        if(isxdigit(*p)) {      /* if another hex digit, skip too */
                    247:                                                tmp[1]=*(p++);
                    248:                                                tmp[2]=0; }
                    249:                                        str[j]=(char)ahtoul(tmp);
                    250:                                        break;
                    251:                                case 'r':
                    252:                                        str[j]=CR;
                    253:                                        break;
                    254:                                case 'n':
                    255:                                        str[j]=LF;
                    256:                                        break;
                    257:                                case 't':
                    258:                                        str[j]=TAB;
                    259:                                        break;
                    260:                                case 'b':
                    261:                                        str[j]=BS;
                    262:                                        break;
                    263:                                case 'a':
                    264:                                        str[j]=BEL;
                    265:                                        break;
                    266:                                case 'f':
                    267:                                        str[j]=FF;
                    268:                                        break;
                    269:                                case 'v':
                    270:                                        str[j]=11;      /* VT */
                    271:                                        break;
                    272:                                default:
                    273:                                        str[j]=*(p-1);
                    274:                                        break; }
                    275:                        j++;
                    276:                        continue; }
                    277:                str[j++]=*(p++); }
                    278:        str[j]=0;
                    279:        fwrite(str,1,j+1,out);
                    280: }
                    281: 
                    282: void writestr(uchar *p)
                    283: {
                    284:        char str[1024];
                    285:        int j=0;
                    286: 
                    287:        while(*p) {
                    288:                if(*p=='"') {   /* ignore quotes */
                    289:                        p++;
                    290:                        continue; }
                    291:                if(*p=='\\' && *(p+1)=='"' && *(p+2))
                    292:                        p++;
                    293:                str[j++]=*(p++); }
                    294:        str[j]=0;
                    295:        fwrite(str,1,j+1,out);
                    296: }
                    297: 
                    298: void cvttab(char *str)
                    299: {
                    300:        int i;
                    301: 
                    302:        for(i=0;str[i];i++)
                    303:                if(str[i]==TAB)
1.1.1.2 ! root      304:                        str[i]=' ';
1.1       root      305: }
                    306: 
                    307: void newvar(uchar *in)
                    308: {
                    309:        uchar name[128];
                    310:        long i,l;
                    311: 
                    312:        sprintf(name,"%.80s",in);
                    313:        if(!case_sens)
                    314:                strupr(name);
1.1.1.2 ! root      315:        l=crc32(name,0);
1.1       root      316:        for(i=0;i<vars;i++)
                    317:                if(var_name[i]==l)
                    318:                        break;
                    319:        if(i<vars)
                    320:                return;
                    321:        if((var_name=(ulong *)REALLOC(var_name,sizeof(long)*(vars+1)))==NULL) {
                    322:                printf("Too many (%lu) variables!\n",vars);
1.1.1.2 ! root      323:                bail(1); }
1.1       root      324:        var_name[vars]=l;
                    325:        if(display)
                    326:                printf("newvar(%08lX)=%s\n",l,in);
                    327:        vars++;
                    328: }
                    329: 
                    330: void writecrc(uchar *src, uchar *in)
                    331: {
                    332:        uchar   name[128];
                    333:        uchar*  p;
                    334:        long    i,l;
                    335: 
                    336:        /* Automatically terminate variable name Oct-09-2000 rswindell */
                    337:        sprintf(name,"%.80s",in);
1.1.1.2 ! root      338:        p=strchr(name,' ');
1.1       root      339:        if(p) *p=0;
                    340: 
                    341:        if(!case_sens)
                    342:                strupr(name);
                    343:        if(!stricmp(name,"STR") || !name[0])
                    344:                l=0;
                    345:        else {
1.1.1.2 ! root      346:                l=crc32(name,0);
1.1       root      347: 
                    348:                for(i=0;i<vars;i++)
                    349:                        if(var_name[i]==l)
                    350:                                break;
                    351:                if(i==vars) {
                    352:                        printf("SYNTAX ERROR (expecting variable name):\n");
                    353:                        printf(linestr,src,line,*in ? (char*)in : "<end of line>");
1.1.1.2 ! root      354:                        bail(1)1.1       root      355:                }
                    356:        }
                    357:        fwrite(&l,4,1,out);
                    358: }
                    359: 
                    360: long isvar(uchar *arg)
                    361: {
                    362:        uchar name[128],*p;
                    363:        long i,l;
                    364: 
                    365:        if(!arg || !(*arg))
                    366:                return(0);
                    367: 
                    368:        sprintf(name,"%.80s",arg);
1.1.1.2 ! root      369:        if((p=strchr(name,' '))!=NULL)  // Truncate at first space
1.1       root      370:                *p=0;
                    371:        if(!case_sens)
                    372:                strupr(name);
1.1.1.2 ! root      373:        l=crc32(name,0);
1.1       root      374: 
                    375:        for(i=0;i<vars;i++)
                    376:                if(var_name[i]==l)
                    377:                        break;
                    378:        if(i==vars)
                    379:                return(0);
                    380:        return(l);
                    381: }
                    382: 
                    383: int str_cmp(char *s1, char *s2)
                    384: {
                    385:        if(case_sens)
                    386:                return(strcmp(s1,s2));
                    387:        return(stricmp(s1,s2));
                    388: }
                    389: 
                    390: void expdefs(uchar *line)
                    391: {
                    392:        uchar str[512],*p,*sp,sav[2]={0};
                    393:        int i;
                    394: 
                    395:        str[0]=0;
                    396:        for(p=line;*p;p++) {
1.1.1.2 ! root      397:                if(*p==' ') {
1.1       root      398:                        strcat(str," ");
                    399:                        continue; }
                    400: 
                    401:                if(*p=='"') {               /* Skip quoted text */
                    402:                        sp=strchr(p+1,'"');
                    403:                        if(sp) *sp=0;
                    404:                        strcat(str,p);
                    405:                        if(!sp)
                    406:                                break;
                    407:                        strcat(str,"\"");
                    408:                        p+=strlen(p);
                    409:                        continue; }
                    410: 
                    411:                for(sp=p;*sp;sp++)
                    412:                        if(!isalnum(*sp) && *sp!='_')
                    413:                                break;
                    414:                sav[0]=*sp;             /* Save delimiter */
                    415:                sav[1]=0;
                    416:                *sp=0;
                    417:                for(i=0;i<defines;i++)
                    418:                        if(!str_cmp(define_str[i],p))
                    419:                                break;
                    420:                if(i<defines)
                    421:                        strcat(str,define_val[i]);
                    422:                else
                    423:                        strcat(str,p);
                    424:                if(!sav[0])             /* Last argument */
                    425:                        break;
                    426:                p+=strlen(p);
                    427:                strcat(str,sav);        /* Restore delimiter */
                    428:                }
                    429:        strcpy(line,str);
                    430: }
                    431: 
                    432: 
                    433: 
                    434: void compile(char *src)
                    435: {
1.1.1.2 ! root      436:        uchar *str,*save,*p,*sp,*tp,*arg,*arg2,*arg3,*arg4,*ar,ch;
        !           437:        char path[MAX_PATH+1];
1.1       root      438:     ushort i,j;
                    439:        long l,savline;
                    440:        FILE *in;
                    441: 
                    442:        if((in=fopen(src,"rb"))==NULL) {
1.1.1.2 ! root      443:                printf("error %d opening %s for read\n",errno,src);
        !           444:                bail(1); }
1.1       root      445:        line=0;
                    446: 
                    447:        if((str=malloc(1024))==NULL) {
                    448:                printf("malloc error\n");
1.1.1.2 ! root      449:                bail(1);
1.1       root      450:        }
                    451: 
                    452:        if((save=malloc(1024))==NULL) {
                    453:                printf("malloc error\n");
1.1.1.2 ! root      454:                bail(1);
1.1       root      455:        }
                    456: 
                    457:        while(!feof(in) && !ferror(in)) {
                    458:                if(!fgets(str,1000,in))
                    459:                        break;
                    460:                truncsp(str);
                    461:                cvttab(str);
                    462:                line++;
                    463:                strcpy(save,str);
                    464:                p=str;
1.1.1.2 ! root      465:                while(*p && *p<=' ')   /* look for beginning of command */
1.1       root      466:                        p++;
                    467:                if((*p)==0)
                    468:                        continue;
                    469:                if(*p=='#')             /* remarks start with # */
                    470:                        continue;
                    471:                expdefs(p);                     /* expand defines */
                    472:                if(display)
                    473:                        printf("%s\n",p);
1.1.1.2 ! root      474:                sp=strchr(p,' ');
        !           475:                arg=arg2=arg3=arg4="";
1.1       root      476:                if(sp) {
                    477:                        *sp=0;
                    478:                        arg=sp+1;
1.1.1.2 ! root      479:                        while(*arg && *arg<=' ') arg++;
        !           480:                        sp=strchr(arg,' ');
1.1       root      481:                        if(sp) {
                    482:                                arg2=sp+1;
1.1.1.2 ! root      483:                                while(*arg2 && *arg2<=' ') arg2++;
        !           484:                                sp=strchr(arg2,' ');
1.1       root      485:                                if(sp) {
                    486:                                        arg3=sp+1;
1.1.1.2 ! root      487:                                        while(*arg3 && *arg3<=' ') arg3++; 
        !           488:                                        sp=strchr(arg3,' ');
        !           489:                                        if(sp) {
        !           490:                                                arg4=sp+1;
        !           491:                                                while(*arg4 && *arg4<=' ') arg4++; } } } }
1.1       root      492: 
                    493:                if(!stricmp(p,"!INCLUDE")) {
                    494:                        savline=line;
1.1.1.2 ! root      495:                        sp=strchr(arg,' ');
1.1       root      496:                        if(sp) *sp=0;
1.1.1.2 ! root      497:                        sprintf(path,"%s%s",include_dir,arg);
        !           498:                        compile(path);
1.1       root      499:                        line=savline;
1.1.1.2 ! root      500:                        continue; 
        !           501:                }
1.1       root      502: 
                    503:                if(!stricmp(p,"!DEFINE")) {                     /* define */
1.1.1.2 ! root      504:                        sp=strchr(arg,' ');
1.1       root      505:                        if(sp)
                    506:                                *sp=0;
                    507:                        else
                    508:                                break;
                    509:                        tp=strrchr(arg2,'\"');
                    510:                        if(!tp)
                    511:                                tp=arg2;
                    512:                        sp=strchr(tp,'#');
                    513:                        if(sp)
                    514:                                *sp=0;
                    515:                        truncsp(arg2);
                    516:                        if((define_str=(char **)REALLOC(define_str,sizeof(char *)*(defines+1)))
                    517:                                ==NULL) {
                    518:                                printf("Too many defines.\n");
1.1.1.2 ! root      519:                                bail(1); }
1.1       root      520:                        if((define_str[defines]=(char *)MALLOC(strlen(arg)+1))==NULL) {
                    521:                                printf("Too many defines.\n");
1.1.1.2 ! root      522:                                bail(1); }
1.1       root      523:                        if((define_val=(char **)REALLOC(define_val,sizeof(char *)*(defines+1)))
                    524:                                ==NULL) {
                    525:                                printf("Too many defines.\n");
1.1.1.2 ! root      526:                                bail(1); }
1.1       root      527:                        if((define_val[defines]=(char *)MALLOC(strlen(arg2)+1))==NULL) {
                    528:                                printf("Too many defines.\n");
1.1.1.2 ! root      529:                                bail(1); }
1.1       root      530:                        strcpy(define_str[defines],arg);
                    531:                        strcpy(define_val[defines],arg2);
                    532:                        defines++;
                    533:                        continue; }
                    534: 
                    535:                if(!stricmp(p,"!GLOBAL")) {             /* declare global variables */
                    536:                        if(!(*arg)) break;
                    537:                        for(p=arg;*p && *p!='#';) {
1.1.1.2 ! root      538:                                sp=strchr(p,' ');
1.1       root      539:                                if(sp) *sp=0;
                    540:                                newvar(p);
                    541:                                if(!sp)
                    542:                                        break;
                    543:                                p=sp+1;
1.1.1.2 ! root      544:                                while(*p && *p<=' ')
1.1       root      545:                                        p++; }
                    546:                        continue; }
                    547: 
                    548:                if(!stricmp(p,"PATCH")) {
                    549:                        if(!(*arg)) break;
                    550:                        p=arg;
                    551:                        while(*p) {
1.1.1.2 ! root      552:                                while(*p && *p<=' ') p++;
1.1       root      553:                                tmp[0]=*p++;
                    554:                                tmp[1]=*p++;
                    555:                                tmp[2]=0;
                    556:                                if(!tmp[0])
                    557:                                        break;
                    558:                                ch=ahtoul(tmp);
                    559:                                fputc(ch,out); }
                    560:                        continue; }
                    561: 
                    562:                if(!stricmp(p,"SHOW_VARS")) {
                    563:                        fputc(CS_VAR_INSTRUCTION,out);
                    564:                        fputc(SHOW_VARS,out);
                    565:                        continue; }
                    566: 
                    567:                if(!stricmp(p,"COMPARE_ARS")) {
                    568:                        if(!(*arg)) break;
                    569:                        strupr(arg);
                    570:                        ar=arstr(&i,arg,NULL);
                    571:                        fprintf(out,"%c%c",CS_COMPARE_ARS,(uchar)i);
                    572:                        fwrite(ar,i,1,out);
                    573:                        continue; }
                    574: 
                    575:                if(!stricmp(p,"CHKSYSPASS")) {
                    576:                        fprintf(out,"%c",CS_CHKSYSPASS);
                    577:                        continue; }
                    578:                if(!stricmp(p,"INFO_SYSTEM")) {
                    579:                        fprintf(out,"%c",CS_INFO_SYSTEM);
                    580:                        continue; }
                    581:                if(!stricmp(p,"INFO_SUBBOARD")) {
                    582:                        fprintf(out,"%c",CS_INFO_SUBBOARD);
                    583:                        continue; }
                    584:                if(!stricmp(p,"INFO_DIRECTORY")) {
                    585:                        fprintf(out,"%c",CS_INFO_DIRECTORY);
                    586:                        continue; }
                    587:                if(!stricmp(p,"INFO_VERSION")) {
                    588:                        fprintf(out,"%c",CS_INFO_VERSION);
                    589:                        continue; }
                    590:                if(!stricmp(p,"INFO_USER")) {
                    591:                        fprintf(out,"%c",CS_INFO_USER);
                    592:                        continue; }
                    593:                if(!stricmp(p,"INFO_XFER_POLICY")) {
                    594:                        fprintf(out,"%c",CS_INFO_XFER_POLICY);
                    595:                        continue; }
                    596:                if(!stricmp(p,"LOGKEY")) {
                    597:                        fprintf(out,"%c",CS_LOGKEY);
                    598:                        continue; }
                    599:                if(!stricmp(p,"LOGKEY_COMMA")) {
                    600:                        fprintf(out,"%c",CS_LOGKEY_COMMA);
                    601:                        continue; }
                    602:                if(!stricmp(p,"LOGSTR")) {
                    603:                        fprintf(out,"%c",CS_LOGSTR);
                    604:                        continue; }
                    605: 
                    606:                if(!stricmp(p,"ONLINE")) {
                    607:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_ONLINE);
                    608:                        continue; }
                    609:                if(!stricmp(p,"OFFLINE")) {
                    610:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_OFFLINE);
                    611:                        continue; }
                    612:                if(!stricmp(p,"NEWUSER")) {
                    613:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_NEWUSER);
                    614:                        continue; }
                    615:                if(!stricmp(p,"LOGON")) {
                    616:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_LOGON);
                    617:                        continue; }
                    618:                if(!stricmp(p,"LOGOUT")) {
                    619:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_LOGOUT);
                    620:                        continue; }
                    621:                if(!stricmp(p,"EXIT")) {
                    622:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_EXIT);
                    623:                        continue; }
                    624: 
1.1.1.2 ! root      625:                if(!stricmp(p,"LOOP") || !stricmp(p,"LOOP_BEGIN")) {
        !           626:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_LOOP_BEGIN);
        !           627:                        continue; }
        !           628:                if(!stricmp(p,"CONTINUE") || !stricmp(p,"CONTINUE_LOOP")) {
        !           629:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_CONTINUE_LOOP);
        !           630:                        continue; }
        !           631:                if(!stricmp(p,"BREAK") || !stricmp(p,"BREAK_LOOP")) {
        !           632:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_BREAK_LOOP);
        !           633:                        continue; }
        !           634:                if(!stricmp(p,"END_LOOP")) {
        !           635:                        fprintf(out,"%c%c",CS_ONE_MORE_BYTE,CS_END_LOOP);
        !           636:                        continue; }
        !           637: 
1.1       root      638:                if(!stricmp(p,"USER_EVENT")) {
                    639:                        if(!(*arg))
                    640:                                break;
                    641:                        if((l=isvar(arg))!=0) {
                    642:                                fputc(CS_USE_INT_VAR,out);
                    643:                                fwrite(&l,4,1,out); // variable
                    644:                                fputc(2,out);           // int offset
                    645:                                fputc(1,out);       // int length
                    646:                                ch=0; }             // place holder
                    647:                        else
                    648:                                ch=val(src,arg);
                    649:                        fprintf(out,"%c%c",CS_TWO_MORE_BYTES,CS_USER_EVENT);
                    650:                        fwrite(&ch,1,1,out);
                    651:                        continue; }
                    652: 
                    653:                if(!stricmp(p,"PUT_NODE")) {
                    654:                        fprintf(out,"%c",CS_PUT_NODE);
                    655:                        continue; }
                    656:                if(!stricmp(p,"SYNC")) {
                    657:                        fprintf(out,"%c",CS_SYNC);
                    658:                        continue; }
                    659:                if(!stricmp(p,"ASYNC")) {
                    660:                        fprintf(out,"%c",CS_ASYNC);
                    661:                        continue; }
1.1.1.2 ! root      662:                if(!stricmp(p,"RIOSYNC")) {             /* deprecated */
        !           663:                        fprintf(out,"%c",CS_SYNC);
1.1       root      664:                        continue; }
                    665:                if(!stricmp(p,"GETTIMELEFT")) {
                    666:                        fprintf(out,"%c",CS_GETTIMELEFT);
                    667:                        continue; }
                    668:                if(!stricmp(p,"SAVELINE")) {
                    669:                        fprintf(out,"%c",CS_SAVELINE);
                    670:                        continue; }
                    671:                if(!stricmp(p,"RESTORELINE")) {
                    672:                        fprintf(out,"%c",CS_RESTORELINE);
                    673:                        continue; }
                    674:                if(!stricmp(p,"IF_TRUE") || !stricmp(p,"IF_EQUAL")) {
                    675:                        fprintf(out,"%c",CS_IF_TRUE);
                    676:                        continue; }
                    677:                if(!stricmp(p,"IF_FALSE") || !stricmp(p,"IF_NOT_EQUAL")) {
                    678:                        fprintf(out,"%c",CS_IF_FALSE);
                    679:                        continue; }
                    680:                if(!stricmp(p,"IF_GREATER")) {
                    681:                        fprintf(out,"%c",CS_IF_GREATER);
                    682:                        continue; }
                    683:                if(!stricmp(p,"IF_GREATER_OR_EQUAL")
                    684:                        || !stricmp(p,"IF_EQUAL_OR_GREATER")) {
                    685:                        fprintf(out,"%c",CS_IF_GREATER_OR_EQUAL);
                    686:                        continue; }
                    687:                if(!stricmp(p,"IF_LESS")) {
                    688:                        fprintf(out,"%c",CS_IF_LESS);
                    689:                        continue; }
                    690:                if(!stricmp(p,"IF_LESS_OR_EQUAL")
                    691:                        || !stricmp(p,"IF_EQUAL_OR_LESS")) {
                    692:                        fprintf(out,"%c",CS_IF_LESS_OR_EQUAL);
                    693:                        continue; }
                    694:                if(!stricmp(p,"ENDIF") || !stricmp(p,"END_IF")) {
                    695:                        fprintf(out,"%c",CS_ENDIF);
                    696:                        continue; }
                    697:                if(!stricmp(p,"ELSE")) {
                    698:                        fprintf(out,"%c",CS_ELSE);
                    699:                        continue; }
                    700:                if(p[0]==':') {                     /* :label */
                    701:                        p++;
1.1.1.2 ! root      702:                        sp=strchr(p,' ');
1.1       root      703:                        if(sp)
                    704:                                *sp=0;
                    705:                        for(i=0;i<labels;i++)
                    706:                                if(!stricmp(label_name[i],p))
                    707:                                        break;
                    708:                        if(i<labels) {
                    709:                                printf("SYNTAX ERROR (duplicate label name):\n");
                    710:                                printf(linestr,src,line,p);
1.1.1.2 ! root      711:                                bail(1); }
1.1       root      712:                        if((label_name=(char **)REALLOC(label_name,sizeof(char *)*(labels+1)))
                    713:                                ==NULL) {
                    714:                                printf("Too many labels.\n");
1.1.1.2 ! root      715:                                bail(1); }
1.1       root      716:                        if((label_indx=(uint *)REALLOC(label_indx,sizeof(int)*(labels+1)))
                    717:                                ==NULL) {
                    718:                                printf("Too many labels.\n");
1.1.1.2 ! root      719:                                bail(1); }
1.1       root      720:                        if((label_name[labels]=(char *)MALLOC(strlen(p)+1))==NULL) {
                    721:                                printf("Too many labels.\n");
1.1.1.2 ! root      722:                                bail(1); }
1.1       root      723:                        strcpy(label_name[labels],p);
                    724:                        label_indx[labels]=ftell(out);
                    725:                        labels++;
                    726:                        continue; }
                    727:                if(!stricmp(p,"GOTO")) {           /* goto */
                    728:                        if(!(*arg)) break;
1.1.1.2 ! root      729:                        sp=strchr(arg,' ');
1.1       root      730:                        if(sp)
                    731:                                *sp=0;
                    732:                        if((goto_label=(char **)REALLOC(goto_label,sizeof(char *)*(gotos+1)))
                    733:                                ==NULL) {
                    734:                                printf("Too many gotos.\n");
1.1.1.2 ! root      735:                                bail(1); }
1.1       root      736:                        if((goto_file=(char **)REALLOC(goto_file,sizeof(char *)*(gotos+1)))
                    737:                                ==NULL) {
                    738:                                printf("Too many gotos.\n");
1.1.1.2 ! root      739:                                bail(1); }
1.1       root      740:                        if((goto_indx=(uint *)REALLOC(goto_indx,sizeof(int)*(gotos+1)))
                    741:                                ==NULL) {
                    742:                                printf("Too many gotos.\n");
1.1.1.2 ! root      743:                                bail(1); }
1.1       root      744:                        if((goto_line=(uint *)REALLOC(goto_line,sizeof(int)*(gotos+1)))
                    745:                                ==NULL) {
                    746:                                printf("Too many gotos.\n");
1.1.1.2 ! root      747:                                bail(1); }
1.1       root      748:                        if((goto_label[gotos]=(char *)MALLOC(strlen(arg)+1))==NULL) {
                    749:                                printf("Too many gotos.\n");
1.1.1.2 ! root      750:                                bail(1); }
1.1       root      751:                        if((goto_file[gotos]=(char *)MALLOC(strlen(str)+1))==NULL) {
                    752:                                printf("Too many gotos.\n");
1.1.1.2 ! root      753:                                bail(1); }
1.1       root      754:                        strcpy(goto_label[gotos],arg);
                    755:                        strcpy(goto_file[gotos],str);
                    756:                        goto_indx[gotos]=ftell(out);
                    757:                        goto_line[gotos]=line;
                    758:                        gotos++;
                    759:                        fprintf(out,"%c%c%c",CS_GOTO,0xff,0xff);
                    760:                        continue; }
                    761:                if(!stricmp(p,"CALL")) {          /* call */
                    762:                        if(!(*arg)) break;
1.1.1.2 ! root      763:                        sp=strchr(arg,' ');
1.1       root      764:                        if(sp)
                    765:                                *sp=0;
                    766:                        if((call_label=(char **)REALLOC(call_label,sizeof(char *)*(calls+1)))
                    767:                                ==NULL) {
                    768:                                printf("Too many calls.\n");
1.1.1.2 ! root      769:                                bail(1); }
1.1       root      770:                        if((call_file=(char **)REALLOC(call_file,sizeof(char *)*(calls+1)))
                    771:                                ==NULL) {
                    772:                                printf("Too many calls.\n");
1.1.1.2 ! root      773:                                bail(1); }
1.1       root      774:                        if((call_indx=(uint *)REALLOC(call_indx,sizeof(int)*(calls+1)))
                    775:                                ==NULL) {
                    776:                                printf("Too many calls.\n");
1.1.1.2 ! root      777:                                bail(1); }
1.1       root      778:                        if((call_line=(uint *)REALLOC(call_line,sizeof(int)*(calls+1)))
                    779:                                ==NULL) {
                    780:                                printf("Too many calls.\n");
1.1.1.2 ! root      781:                                bail(1); }
1.1       root      782:                        if((call_label[calls]=(char *)MALLOC(strlen(arg)+1))==NULL) {
                    783:                                printf("Too many calls.\n");
1.1.1.2 ! root      784:                                bail(1); }
1.1       root      785:                        if((call_file[calls]=(char *)MALLOC(strlen(src)+1))==NULL) {
                    786:                                printf("Too many calls.\n");
1.1.1.2 ! root      787:                                bail(1); }
1.1       root      788: 
                    789:                        strcpy(call_label[calls],arg);
                    790:                        strcpy(call_file[calls],src);
                    791:                        call_indx[calls]=ftell(out);
                    792:                        call_line[calls]=line;
                    793:                        calls++;
                    794:                        fprintf(out,"%c%c%c",CS_CALL,0xff,0xff);
                    795:                        continue; }
                    796: 
                    797:                if(!stricmp(p,"RETURN")) {
                    798:                        fprintf(out,"%c",CS_RETURN);
                    799:                        continue; }
                    800:                if(!stricmp(p,"CMD_HOME")) {
                    801:                        fprintf(out,"%c",CS_CMD_HOME);
                    802:                        continue; }
                    803:                if(!stricmp(p,"CMDKEY")) {
                    804:                        if(!(*arg)) break;
                    805:                        if(!stricmp(arg,"DIGIT"))
                    806:                                ch=CS_DIGIT;
                    807:                        else if(!stricmp(arg,"EDIGIT"))
                    808:                                ch=CS_EDIGIT;
                    809:                        else
                    810:                                ch=toupper(*arg);
                    811:                        if(ch=='/')
                    812:                                ch=*(arg+1)|0x80;   /* high bit indicates slash required */
                    813:                        else if(ch=='^' && *(arg+1)>=0x40)
                    814:                                ch=*(arg+1)-0x40;   /* ctrl char */
                    815:                        else if(ch=='\\')
                    816:                                ch=cesc(*(arg+1));
                    817:                        else if(ch=='\'')
                    818:                                ch=*(arg+1);
                    819:                        fprintf(out,"%c%c",CS_CMDKEY,ch);
                    820:                        continue; }
                    821:                if(!stricmp(p,"CMDCHAR")) {
                    822:                        if(!(*arg)) break;
                    823:                        fprintf(out,"%c%c",CS_CMDKEY,*arg);
                    824:                        continue; }
                    825:                if(!stricmp(p,"SETLOGIC") || !stricmp(p,"SET_LOGIC")) {
                    826:                        if(!(*arg)) break;
                    827:                        if(!stricmp(arg,"TRUE") || !stricmp(arg,"EQUAL"))
                    828:                                ch=LOGIC_TRUE;
                    829:                        else if(!stricmp(arg,"GREATER"))
                    830:                                ch=LOGIC_GREATER;
                    831:                        else if(!stricmp(arg,"LESS"))
                    832:                                ch=LOGIC_LESS;
                    833:                        else
                    834:                                ch=LOGIC_FALSE;
                    835:                        fprintf(out,"%c%c",CS_SETLOGIC,ch);
                    836:                        continue; }
                    837: 
                    838:                if(!stricmp(p,"DEFINE_STR_VAR") || !stricmp(p,"STR")) {
                    839:                        if(!(*arg)) break;
                    840:                        for(p=arg;*p && *p!='#';) {
1.1.1.2 ! root      841:                                sp=strchr(p,' ');
1.1       root      842:                                if(sp) *sp=0;
                    843:                                fputc(CS_VAR_INSTRUCTION,out);
                    844:                                fputc(DEFINE_STR_VAR,out);
                    845:                                newvar(p);
                    846:                                writecrc(src,p);
                    847:                                if(!sp)
                    848:                                        break;
                    849:                                p=sp+1;
1.1.1.2 ! root      850:                                while(*p && *p<=' ')
1.1       root      851:                                        p++; }
                    852:                        continue; }
                    853:                if(!stricmp(p,"DEFINE_INT_VAR") || !stricmp(p,"INT")) {
                    854:                        if(!(*arg)) break;
                    855:                        for(p=arg;*p && *p!='#';) {
1.1.1.2 ! root      856:                                sp=strchr(p,' ');
1.1       root      857:                                if(sp) *sp=0;
                    858:                                fputc(CS_VAR_INSTRUCTION,out);
                    859:                                fputc(DEFINE_INT_VAR,out);
                    860:                                newvar(p);
                    861:                                writecrc(src,p);
                    862:                                if(!sp)
                    863:                                        break;
                    864:                                p=sp+1;
1.1.1.2 ! root      865:                                while(*p && *p<=' ')
1.1       root      866:                                        p++; }
                    867:                        continue; }
                    868:                if(!stricmp(p,"DEFINE_GLOBAL_STR_VAR") || !stricmp(p,"GLOBAL_STR")) {
                    869:                        if(!(*arg)) break;
                    870:                        for(p=arg;*p && *p!='#';) {
1.1.1.2 ! root      871:                                sp=strchr(p,' ');
1.1       root      872:                                if(sp) *sp=0;
                    873:                                fputc(CS_VAR_INSTRUCTION,out);
                    874:                                fputc(DEFINE_GLOBAL_STR_VAR,out);
                    875:                                newvar(p);
                    876:                                writecrc(src,p);
                    877:                                if(!sp)
                    878:                                        break;
                    879:                                p=sp+1;
1.1.1.2 ! root      880:                                while(*p && *p<=' ')
1.1       root      881:                                        p++; }
                    882:                        continue; }
                    883:                if(!stricmp(p,"DEFINE_GLOBAL_INT_VAR") || !stricmp(p,"GLOBAL_INT")) {
                    884:                        if(!(*arg)) break;
                    885:                        for(p=arg;*p && *p!='#';) {
1.1.1.2 ! root      886:                                sp=strchr(p,' ');
1.1       root      887:                                if(sp) *sp=0;
                    888:                                fputc(CS_VAR_INSTRUCTION,out);
                    889:                                fputc(DEFINE_GLOBAL_INT_VAR,out);
                    890:                                newvar(p);
                    891:                                writecrc(src,p);
                    892:                                if(!sp)
                    893:                                        break;
                    894:                                p=sp+1;
1.1.1.2 ! root      895:                                while(*p && *p<=' ')
1.1       root      896:                                        p++; }
                    897:                        continue; }
                    898: 
                    899:                if(!stricmp(p,"LOGIN")) {
                    900:                        if(!(*arg)) break;
                    901:                        fputc(CS_STR_FUNCTION,out);
                    902:                        fputc(CS_LOGIN,out);
                    903:                        writecstr(arg);
                    904:                        continue; }
                    905: 
                    906:                if(!stricmp(p,"LOAD_TEXT")) {
                    907:                        if(!(*arg)) break;
                    908:                        fputc(CS_STR_FUNCTION,out);
                    909:                        fputc(CS_LOAD_TEXT,out);
                    910:                        writestr(arg);
                    911:                        continue; }
                    912: 
                    913:                if(!stricmp(p,"SET_STR_VAR")
                    914:                        || (!stricmp(p,"SET") && strchr(arg,'"'))) {
                    915:                        if(!(*arg)) break;
                    916:                        fputc(CS_VAR_INSTRUCTION,out);
                    917:                        fputc(SET_STR_VAR,out);
1.1.1.2 ! root      918:                        p=strchr(arg,' ');
1.1       root      919:                        if(!p)
                    920:                                break;
                    921:                        *p=0;
                    922:                        writecrc(src,arg);
                    923:                        writecstr(arg2);
                    924:                        continue; }
                    925:                if(!stricmp(p,"CAT_STR_VAR")
                    926:                        || (!stricmp(p,"STRCAT") && strchr(arg,'"'))) {
                    927:                        fputc(CS_VAR_INSTRUCTION,out);
                    928:                        fputc(CAT_STR_VAR,out);
1.1.1.2 ! root      929:                        p=strchr(arg,' ');
1.1       root      930:                        if(!p)
                    931:                                break;
                    932:                        *p=0;
                    933:                        writecrc(src,arg);
                    934:                        writecstr(arg2);
                    935:                        continue; }
                    936:                if((!stricmp(p,"STRSTR") || !stricmp(p,"COMPARE_SUBSTR"))
                    937:                        && strchr(arg,'"')) {
                    938:                        fputc(CS_VAR_INSTRUCTION,out);
                    939:                        fputc(STRSTR_VAR,out);
1.1.1.2 ! root      940:                        p=strchr(arg,' ');
1.1       root      941:                        if(!p)
                    942:                                break;
                    943:                        *p=0;
                    944:                        writecrc(src,arg);
                    945:                        writecstr(arg2);
                    946:                        continue; }
                    947:                if(!stricmp(p,"STRSTR") || !stricmp(p,"COMPARE_SUBSTR")) {
                    948:                        if(!(*arg)) break;
                    949:                        fputc(CS_VAR_INSTRUCTION,out);
                    950:                        fputc(STRSTR_VARS,out);
1.1.1.2 ! root      951:                        p=strchr(arg,' ');
1.1       root      952:                        if(!p)
                    953:                                break;
                    954:                        *p=0;
                    955:                        writecrc(src,arg);
                    956:                        writecrc(src,arg2);
                    957:                        continue; }
1.1.1.2 ! root      958:                if(!stricmp(p,"COPY_CHAR") || !stricmp(p,"COPY_KEY")) {
        !           959:                        if(!(*arg)) break;
        !           960:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,COPY_CHAR);
        !           961:                        writecrc(src,arg);
        !           962:                        continue; }
1.1       root      963:                if(!stricmp(p,"COPY_FIRST_CHAR")) {
1.1.1.2 ! root      964:                        if(!(*arg) || !(*arg2)) break;
1.1       root      965:                        fputc(CS_VAR_INSTRUCTION,out);
                    966:                        fputc(COPY_FIRST_CHAR,out);
                    967:                        writecrc(src,arg);
                    968:                        writecrc(src,arg2);
                    969:                        continue; }
                    970:                if(!stricmp(p,"COMPARE_FIRST_CHAR")) {
1.1.1.2 ! root      971:                        if(!(*arg) || !(*arg2)) break;
1.1       root      972:                        fputc(CS_VAR_INSTRUCTION,out);
                    973:                        fputc(COMPARE_FIRST_CHAR,out);
                    974:                        writecrc(src,arg);
                    975:                        fputc((uchar)val(src,arg2),out);
                    976:                        continue; }
                    977:                if(!stricmp(p,"CAT_STR_VARS") || !stricmp(p,"STRCAT")) {
                    978:                        if(!(*arg)) break;
                    979:                        fputc(CS_VAR_INSTRUCTION,out);
                    980:                        fputc(CAT_STR_VARS,out);
1.1.1.2 ! root      981:                        p=strchr(arg,' ');
1.1       root      982:                        if(!p)
                    983:                                break;
                    984:                        *p=0;
                    985:                        writecrc(src,arg);
                    986:                        writecrc(src,arg2);
                    987:                        continue; }
                    988:                if(!stricmp(p,"FORMAT") || !stricmp(p,"SPRINTF")) {
                    989:                        if(!(*arg)) break;
                    990:                        fputc(CS_VAR_INSTRUCTION,out);
                    991:                        fputc(FORMAT_STR_VAR,out);
1.1.1.2 ! root      992:                        p=strchr(arg,' ');
1.1       root      993:                        if(!p)
                    994:                                break;
                    995:                        *p=0;
                    996:                        writecrc(src,arg);                                      /* Write destination variable */
                    997:                        p++;
1.1.1.2 ! root      998:                        while(*p && *p<=' ') p++;
1.1       root      999:                        arg=p;
                   1000:                        p=strrchr(arg,'"');
                   1001:                        if(!p)
                   1002:                                break;
                   1003:                        *p=0;
                   1004:                        p++;
1.1.1.2 ! root     1005:                        while(*p && *p<=' ') p++;
1.1       root     1006:                        writecstr(arg);                 /* Write string */
                   1007:                        l=ftell(out);
                   1008:                        fputc(0,out);                   /* Write total number of args */
                   1009:                        i=0;
                   1010:                        while(p && *p) {
                   1011:                                arg=p;
1.1.1.2 ! root     1012:                                p=strchr(arg,' ');
1.1       root     1013:                                if(p) {
                   1014:                                        *p=0;
                   1015:                                        p++; }
                   1016:                                writecrc(src,arg);
                   1017:                                i++; }
                   1018:                        fseek(out,l,SEEK_SET);
                   1019:                        fputc((char)i,out);
                   1020:                        fseek(out,i*4,SEEK_CUR);
                   1021:                        continue; }
                   1022: 
                   1023:                if(!stricmp(p,"STRFTIME") || !stricmp(p,"FTIME_STR")) {
                   1024:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
                   1025:                        fputc(CS_VAR_INSTRUCTION,out);
                   1026:                        fputc(FORMAT_TIME_STR,out);
1.1.1.2 ! root     1027:                        p=strchr(arg,' ');
1.1       root     1028:                        if(!p)
                   1029:                                break;
                   1030:                        *p=0;
                   1031:                        writecrc(src,arg);                                      /* Write destination variable */
                   1032:                        p++;
1.1.1.2 ! root     1033:                        while(*p && *p<=' ') p++;
1.1       root     1034:                        arg=p;
                   1035:                        p=strrchr(arg,'"');
                   1036:                        if(!p)
                   1037:                                break;
                   1038:                        *p=0;
                   1039:                        writecstr(arg);                 /* Write string */
                   1040:                        p++;
1.1.1.2 ! root     1041:                        while(*p && *p<=' ') p++;
1.1       root     1042:                        writecrc(src,p);
                   1043:                        continue; }
                   1044: 
                   1045:                if(!stricmp(p,"TIME_STR")) {
                   1046:                        if(!(*arg)) break;
                   1047:                        fputc(CS_VAR_INSTRUCTION,out);
                   1048:                        fputc(TIME_STR,out);
1.1.1.2 ! root     1049:                        p=strchr(arg,' ');
1.1       root     1050:                        if(!p)
                   1051:                                break;
                   1052:                        *p=0;
                   1053:                        writecrc(src,arg);
                   1054:                        writecrc(src,arg2);
                   1055:                        continue; }
                   1056: 
                   1057:                if(!stricmp(p,"DATE_STR")) {
                   1058:                        if(!(*arg)) break;
                   1059:                        fputc(CS_VAR_INSTRUCTION,out);
                   1060:                        fputc(DATE_STR,out);
1.1.1.2 ! root     1061:                        p=strchr(arg,' ');
1.1       root     1062:                        if(!p)
                   1063:                                break;
                   1064:                        *p=0;
                   1065:                        writecrc(src,arg);
                   1066:                        writecrc(src,arg2);
                   1067:                        continue; }
                   1068: 
                   1069:                if(!stricmp(p,"SECOND_STR")) {
                   1070:                        if(!(*arg)) break;
                   1071:                        fputc(CS_VAR_INSTRUCTION,out);
                   1072:                        fputc(SECOND_STR,out);
1.1.1.2 ! root     1073:                        p=strchr(arg,' ');
1.1       root     1074:                        if(!p)
                   1075:                                break;
                   1076:                        *p=0;
                   1077:                        writecrc(src,arg);
                   1078:                        writecrc(src,arg2);
                   1079:                        continue; }
                   1080: 
                   1081: 
                   1082:                if(!stricmp(p,"SET_INT_VAR")
                   1083:                        || (!stricmp(p,"SET") && *arg2!='"')) {
                   1084:                        if(!(*arg)) break;
                   1085:                        fputc(CS_VAR_INSTRUCTION,out);
                   1086:                        fputc(SET_INT_VAR,out);
1.1.1.2 ! root     1087:                        p=strchr(arg,' ');
1.1       root     1088:                        if(!p)
                   1089:                                break;
                   1090:                        *p=0;
                   1091:                        writecrc(src,arg);
                   1092:                        l=val(src,arg2);
                   1093:                        fwrite(&l,4,1,out);
                   1094:                        continue; }
                   1095: 
                   1096:                if(!stricmp(p,"COMPARE_STR_VAR") ||
                   1097:                        (!stricmp(p,"COMPARE") && *arg2=='"')) {
                   1098:                        if(!(*arg)) break;
                   1099:                        fputc(CS_VAR_INSTRUCTION,out);
                   1100:                        fputc(COMPARE_STR_VAR,out);
1.1.1.2 ! root     1101:                        p=strchr(arg,' ');
1.1       root     1102:                        if(!p)
                   1103:                                break;
                   1104:                        *p=0;
                   1105:                        writecrc(src,arg);
                   1106:                        writecstr(arg2);
                   1107:                        continue; }
                   1108: 
                   1109:                if(!stricmp(p,"COMPARE_STRN_VAR") ||
                   1110:                        ((!stricmp(p,"STRNCMP") || !stricmp(p,"COMPARE_STRN"))
                   1111:                                && *arg3 && strchr(arg3,'"'))) {
                   1112:                        if((l=isvar(arg))!=0) {
                   1113:                                fputc(CS_USE_INT_VAR,out);
                   1114:                                fwrite(&l,4,1,out); // variable
                   1115:                                fputc(2,out);           // int offset
                   1116:                                fputc(1,out);           // int length
                   1117:                                i=0; }                          // place holder
                   1118:                        else
                   1119:                                i=val(src,arg);
                   1120:                        fputc(CS_VAR_INSTRUCTION,out);
                   1121:                        fputc(STRNCMP_VAR,out);
                   1122:                        fwrite(&i,1,1,out); /* Length */
1.1.1.2 ! root     1123:                        p=strchr(arg2,' ');
1.1       root     1124:                        if(!p)
                   1125:                                break;
                   1126:                        *p=0;
                   1127:                        p++;
1.1.1.2 ! root     1128:                        while(*p && *p<=' ') p++;
1.1       root     1129:                        writecrc(src,arg2);
                   1130:                        writecstr(p);
                   1131:                        continue; }
                   1132: 
                   1133:                if(!stricmp(p,"COMPARE_STRN_VARS") || !stricmp(p,"STRNCMP")
                   1134:                        || !stricmp(p,"COMPARE_STRN")) {
                   1135:                        if(!(*arg) || !(*arg2) || !(*arg3))
                   1136:                                break;
                   1137:                        if((l=isvar(arg))!=0) {
                   1138:                                fputc(CS_USE_INT_VAR,out);
                   1139:                                fwrite(&l,4,1,out); // variable
                   1140:                                fputc(2,out);           // int offset
                   1141:                                fputc(1,out);           // int length
                   1142:                                i=0; }                          // place holder
                   1143:                        else
                   1144:                                i=val(src,arg);
                   1145:                        fputc(CS_VAR_INSTRUCTION,out);
                   1146:                        fputc(STRNCMP_VARS,out);
                   1147: 
                   1148:                        fwrite(&i,1,1,out); /* Length */
1.1.1.2 ! root     1149:                        p=strchr(arg2,' ');
1.1       root     1150:                        if(!p)
                   1151:                                break;
                   1152:                        *p=0;
                   1153:                        p++;
1.1.1.2 ! root     1154:                        while(*p && *p<=' ') p++;
1.1       root     1155:                        writecrc(src,arg2);
                   1156:                        writecrc(src,p);
                   1157:                        continue; }
                   1158: 
                   1159:                if(!stricmp(p,"COMPARE_INT_VAR") ||
                   1160:                        (!stricmp(p,"COMPARE")
                   1161:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1162:                        if(!(*arg)) break;
                   1163: 
                   1164:                        fputc(CS_VAR_INSTRUCTION,out);
                   1165:                        fputc(COMPARE_INT_VAR,out);
1.1.1.2 ! root     1166:                        p=strchr(arg,' ');
1.1       root     1167:                        if(!p)
                   1168:                                break;
                   1169:                        *p=0;
                   1170:                        writecrc(src,arg);
                   1171:                        l=val(src,arg2);
                   1172:                        fwrite(&l,4,1,out);
                   1173:                        continue; }
                   1174: 
                   1175:                if(!stricmp(p,"COMPARE")) {
                   1176:                        if(!(*arg)) break;
                   1177:                        fputc(CS_VAR_INSTRUCTION,out);
                   1178:                        fputc(COMPARE_VARS,out);
1.1.1.2 ! root     1179:                        p=strchr(arg,' ');
1.1       root     1180:                        if(!p)
                   1181:                                break;
                   1182:                        *p=0;
                   1183:                        writecrc(src,arg);
                   1184:                        writecrc(src,arg2);
                   1185:                        continue; }
                   1186:                if(!stricmp(p,"COPY")) {
                   1187:                        if(!(*arg)) break;
                   1188:                        fputc(CS_VAR_INSTRUCTION,out);
                   1189:                        fputc(COPY_VAR,out);
1.1.1.2 ! root     1190:                        p=strchr(arg,' ');
1.1       root     1191:                        if(!p)
                   1192:                                break;
                   1193:                        *p=0;
                   1194:                        writecrc(src,arg);
                   1195:                        writecrc(src,arg2);
                   1196:                        continue; }
                   1197:                if(!stricmp(p,"SWAP")) {
                   1198:                        if(!(*arg)) break;
                   1199:                        fputc(CS_VAR_INSTRUCTION,out);
                   1200:                        fputc(SWAP_VARS,out);
1.1.1.2 ! root     1201:                        p=strchr(arg,' ');
1.1       root     1202:                        if(!p)
                   1203:                                break;
                   1204:                        *p=0;
                   1205:                        writecrc(src,arg);
                   1206:                        writecrc(src,arg2);
                   1207:                        continue; }
                   1208: 
                   1209:                if(!stricmp(p,"TIME")) {
                   1210:                        if(!(*arg)) break;
                   1211:                        fputc(CS_VAR_INSTRUCTION,out);
                   1212:                        fputc(TIME_INT_VAR,out);
                   1213:                        writecrc(src,arg);
                   1214:                        continue; }
                   1215: 
                   1216:                if(!stricmp(p,"DATE_INT")) {
                   1217:                        if(!(*arg)) break;
                   1218:                        fputc(CS_VAR_INSTRUCTION,out);
                   1219:                        fputc(DATE_STR_TO_INT,out);
1.1.1.2 ! root     1220:                        p=strchr(arg,' ');
1.1       root     1221:                        if(!p)
                   1222:                                break;
                   1223:                        *p=0;
                   1224:                        writecrc(src,arg);
                   1225:                        writecrc(src,arg2);
                   1226:                        continue; }
                   1227: 
                   1228:                if(!stricmp(p,"CRC16")) {
                   1229:                        if(!(*arg)) break;
                   1230:                        fputc(CS_VAR_INSTRUCTION,out);
                   1231:                        fputc(CRC16_TO_INT,out);
1.1.1.2 ! root     1232:                        p=strchr(arg,' ');
1.1       root     1233:                        if(!p)
                   1234:                                break;
                   1235:                        *p=0;
                   1236:                        writecrc(src,arg);
                   1237:                        writecrc(src,arg2);
                   1238:                        continue; }
                   1239: 
                   1240:                if(!stricmp(p,"CRC32")) {
                   1241:                        if(!(*arg)) break;
                   1242:                        fputc(CS_VAR_INSTRUCTION,out);
                   1243:                        fputc(CRC32_TO_INT,out);
1.1.1.2 ! root     1244:                        p=strchr(arg,' ');
1.1       root     1245:                        if(!p)
                   1246:                                break;
                   1247:                        *p=0;
                   1248:                        writecrc(src,arg);
                   1249:                        writecrc(src,arg2);
                   1250:                        continue; }
                   1251: 
                   1252:                if(!stricmp(p,"CHKSUM")) {
                   1253:                        if(!(*arg)) break;
                   1254:                        fputc(CS_VAR_INSTRUCTION,out);
                   1255:                        fputc(CHKSUM_TO_INT,out);
1.1.1.2 ! root     1256:                        p=strchr(arg,' ');
1.1       root     1257:                        if(!p)
                   1258:                                break;
                   1259:                        *p=0;
                   1260:                        writecrc(src,arg);
                   1261:                        writecrc(src,arg2);
                   1262:                        continue; }
                   1263: 
                   1264:                if(!stricmp(p,"ADD_INT_VAR")
                   1265:                        || (!stricmp(p,"ADD")
                   1266:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1267:                        if(!(*arg)) break;
                   1268:                        fputc(CS_VAR_INSTRUCTION,out);
                   1269:                        fputc(ADD_INT_VAR,out);
1.1.1.2 ! root     1270:                        p=strchr(arg,' ');
1.1       root     1271:                        if(!p)
                   1272:                                break;
                   1273:                        *p=0;
                   1274:                        writecrc(src,arg);
                   1275:                        l=val(src,arg2);
                   1276:                        if(!l)
                   1277:                                break;
                   1278:                        fwrite(&l,4,1,out);
                   1279:                        continue; }
                   1280:                if(!stricmp(p,"ADD_INT_VARS") || !stricmp(p,"ADD")) {
                   1281:                        if(!(*arg)) break;
                   1282:                        fputc(CS_VAR_INSTRUCTION,out);
                   1283:                        fputc(ADD_INT_VARS,out);
1.1.1.2 ! root     1284:                        p=strchr(arg,' ');
1.1       root     1285:                        if(!p)
                   1286:                                break;
                   1287:                        *p=0;
                   1288:                        writecrc(src,arg);
                   1289:                        writecrc(src,arg2);
                   1290:                        continue; }
                   1291: 
                   1292:                if(!stricmp(p,"SUB_INT_VAR")
                   1293:                        || (!stricmp(p,"SUB")
                   1294:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1295:                        if(!(*arg)) break;
                   1296:                        fputc(CS_VAR_INSTRUCTION,out);
                   1297:                        fputc(SUB_INT_VAR,out);
1.1.1.2 ! root     1298:                        p=strchr(arg,' ');
1.1       root     1299:                        if(!p)
                   1300:                                break;
                   1301:                        *p=0;
                   1302:                        writecrc(src,arg);
                   1303:                        l=val(src,arg2);
                   1304:                        if(!l)
                   1305:                                break;
                   1306:                        fwrite(&l,4,1,out);
                   1307:                        continue; }
                   1308:                if(!stricmp(p,"SUB_INT_VARS") || !stricmp(p,"SUB")) {
                   1309:                        if(!(*arg)) break;
                   1310:                        fputc(CS_VAR_INSTRUCTION,out);
                   1311:                        fputc(SUB_INT_VARS,out);
1.1.1.2 ! root     1312:                        p=strchr(arg,' ');
1.1       root     1313:                        if(!p)
                   1314:                                break;
                   1315:                        *p=0;
                   1316:                        writecrc(src,arg);
                   1317:                        writecrc(src,arg2);
                   1318:                        continue; }
                   1319: 
                   1320:                if(!stricmp(p,"MUL_INT_VAR")
                   1321:                        || (!stricmp(p,"MUL")
                   1322:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1323:                        if(!(*arg)) break;
                   1324:                        fputc(CS_VAR_INSTRUCTION,out);
                   1325:                        fputc(MUL_INT_VAR,out);
1.1.1.2 ! root     1326:                        p=strchr(arg,' ');
1.1       root     1327:                        if(!p)
                   1328:                                break;
                   1329:                        *p=0;
                   1330:                        writecrc(src,arg);
                   1331:                        l=val(src,arg2);
                   1332:                        if(!l)
                   1333:                                break;
                   1334:                        fwrite(&l,4,1,out);
                   1335:                        continue; }
                   1336:                if(!stricmp(p,"MUL_INT_VARS") || !stricmp(p,"MUL")) {
                   1337:                        if(!(*arg)) break;
                   1338:                        fputc(CS_VAR_INSTRUCTION,out);
                   1339:                        fputc(MUL_INT_VARS,out);
1.1.1.2 ! root     1340:                        p=strchr(arg,' ');
1.1       root     1341:                        if(!p)
                   1342:                                break;
                   1343:                        *p=0;
                   1344:                        writecrc(src,arg);
                   1345:                        writecrc(src,arg2);
                   1346:                        continue; }
                   1347: 
                   1348:                if(!stricmp(p,"DIV_INT_VAR")
                   1349:                        || (!stricmp(p,"DIV")
                   1350:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1351:                        if(!(*arg)) break;
                   1352:                        fputc(CS_VAR_INSTRUCTION,out);
                   1353:                        fputc(DIV_INT_VAR,out);
1.1.1.2 ! root     1354:                        p=strchr(arg,' ');
1.1       root     1355:                        if(!p)
                   1356:                                break;
                   1357:                        *p=0;
                   1358:                        writecrc(src,arg);
                   1359:                        l=val(src,arg2);
                   1360:                        if(!l)
                   1361:                                break;
                   1362:                        fwrite(&l,4,1,out);
                   1363:                        continue; }
                   1364:                if(!stricmp(p,"DIV_INT_VARS") || !stricmp(p,"DIV")) {
                   1365:                        if(!(*arg)) break;
                   1366:                        fputc(CS_VAR_INSTRUCTION,out);
                   1367:                        fputc(DIV_INT_VARS,out);
1.1.1.2 ! root     1368:                        p=strchr(arg,' ');
1.1       root     1369:                        if(!p)
                   1370:                                break;
                   1371:                        *p=0;
                   1372:                        writecrc(src,arg);
                   1373:                        writecrc(src,arg2);
                   1374:                        continue; }
                   1375: 
                   1376:                if(!stricmp(p,"MOD_INT_VAR")
                   1377:                        || (!stricmp(p,"MOD")
                   1378:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1379:                        if(!(*arg)) break;
                   1380:                        fputc(CS_VAR_INSTRUCTION,out);
                   1381:                        fputc(MOD_INT_VAR,out);
1.1.1.2 ! root     1382:                        p=strchr(arg,' ');
1.1       root     1383:                        if(!p)
                   1384:                                break;
                   1385:                        *p=0;
                   1386:                        writecrc(src,arg);
                   1387:                        l=val(src,arg2);
                   1388:                        if(!l)
                   1389:                                break;
                   1390:                        fwrite(&l,4,1,out);
                   1391:                        continue; }
                   1392:                if(!stricmp(p,"MOD_INT_VARS") || !stricmp(p,"MOD")) {
                   1393:                        if(!(*arg)) break;
                   1394:                        fputc(CS_VAR_INSTRUCTION,out);
                   1395:                        fputc(MOD_INT_VARS,out);
1.1.1.2 ! root     1396:                        p=strchr(arg,' ');
1.1       root     1397:                        if(!p)
                   1398:                                break;
                   1399:                        *p=0;
                   1400:                        writecrc(src,arg);
                   1401:                        writecrc(src,arg2);
                   1402:                        continue; }
                   1403: 
                   1404:                if(!stricmp(p,"AND_INT_VAR")
                   1405:                        || (!stricmp(p,"AND")
                   1406:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1407:                        if(!(*arg)) break;
                   1408:                        fputc(CS_VAR_INSTRUCTION,out);
                   1409:                        fputc(AND_INT_VAR,out);
1.1.1.2 ! root     1410:                        p=strchr(arg,' ');
1.1       root     1411:                        if(!p)
                   1412:                                break;
                   1413:                        *p=0;
                   1414:                        writecrc(src,arg);
                   1415:                        l=val(src,arg2);
                   1416:                        fwrite(&l,4,1,out);
                   1417:                        continue; }
                   1418:                if(!stricmp(p,"AND_INT_VARS") || !stricmp(p,"AND")) {
                   1419:                        if(!(*arg)) break;
                   1420:                        fputc(CS_VAR_INSTRUCTION,out);
                   1421:                        fputc(AND_INT_VARS,out);
1.1.1.2 ! root     1422:                        p=strchr(arg,' ');
1.1       root     1423:                        if(!p)
                   1424:                                break;
                   1425:                        *p=0;
                   1426:                        writecrc(src,arg);
                   1427:                        writecrc(src,arg2);
                   1428:                        continue; }
                   1429: 
1.1.1.2 ! root     1430:                if(!stricmp(p,"COMPARE_ANY_BITS") || !stricmp(p,"COMPARE_ALL_BITS")) {
        !          1431:                        if(!(*arg) || !(*arg2))
        !          1432:                                break;
        !          1433:                        if((l=isvar(arg2))!=0) {
        !          1434:                                fputc(CS_USE_INT_VAR,out);
        !          1435:                                fwrite(&l,4,1,out); // variable
        !          1436:                                fputc(6,out);           // int offset
        !          1437:                                fputc(4,out);           // int length
        !          1438:                                l=0; }                          // place holder
        !          1439:                        else
        !          1440:                                l=val(src,arg2);
        !          1441:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION
        !          1442:                                ,!stricmp(p,"COMPARE_ANY_BITS") ? COMPARE_ANY_BITS : COMPARE_ALL_BITS);
        !          1443:                        writecrc(src,arg);
        !          1444:                        fwrite(&l,sizeof(l),1,out);
        !          1445:                        continue;
        !          1446:                }
        !          1447: 
1.1       root     1448:                if(!stricmp(p,"OR_INT_VAR")
                   1449:                        || (!stricmp(p,"OR")
                   1450:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1451:                        if(!(*arg)) break;
                   1452:                        fputc(CS_VAR_INSTRUCTION,out);
                   1453:                        fputc(OR_INT_VAR,out);
1.1.1.2 ! root     1454:                        p=strchr(arg,' ');
1.1       root     1455:                        if(!p)
                   1456:                                break;
                   1457:                        *p=0;
                   1458:                        writecrc(src,arg);
                   1459:                        l=val(src,arg2);
                   1460:                        fwrite(&l,4,1,out);
                   1461:                        continue; }
                   1462:                if(!stricmp(p,"OR_INT_VARS") || !stricmp(p,"OR")) {
                   1463:                        if(!(*arg)) break;
                   1464:                        fputc(CS_VAR_INSTRUCTION,out);
                   1465:                        fputc(OR_INT_VARS,out);
1.1.1.2 ! root     1466:                        p=strchr(arg,' ');
1.1       root     1467:                        if(!p)
                   1468:                                break;
                   1469:                        *p=0;
                   1470:                        writecrc(src,arg);
                   1471:                        writecrc(src,arg2);
                   1472:                        continue; }
                   1473: 
                   1474:                if(!stricmp(p,"NOT_INT_VAR")
                   1475:                        || (!stricmp(p,"NOT")
                   1476:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1477:                        if(!(*arg)) break;
                   1478:                        fputc(CS_VAR_INSTRUCTION,out);
                   1479:                        fputc(NOT_INT_VAR,out);
1.1.1.2 ! root     1480:                        p=strchr(arg,' ');
1.1       root     1481:                        if(!p)
                   1482:                                break;
                   1483:                        *p=0;
                   1484:                        writecrc(src,arg);
                   1485:                        l=val(src,arg2);
                   1486:                        fwrite(&l,4,1,out);
                   1487:                        continue; }
                   1488:                if(!stricmp(p,"NOT_INT_VARS") || !stricmp(p,"NOT")) {
                   1489:                        if(!(*arg)) break;
                   1490:                        fputc(CS_VAR_INSTRUCTION,out);
                   1491:                        fputc(NOT_INT_VARS,out);
1.1.1.2 ! root     1492:                        p=strchr(arg,' ');
1.1       root     1493:                        if(!p)
                   1494:                                break;
                   1495:                        *p=0;
                   1496:                        writecrc(src,arg);
                   1497:                        writecrc(src,arg2);
                   1498:                        continue; }
                   1499: 
                   1500:                if(!stricmp(p,"XOR_INT_VAR")
                   1501:                        || (!stricmp(p,"XOR")
                   1502:                                && (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
                   1503:                        if(!(*arg)) break;
                   1504:                        fputc(CS_VAR_INSTRUCTION,out);
                   1505:                        fputc(XOR_INT_VAR,out);
1.1.1.2 ! root     1506:                        p=strchr(arg,' ');
1.1       root     1507:                        if(!p)
                   1508:                                break;
                   1509:                        *p=0;
                   1510:                        writecrc(src,arg);
                   1511:                        l=val(src,arg2);
                   1512:                        fwrite(&l,4,1,out);
                   1513:                        continue; }
                   1514:                if(!stricmp(p,"XOR_INT_VARS") || !stricmp(p,"XOR")) {
                   1515:                        if(!(*arg)) break;
                   1516:                        fputc(CS_VAR_INSTRUCTION,out);
                   1517:                        fputc(XOR_INT_VARS,out);
1.1.1.2 ! root     1518:                        p=strchr(arg,' ');
1.1       root     1519:                        if(!p)
                   1520:                                break;
                   1521:                        *p=0;
                   1522:                        writecrc(src,arg);
                   1523:                        writecrc(src,arg2);
                   1524:                        continue; }
                   1525: 
                   1526:                if(!stricmp(p,"RANDOM_INT_VAR") || !stricmp(p,"RANDOM")) {
                   1527:                        if(!(*arg)) break;
                   1528:                        if((l=isvar(arg2))!=0) {
                   1529:                                fputc(CS_USE_INT_VAR,out);
                   1530:                                fwrite(&l,4,1,out); // variable
                   1531:                                fputc(6,out);           // int offset
                   1532:                                fputc(4,out);           // int length
                   1533:                                l=0; }                          // place holder
                   1534:                        else
                   1535:                                l=val(src,arg2);
                   1536:                        fputc(CS_VAR_INSTRUCTION,out);
                   1537:                        fputc(RANDOM_INT_VAR,out);
1.1.1.2 ! root     1538:                        p=strchr(arg,' ');
1.1       root     1539:                        if(!p)
                   1540:                                break;
                   1541:                        *p=0;
                   1542:                        writecrc(src,arg);
                   1543:                        fwrite(&l,4,1,out);
                   1544:                        continue; }
                   1545: 
                   1546:                if(!stricmp(p,"SWITCH")) {
                   1547:                        if(!(*arg)) break;
                   1548:                        fputc(CS_SWITCH,out);
                   1549:                        writecrc(src,arg);
                   1550:                        continue; }
                   1551:                if(!stricmp(p,"END_SWITCH")) {
                   1552:                        fputc(CS_END_SWITCH,out);
                   1553:                        continue; }
                   1554:                if(!stricmp(p,"CASE")) {
                   1555:                        if(!(*arg)) break;
                   1556:                        fputc(CS_CASE,out);
                   1557:                        l=val(src,arg);
                   1558:                        fwrite(&l,4,1,out);
                   1559:                        continue; }
                   1560:                if(!stricmp(p,"DEFAULT")) {
                   1561:                        fputc(CS_DEFAULT,out);
                   1562:                        continue; }
                   1563:                if(!stricmp(p,"END_CASE")) {
                   1564:                        fputc(CS_END_CASE,out);
                   1565:                        continue; }
                   1566: 
                   1567:                if(!stricmp(p,"PRINT") && !strchr(arg,'"') && !strchr(arg,'\\')
1.1.1.2 ! root     1568:                        && !strchr(arg,' ')) {
1.1       root     1569:                        if(!(*arg)) break;
                   1570:                        fputc(CS_VAR_INSTRUCTION,out);
                   1571:                        fputc(PRINT_VAR,out);
                   1572:                        writecrc(src,arg);
                   1573:                        continue; }
                   1574: 
1.1.1.2 ! root     1575:                if(!stricmp(p,"PRINTF") || !stricmp(p,"LPRINTF") || !stricmp(p,"PRINTF_LOCAL")) {
1.1       root     1576:                        if(!(*arg)) break;
                   1577:                        fputc(CS_VAR_INSTRUCTION,out);
1.1.1.2 ! root     1578:                        if(!stricmp(p,"PRINTF"))
        !          1579:                                fputc(VAR_PRINTF,out);
        !          1580:                        else
        !          1581:                                fputc(VAR_PRINTF_LOCAL,out);
1.1       root     1582:                        p=strrchr(arg,'"');
                   1583:                        if(!p)
                   1584:                                break;
                   1585:                        *p=0;
                   1586:                        p++;
1.1.1.2 ! root     1587:                        while(*p && *p<=' ') p++;
1.1       root     1588:                        writecstr(arg);                 /* Write string */
                   1589:                        l=ftell(out);
                   1590:                        fputc(0,out);                   /* Write total number of args */
                   1591:                        i=0;
                   1592:                        while(p && *p) {
                   1593:                                arg=p;
1.1.1.2 ! root     1594:                                p=strchr(arg,' ');
1.1       root     1595:                                if(p) {
                   1596:                                        *p=0;
                   1597:                                        p++; }
                   1598:                                writecrc(src,arg);
                   1599:                                i++; }
                   1600:                        fseek(out,l,SEEK_SET);
                   1601:                        fputc((char)i,out);
                   1602:                        fseek(out,i*4,SEEK_CUR);
                   1603:                        continue; }
                   1604: 
                   1605:                if(!stricmp(p,"FOPEN")) {
                   1606:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
                   1607:                        if((l=isvar(arg2))!=0) {
                   1608:                                fputc(CS_USE_INT_VAR,out);
                   1609:                                fwrite(&l,4,1,out); // variable
                   1610:                                fputc(6,out);           // int offset
                   1611:                                fputc(2,out);           // int length
                   1612:                                i=0; }                          // place holder
                   1613:                        else
                   1614:                                i=val(src,arg2);
                   1615: 
                   1616:                        fputc(CS_FIO_FUNCTION,out);
                   1617:                        if(*arg3=='"')
                   1618:                                fputc(FIO_OPEN,out);
                   1619:                        else
                   1620:                                fputc(FIO_OPEN_VAR,out);
1.1.1.2 ! root     1621:                        p=strchr(arg,' ');
1.1       root     1622:                        if(!p)
                   1623:                                break;
                   1624:                        *p=0;
                   1625:                        writecrc(src,arg);
1.1.1.2 ! root     1626:                        p=strchr(arg2,' ');
1.1       root     1627:                        if(!p)
                   1628:                                break;
                   1629:                        *p=0;
                   1630:                        p++;
                   1631:                        fwrite(&i,2,1,out);
1.1.1.2 ! root     1632:                        while(*p && *p<=' ') p++;
1.1       root     1633:                        if(*p=='"')
                   1634:                                writestr(p);
                   1635:                        else
                   1636:                                writecrc(src,p);
                   1637:                        continue; }
                   1638:                if(!stricmp(p,"FCLOSE")) {
                   1639:                        if(!(*arg)) break;
                   1640:                        fputc(CS_FIO_FUNCTION,out);
                   1641:                        fputc(FIO_CLOSE,out);
                   1642:                        writecrc(src,arg);
                   1643:                        continue; }
                   1644:                if(!stricmp(p,"FFLUSH")) {
                   1645:                        if(!(*arg)) break;
                   1646:                        fputc(CS_FIO_FUNCTION,out);
                   1647:                        fputc(FIO_FLUSH,out);
                   1648:                        writecrc(src,arg);
                   1649:                        continue; }
                   1650:                if(!stricmp(p,"FREAD")) {
                   1651:                        if(!(*arg)) break;
                   1652: 
                   1653:                        fputc(CS_FIO_FUNCTION,out);
                   1654:                        if(!(*arg3) || isdigit(*arg3) || atoi(arg3))
                   1655:                                fputc(FIO_READ,out);
                   1656:                        else
                   1657:                                fputc(FIO_READ_VAR,out);
1.1.1.2 ! root     1658:                        p=strchr(arg,' ');
1.1       root     1659:                        if(!p)
                   1660:                                break;
                   1661:                        *p=0;
                   1662:                        writecrc(src,arg);                      /* File handle */
1.1.1.2 ! root     1663:                        p=strchr(arg2,' ');
1.1       root     1664:                        if(p)
                   1665:                                *p=0;
                   1666:                        writecrc(src,arg2);             /* Variable */
                   1667:                        if(isdigit(*arg3))
                   1668:                                i=val(src,arg3);         /* Length */
                   1669:                        else
                   1670:                                i=0;
                   1671:                        if(i || !(*arg3))
                   1672:                                fwrite(&i,2,1,out);
                   1673:                        else
                   1674:                                writecrc(src,arg3);
                   1675:                        continue; }
                   1676:                if(!stricmp(p,"FWRITE")) {
                   1677:                        if(!(*arg)) break;
                   1678:                        fputc(CS_FIO_FUNCTION,out);
                   1679:                        if(!(*arg3) || isdigit(*arg3) || atoi(arg3))
                   1680:                                fputc(FIO_WRITE,out);
                   1681:                        else
                   1682:                                fputc(FIO_WRITE_VAR,out);
1.1.1.2 ! root     1683:                        p=strchr(arg,' ');
1.1       root     1684:                        if(!p)
                   1685:                                break;
                   1686:                        *p=0;
                   1687:                        writecrc(src,arg);                      /* File handle */
1.1.1.2 ! root     1688:                        p=strchr(arg2,' ');
1.1       root     1689:                        if(p)
                   1690:                                *p=0;
                   1691:                        writecrc(src,arg2);             /* Variable */
                   1692:                        if(isdigit(*arg3))
                   1693:                                i=val(src,arg3);         /* Length */
                   1694:                        else
                   1695:                                i=0;
                   1696:                        if(i || !(*arg3))
                   1697:                                fwrite(&i,2,1,out);
                   1698:                        else
                   1699:                                writecrc(src,arg3);
                   1700:                        continue; }
                   1701:                if(!stricmp(p,"FGET_LENGTH")
                   1702:                        || !stricmp(p,"FGETLENGTH")
                   1703:                        || !stricmp(p,"GETFLENGTH")) {
                   1704:                        if(!(*arg) || !(*arg2)) break;
                   1705:                        fputc(CS_FIO_FUNCTION,out);
                   1706:                        fputc(FIO_GET_LENGTH,out);
1.1.1.2 ! root     1707:                        p=strchr(arg,' ');
1.1       root     1708:                        if(!p)
                   1709:                                break;
                   1710:                        *p=0;
                   1711:                        writecrc(src,arg);                      /* File handle */
                   1712:                        writecrc(src,arg2);             /* Variable */
                   1713:                        continue; }
                   1714:                if(!stricmp(p,"FREAD_LINE")) {
                   1715:                        if(!(*arg) || !(*arg2)) break;
                   1716:                        fputc(CS_FIO_FUNCTION,out);
                   1717:                        fputc(FIO_READ_LINE,out);
1.1.1.2 ! root     1718:                        p=strchr(arg,' ');
1.1       root     1719:                        if(!p)
                   1720:                                break;
                   1721:                        *p=0;
                   1722:                        writecrc(src,arg);                      /* File handle */
                   1723:                        writecrc(src,arg2);             /* Variable */
                   1724:                        continue; }
                   1725:                if(!stricmp(p,"FEOF")) {
                   1726:                        if(!(*arg)) break;
                   1727:                        fputc(CS_FIO_FUNCTION,out);
                   1728:                        fputc(FIO_EOF,out);
                   1729:                        writecrc(src,arg);
                   1730:                        continue; }
                   1731:                if(!stricmp(p,"FGET_POS")) {
                   1732:                        if(!(*arg) || !(*arg2)) break;
                   1733:                        fputc(CS_FIO_FUNCTION,out);
                   1734:                        fputc(FIO_GET_POS,out);
1.1.1.2 ! root     1735:                        p=strchr(arg,' ');
1.1       root     1736:                        if(!p)
                   1737:                                break;
                   1738:                        *p=0;
                   1739:                        writecrc(src,arg);                      /* File handle */
                   1740:                        writecrc(src,arg2);             /* Variable */
                   1741:                        continue; }
                   1742:                if(!stricmp(p,"FSET_POS") || !stricmp(p,"FSEEK")) {
                   1743:                        if(!(*arg)) break;
                   1744:                        fputc(CS_FIO_FUNCTION,out);
                   1745:                        if(isdigit(*arg2) || atol(arg2))
                   1746:                                fputc(FIO_SEEK,out);
                   1747:                        else
                   1748:                                fputc(FIO_SEEK_VAR,out);
1.1.1.2 ! root     1749:                        p=strchr(arg,' ');
1.1       root     1750:                        if(!p)
                   1751:                                break;
                   1752:                        *p=0;
                   1753:                        writecrc(src,arg);                      /* File handle */
1.1.1.2 ! root     1754:                        p=strchr(arg2,' ');
1.1       root     1755:                        if(p)
                   1756:                                *p=0;
                   1757:                        if(atol(arg2) || isdigit(*arg2)) {
                   1758:                                l=val(src,arg2);
                   1759:                                fwrite(&l,4,1,out); }
                   1760:                        else
                   1761:                                writecrc(src,arg2);             /* Offset variable */
                   1762:                        i=0;
                   1763:                        if(p) {
                   1764:                                p++;
1.1.1.2 ! root     1765:                                while(*p && *p<=' ') p++;
1.1       root     1766:                                i=atoi(p);
                   1767:                                if(!stricmp(p,"CUR"))
                   1768:                                        i=SEEK_CUR;
                   1769:                                else if(!stricmp(p,"END"))
                   1770:                                        i=SEEK_END; }
                   1771:                        fwrite(&i,2,1,out);
                   1772:                        continue; }
                   1773:                if(!stricmp(p,"FLOCK")) {
                   1774:                        if(!(*arg)) break;
                   1775:                        fputc(CS_FIO_FUNCTION,out);
                   1776:                        if(isdigit(*arg2) || atol(arg2))
                   1777:                                fputc(FIO_LOCK,out);
                   1778:                        else
                   1779:                                fputc(FIO_LOCK_VAR,out);
1.1.1.2 ! root     1780:                        p=strchr(arg,' ');
1.1       root     1781:                        if(!p)
                   1782:                                break;
                   1783:                        *p=0;
                   1784:                        writecrc(src,arg);                      /* File handle */
                   1785:                        if(atol(arg2) || isdigit(*arg2)) {
                   1786:                                l=val(src,arg2);
                   1787:                                if(!l)
                   1788:                                        break;
                   1789:                                fwrite(&l,4,1,out); }
                   1790:                        else
                   1791:                                writecrc(src,arg2);     /* Length variable */
                   1792:                        continue; }
                   1793:                if(!stricmp(p,"FUNLOCK")) {
                   1794:                        if(!(*arg)) break;
                   1795:                        fputc(CS_FIO_FUNCTION,out);
                   1796:                        if(isdigit(*arg2) || atol(arg2))
                   1797:                                fputc(FIO_UNLOCK,out);
                   1798:                        else
                   1799:                                fputc(FIO_UNLOCK_VAR,out);
1.1.1.2 ! root     1800:                        p=strchr(arg,' ');
1.1       root     1801:                        if(!p)
                   1802:                                break;
                   1803:                        *p=0;
                   1804:                        writecrc(src,arg);                      /* File handle */
                   1805:                        if(atol(arg2) || isdigit(*arg2)) {
                   1806:                                l=val(src,arg2);
                   1807:                                if(!l)
                   1808:                                        break;
                   1809:                                fwrite(&l,4,1,out); }
                   1810:                        else
                   1811:                                writecrc(src,arg2);             /* Length variable */
                   1812:                        continue; }
                   1813:                if(!stricmp(p,"FSET_LENGTH")) {
                   1814:                        if(!(*arg)) break;
                   1815:                        fputc(CS_FIO_FUNCTION,out);
                   1816:                        if(isdigit(*arg2) || atol(arg2))
                   1817:                                fputc(FIO_SET_LENGTH,out);
                   1818:                        else
                   1819:                                fputc(FIO_SET_LENGTH_VAR,out);
1.1.1.2 ! root     1820:                        p=strchr(arg,' ');
1.1       root     1821:                        if(!p)
                   1822:                                break;
                   1823:                        *p=0;
                   1824:                        writecrc(src,arg);                      /* File handle */
                   1825:                        if(atol(arg2) || isdigit(*arg2)) {
                   1826:                                l=val(src,arg2);
                   1827:                                fwrite(&l,4,1,out); }
                   1828:                        else
                   1829:                                writecrc(src,arg2);             /* Length variable */
                   1830:                        continue; }
                   1831:                if(!stricmp(p,"FPRINTF")) {
                   1832:                        if(!(*arg)) break;
                   1833:                        fputc(CS_FIO_FUNCTION,out);
                   1834:                        fputc(FIO_PRINTF,out);
1.1.1.2 ! root     1835:                        p=strchr(arg,' ');
1.1       root     1836:                        if(!p)
                   1837:                                break;
                   1838:                        *p=0;
                   1839:                        writecrc(src,arg);                                      /* Write destination variable */
                   1840:                        p++;
1.1.1.2 ! root     1841:                        while(*p && *p<=' ') p++;
1.1       root     1842:                        arg=p;
                   1843:                        p=strrchr(arg,'"');
                   1844:                        if(!p)
                   1845:                                break;
                   1846:                        *p=0;
                   1847:                        p++;
1.1.1.2 ! root     1848:                        while(*p && *p<=' ') p++;
1.1       root     1849:                        writecstr(arg);                 /* Write string */
                   1850:                        l=ftell(out);
                   1851:                        fputc(0,out);                   /* Write total number of args */
                   1852:                        i=0;
                   1853:                        while(p && *p) {
                   1854:                                arg=p;
1.1.1.2 ! root     1855:                                p=strchr(arg,' ');
1.1       root     1856:                                if(p) {
                   1857:                                        *p=0;
                   1858:                                        p++; }
                   1859:                                writecrc(src,arg);
                   1860:                                i++; }
                   1861:                        fseek(out,l,SEEK_SET);
                   1862:                        fputc((char)i,out);
                   1863:                        fseek(out,i*4,SEEK_CUR);
                   1864:                        continue; }
                   1865:                if(!stricmp(p,"FSET_ETX")) {
                   1866:                        if(!(*arg)) break;
                   1867:                        if((l=isvar(arg))!=0) {
                   1868:                                fputc(CS_USE_INT_VAR,out);
                   1869:                                fwrite(&l,4,1,out); // variable
                   1870:                                fputc(2,out);       // int offset
                   1871:                                fputc(1,out);       // int length
                   1872:                                ch=0; }                         // place holder
                   1873:                        else
                   1874:                                ch=val(src,arg);
                   1875: 
                   1876:                        fputc(CS_FIO_FUNCTION,out);
                   1877:                        fputc(FIO_SET_ETX,out);
                   1878:                        fwrite(&ch,1,1,out);
                   1879:                        continue; }
                   1880:                if(!stricmp(p,"FGET_TIME")) {
                   1881:                        if(!(*arg) || !(*arg2)) break;
                   1882:                        fputc(CS_FIO_FUNCTION,out);
                   1883:                        fputc(FIO_GET_TIME,out);
1.1.1.2 ! root     1884:                        p=strchr(arg,' ');
1.1       root     1885:                        if(!p)
                   1886:                                break;
                   1887:                        *p=0;
                   1888:                        writecrc(src,arg);                      /* File handle */
                   1889:                        writecrc(src,arg2);             /* Variable */
                   1890:                        continue; }
                   1891:                if(!stricmp(p,"FSET_TIME")) {
                   1892:                        if(!(*arg) || !(*arg2)) break;
                   1893:                        fputc(CS_FIO_FUNCTION,out);
                   1894:                        fputc(FIO_SET_TIME,out);
1.1.1.2 ! root     1895:                        p=strchr(arg,' ');
1.1       root     1896:                        if(!p)
                   1897:                                break;
                   1898:                        *p=0;
                   1899:                        writecrc(src,arg);                      /* File handle */
                   1900:                        writecrc(src,arg2);             /* Variable */
                   1901:                        continue; }
                   1902:                if(!stricmp(p,"REMOVE_FILE")) {
                   1903:                        if(!(*arg)) break;
                   1904:                        fputc(CS_FIO_FUNCTION,out);
                   1905:                        fputc(REMOVE_FILE,out);
                   1906:                        writecrc(src,arg);                      /* Str var */
                   1907:                        continue; }
                   1908:                if(!stricmp(p,"RENAME_FILE")) {
                   1909:                        if(!(*arg) || !(*arg2)) break;
                   1910:                        fputc(CS_FIO_FUNCTION,out);
                   1911:                        fputc(RENAME_FILE,out);
1.1.1.2 ! root     1912:                        p=strchr(arg,' ');
1.1       root     1913:                        if(!p)
                   1914:                                break;
                   1915:                        *p=0;
                   1916:                        writecrc(src,arg);                      /* str var */
                   1917:                        writecrc(src,arg2);             /* str var */
                   1918:                        continue; }
                   1919:                if(!stricmp(p,"COPY_FILE")) {
                   1920:                        if(!(*arg) || !(*arg2)) break;
                   1921:                        fputc(CS_FIO_FUNCTION,out);
                   1922:                        fputc(COPY_FILE,out);
1.1.1.2 ! root     1923:                        p=strchr(arg,' ');
1.1       root     1924:                        if(!p)
                   1925:                                break;
                   1926:                        *p=0;
                   1927:                        writecrc(src,arg);                      /* str var */
                   1928:                        writecrc(src,arg2);             /* str var */
                   1929:                        continue; }
                   1930:                if(!stricmp(p,"MOVE_FILE")) {
                   1931:                        if(!(*arg) || !(*arg2)) break;
                   1932:                        fputc(CS_FIO_FUNCTION,out);
                   1933:                        fputc(MOVE_FILE,out);
1.1.1.2 ! root     1934:                        p=strchr(arg,' ');
1.1       root     1935:                        if(!p)
                   1936:                                break;
                   1937:                        *p=0;
                   1938:                        writecrc(src,arg);                      /* str var */
                   1939:                        writecrc(src,arg2);             /* str var */
                   1940:                        continue; }
                   1941:                if(!stricmp(p,"GET_FILE_ATTRIB")) {
                   1942:                        if(!(*arg) || !(*arg2)) break;
                   1943:                        fputc(CS_FIO_FUNCTION,out);
                   1944:                        fputc(GET_FILE_ATTRIB,out);
1.1.1.2 ! root     1945:                        p=strchr(arg,' ');
1.1       root     1946:                        if(!p)
                   1947:                                break;
                   1948:                        *p=0;
                   1949:                        writecrc(src,arg);                      /* str var */
                   1950:                        writecrc(src,arg2);             /* int var */
                   1951:                        continue; }
                   1952:                if(!stricmp(p,"SET_FILE_ATTRIB")) {
                   1953:                        if(!(*arg) || !(*arg2)) break;
                   1954:                        fputc(CS_FIO_FUNCTION,out);
                   1955:                        fputc(SET_FILE_ATTRIB,out);
1.1.1.2 ! root     1956:                        p=strchr(arg,' ');
1.1       root     1957:                        if(!p)
                   1958:                                break;
                   1959:                        *p=0;
                   1960:                        writecrc(src,arg);                      /* str var */
                   1961:                        writecrc(src,arg2);             /* int var */
                   1962:                        continue; }
                   1963:                if(!stricmp(p,"RMDIR") || !stricmp(p,"REMOVE_DIR")) {
                   1964:                        if(!(*arg)) break;
                   1965:                        fputc(CS_FIO_FUNCTION,out);
                   1966:                        fputc(REMOVE_DIR,out);
                   1967:                        writecrc(src,arg);                      /* Str var */
                   1968:                        continue; }
                   1969:                if(!stricmp(p,"MKDIR") || !stricmp(p,"MAKE_DIR")) {
                   1970:                        if(!(*arg)) break;
                   1971:                        fputc(CS_FIO_FUNCTION,out);
                   1972:                        fputc(MAKE_DIR,out);
                   1973:                        writecrc(src,arg);                      /* Str var */
                   1974:                        continue; }
                   1975:                if(!stricmp(p,"CHDIR") || !stricmp(p,"CHANGE_DIR")) {
                   1976:                        if(!(*arg)) break;
                   1977:                        fputc(CS_FIO_FUNCTION,out);
                   1978:                        fputc(CHANGE_DIR,out);
                   1979:                        writecrc(src,arg);                      /* Str var */
                   1980:                        continue; }
                   1981:                if(!stricmp(p,"OPEN_DIR")) {
                   1982:                        if(!(*arg) || !(*arg2)) break;
                   1983:                        fputc(CS_FIO_FUNCTION,out);
                   1984:                        fputc(OPEN_DIR,out);
1.1.1.2 ! root     1985:                        p=strchr(arg,' ');
1.1       root     1986:                        if(!p)
                   1987:                                break;
                   1988:                        *p=0;
                   1989:                        writecrc(src,arg);                      /* int var */
                   1990:                        writecrc(src,arg2);             /* str var */
                   1991:                        continue; }
                   1992:                if(!stricmp(p,"READ_DIR")) {
                   1993:                        if(!(*arg) || !(*arg2)) break;
                   1994:                        fputc(CS_FIO_FUNCTION,out);
                   1995:                        fputc(READ_DIR,out);
1.1.1.2 ! root     1996:                        p=strchr(arg,' ');
1.1       root     1997:                        if(!p)
                   1998:                                break;
                   1999:                        *p=0;
                   2000:                        writecrc(src,arg);                      /* int var */
                   2001:                        writecrc(src,arg2);             /* str var */
                   2002:                        continue; }
                   2003:                if(!stricmp(p,"REWIND_DIR")) {
                   2004:                        if(!(*arg)) break;
                   2005:                        fputc(CS_FIO_FUNCTION,out);
                   2006:                        fputc(REWIND_DIR,out);
                   2007:                        writecrc(src,arg);                      /* int var */
                   2008:                        continue; }
                   2009:                if(!stricmp(p,"CLOSE_DIR")) {
                   2010:                        if(!(*arg)) break;
                   2011:                        fputc(CS_FIO_FUNCTION,out);
                   2012:                        fputc(CLOSE_DIR,out);
                   2013:                        writecrc(src,arg);                      /* int var */
                   2014:                        continue; }
                   2015: 
1.1.1.2 ! root     2016:                /* NET_FUNCTIONS */
        !          2017: 
        !          2018:                if(!stricmp(p,"SOCKET_OPEN")) {
        !          2019:                        if(!(*arg)) break;
        !          2020:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_OPEN);
        !          2021:                        writecrc(src,arg);                      /* int var (socket) */
        !          2022:                        continue;
        !          2023:                }
        !          2024:                if(!stricmp(p,"SOCKET_CLOSE")) {
        !          2025:                        if(!(*arg)) break;
        !          2026:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_CLOSE);
        !          2027:                        writecrc(src,arg);                      /* int var (socket) */
        !          2028:                        continue;
        !          2029:                }
        !          2030:                if(!stricmp(p,"SOCKET_CHECK")) {
        !          2031:                        if(!(*arg)) break;
        !          2032:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_CHECK);
        !          2033:                        writecrc(src,arg);                      /* int var (socket) */
        !          2034:                        continue;
        !          2035:                }
        !          2036:                if(!stricmp(p,"SOCKET_CONNECT")) {
        !          2037:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
        !          2038: 
        !          2039:                        /* TCP port */
        !          2040:                        if((l=isvar(arg3))!=0) {
        !          2041:                                fputc(CS_USE_INT_VAR,out);
        !          2042:                                fwrite(&l,4,1,out); // variable
        !          2043:                                fputc(10,out);          // int offset
        !          2044:                                fputc(2,out);           // int length
        !          2045:                                i=0; }                          // place holder
        !          2046:                        else
        !          2047:                                i=val(src,arg3);
        !          2048: 
        !          2049:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_CONNECT);
        !          2050:                        writecrc(src,arg);                      /* int var (socket) */
        !          2051:                        writecrc(src,arg2);                     /* str var (address) */
        !          2052:                        fwrite(&i,2,1,out);
        !          2053:                        continue;
        !          2054:                }
        !          2055:                if(!stricmp(p,"SOCKET_ACCEPT")) {
        !          2056:                        if(!(*arg)) break;
        !          2057:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_ACCEPT);
        !          2058:                        writecrc(src,arg);                      /* int var (socket) */
        !          2059:                        continue;
        !          2060:                }
        !          2061:                if(!stricmp(p,"SOCKET_NREAD")) {
        !          2062:                        if(!(*arg) || !(*arg2)) break;
        !          2063:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_NREAD);
        !          2064:                        writecrc(src,arg);                      /* int var (socket) */
        !          2065:                        writecrc(src,arg2);                     /* int var (nbytes) */
        !          2066:                        continue;
        !          2067:                }
        !          2068:                if(!stricmp(p,"SOCKET_READ") 
        !          2069:                        || !stricmp(p,"SOCKET_READLINE") 
        !          2070:                        || !stricmp(p,"SOCKET_PEEK")) {
        !          2071:                        if(!(*arg) || !(*arg2)) break;
        !          2072: 
        !          2073:                        /* length */
        !          2074:                        if(!(*arg3))
        !          2075:                                i=0;
        !          2076:                        else if((l=isvar(arg3))!=0) {
        !          2077:                                fputc(CS_USE_INT_VAR,out);
        !          2078:                                fwrite(&l,4,1,out); // variable
        !          2079:                                fputc(10,out);          // int offset
        !          2080:                                fputc(2,out);           // int length
        !          2081:                                i=0; }                          // place holder
        !          2082:                        else 
        !          2083:                                i=val(src,arg3);
        !          2084: 
        !          2085:                        if(!stricmp(p,"SOCKET_READ"))
        !          2086:                                ch=CS_SOCKET_READ;
        !          2087:                        else if(!stricmp(p,"SOCKET_READLINE"))
        !          2088:                                ch=CS_SOCKET_READLINE;
        !          2089:                        else
        !          2090:                                ch=CS_SOCKET_PEEK;
        !          2091:                        fprintf(out,"%c%c",CS_NET_FUNCTION,ch);
        !          2092:                        writecrc(src,arg);                      /* int var (socket) */
        !          2093:                        writecrc(src,arg2);                     /* str var (buffer) */
        !          2094:                        fwrite(&i,sizeof(i),1,out);     /* word (length) */
        !          2095:                        continue;
        !          2096:                }
        !          2097:                if(!stricmp(p,"SOCKET_WRITE")) {
        !          2098:                        if(!(*arg) || !(*arg2)) break;
        !          2099:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_SOCKET_WRITE);
        !          2100:                        writecrc(src,arg);                      /* int var (socket) */
        !          2101:                        writecrc(src,arg2);                     /* str var (buffer) */
        !          2102:                        continue;
        !          2103:                }
        !          2104: 
        !          2105:                /* FTP functions */
        !          2106:                if(!stricmp(p,"FTP_LOGIN")) {
        !          2107:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
        !          2108:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_LOGIN);
        !          2109:                        writecrc(src,arg);                      /* int var (socket) */
        !          2110:                        writecrc(src,arg2);                     /* int var (user) */
        !          2111:                        writecrc(src,arg3);                     /* int var (password) */
        !          2112:                        continue;
        !          2113:                }
        !          2114:                if(!stricmp(p,"FTP_LOGOUT")) {
        !          2115:                        if(!(*arg)) break;
        !          2116:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_LOGOUT);
        !          2117:                        writecrc(src,arg);                      /* int var (socket) */
        !          2118:                        continue;
        !          2119:                }
        !          2120:                if(!stricmp(p,"FTP_PWD")) {
        !          2121:                        if(!(*arg)) break;
        !          2122:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_PWD);
        !          2123:                        writecrc(src,arg);                      /* int var (socket) */
        !          2124:                        continue;
        !          2125:                }
        !          2126:                if(!stricmp(p,"FTP_CWD")) {
        !          2127:                        if(!(*arg) || !(*arg2)) break;
        !          2128:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_CWD);
        !          2129:                        writecrc(src,arg);                      /* int var (socket) */
        !          2130:                        writecrc(src,arg2);                     /* str var (path)       */
        !          2131:                        continue;
        !          2132:                }
        !          2133:                if(!stricmp(p,"FTP_DIR")) {
        !          2134:                        if(!(*arg) || !(*arg2)) break;
        !          2135:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_DIR);
        !          2136:                        writecrc(src,arg);                      /* int var (socket) */
        !          2137:                        writecrc(src,arg2);                     /* str var (path)       */
        !          2138:                        continue;
        !          2139:                }
        !          2140:                if(!stricmp(p,"FTP_GET")) {
        !          2141:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
        !          2142:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_GET);
        !          2143:                        writecrc(src,arg);                      /* int var (socket) */
        !          2144:                        writecrc(src,arg2);                     /* str var (src path) */
        !          2145:                        writecrc(src,arg3);                     /* str var (dest path) */
        !          2146:                        continue;
        !          2147:                }
        !          2148:                if(!stricmp(p,"FTP_PUT")) {
        !          2149:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
        !          2150:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_PUT);
        !          2151:                        writecrc(src,arg);                      /* int var (socket) */
        !          2152:                        writecrc(src,arg2);                     /* str var (src path) */
        !          2153:                        writecrc(src,arg3);                     /* str var (dest path) */
        !          2154:                        continue;
        !          2155:                }
        !          2156:                if(!stricmp(p,"FTP_DELETE")) {
        !          2157:                        if(!(*arg) || !(*arg2)) break;
        !          2158:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_DELETE);
        !          2159:                        writecrc(src,arg);                      /* int var (socket) */
        !          2160:                        writecrc(src,arg2);                     /* str var (path)       */
        !          2161:                        continue;
        !          2162:                }
        !          2163:                if(!stricmp(p,"FTP_RENAME")) {
        !          2164:                        if(!(*arg) || !(*arg2) || !(*arg3)) break;
        !          2165:                        fprintf(out,"%c%c",CS_NET_FUNCTION,CS_FTP_RENAME);
        !          2166:                        writecrc(src,arg);                      /* int var (socket) */
        !          2167:                        writecrc(src,arg2);                     /* str var (org name) */
        !          2168:                        writecrc(src,arg3);                     /* str var (new name) */
        !          2169:                        continue;
        !          2170:                }
        !          2171: 
1.1       root     2172:                if(!stricmp(p,"NODE_ACTION")) {
                   2173:                        if(!(*arg)) break;
                   2174:                        if((l=isvar(arg))!=0) {
                   2175:                                fputc(CS_USE_INT_VAR,out);
                   2176:                                fwrite(&l,4,1,out); // variable
                   2177:                                fputc(1,out);           // int offset
                   2178:                                fputc(1,out);       // int length
                   2179:                                ch=0; }                         // place holder
                   2180:                        else
                   2181:                                ch=val(src,arg);
                   2182: 
                   2183:                        fprintf(out,"%c%c",CS_NODE_ACTION,ch);
                   2184:                        continue; }
                   2185:                if(!stricmp(p,"NODE_STATUS")) {
                   2186:                        if(!(*arg)) break;
                   2187:                        if((l=isvar(arg))!=0) {
                   2188:                                fputc(CS_USE_INT_VAR,out);
                   2189:                                fwrite(&l,4,1,out); // variable
                   2190:                                fputc(1,out);           // int offset
                   2191:                                fputc(1,out);       // int length
                   2192:                                ch=0; }                         // place holder
                   2193:                        else
                   2194:                                ch=val(src,arg);
                   2195: 
                   2196:                        fprintf(out,"%c%c",CS_NODE_STATUS,ch);
                   2197:                        continue; }
                   2198:                if(!stricmp(p,"END_CMD") || !stricmp(p,"ENDCMD")) {
                   2199:                        fprintf(out,"%c",CS_END_CMD);
                   2200:                        continue; }
                   2201:                if(!stricmp(p,"CMD_POP") || !stricmp(p,"CMDPOP")) {
                   2202:                        fprintf(out,"%c",CS_CMD_POP);
                   2203:                        continue; }
                   2204:                if(!stricmp(p,"CLS")) {
                   2205:                        fprintf(out,"%c",CS_CLS);
                   2206:                        continue; }
                   2207:                if(!stricmp(p,"CRLF")) {
                   2208:                        fprintf(out,"%c",CS_CRLF);
                   2209:                        continue; }
                   2210:                if(!stricmp(p,"PAUSE")) {
                   2211:                        fprintf(out,"%c",CS_PAUSE);
                   2212:                        continue; }
                   2213:                if(!stricmp(p,"PAUSE_RESET")) {
                   2214:                        fprintf(out,"%c",CS_PAUSE_RESET);
                   2215:                        continue; }
                   2216:                if(!stricmp(p,"CLEAR_ABORT")) {
                   2217:                        fprintf(out,"%c",CS_CLEAR_ABORT);
                   2218:                        continue; }
                   2219:                if(!stricmp(p,"GETLINES")) {
                   2220:                        fprintf(out,"%c",CS_GETLINES);
                   2221:                        continue; }
                   2222:                if(!stricmp(p,"GETFILESPEC")) {
                   2223:                        fprintf(out,"%c",CS_GETFILESPEC);
                   2224:                        continue; }
                   2225:                if(!stricmp(p,"FINDUSER")) {
                   2226:                        fprintf(out,"%c",CS_FINDUSER);
                   2227:                        continue; }
1.1.1.2 ! root     2228:                if(!stricmp(p,"MATCHUSER")) {
        !          2229:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,MATCHUSER);
        !          2230:                        writecrc(src,arg);
        !          2231:                        writecrc(src,arg2);
        !          2232:                        continue; }
1.1       root     2233: 
                   2234:                if(!stricmp(p,"LOG")) {
                   2235:                        if(!(*arg)) break;
                   2236:                        fprintf(out,"%c",CS_LOG);
                   2237:                        writecstr(arg);
                   2238:                        continue; }
                   2239:                if(!stricmp(p,"MNEMONICS")) {
                   2240:                        if(!(*arg)) break;
                   2241:                        fprintf(out,"%c",CS_MNEMONICS);
                   2242:                        writecstr(arg);
                   2243:                        continue; }
                   2244:                if(!stricmp(p,"PRINT")) {
                   2245:                        if(!(*arg)) break;
                   2246:                        fprintf(out,"%c",CS_PRINT);
                   2247:                        writecstr(arg);
                   2248:                        continue; }
                   2249:                if(!stricmp(p,"PRINT_LOCAL")) {
                   2250:                        if(!(*arg)) break;
                   2251:                        fprintf(out,"%c",CS_PRINT_LOCAL);
                   2252:                        writecstr(arg);
                   2253:                        continue; }
                   2254:                if(!stricmp(p,"PRINT_REMOTE")) {
                   2255:                        if(!(*arg)) break;
                   2256:                        fprintf(out,"%c",CS_PRINT_REMOTE);
                   2257:                        writecstr(arg);
                   2258:                        continue; }
                   2259:                if(!stricmp(p,"PRINTFILE")) {
                   2260:                        if(!(*arg)) break;
                   2261:                        if(*arg=='"') { /* NEED TO SUPPORT MODE HERE */
                   2262:                                fprintf(out,"%c",CS_PRINTFILE);
                   2263:                                writestr(arg); }
                   2264:                        else {
                   2265:                                if((l=isvar(arg2))!=0) {
                   2266:                                        fputc(CS_USE_INT_VAR,out);
                   2267:                                        fwrite(&l,4,1,out); // variable
                   2268:                                        fputc(6,out);           // int offset
                   2269:                                        fputc(2,out);           // int length
                   2270:                                        i=0; }                          // place holder
                   2271:                                else
                   2272:                                        i=val(src,arg2);
                   2273: 
                   2274:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,PRINTFILE_VAR_MODE);
1.1.1.2 ! root     2275:                                p=strchr(arg,' ');
1.1       root     2276:                                if(p) *p=0;
                   2277:                                writecrc(src,arg);
                   2278:                                fwrite(&i,2,1,out); }
                   2279:                        continue; }
                   2280:                if(!stricmp(p,"PRINTTAIL")) {
                   2281:                        if(!(*arg) || !(*arg2))
                   2282:                                break;
                   2283:                        if((l=isvar(arg3))!=0) {
                   2284:                                fputc(CS_USE_INT_VAR,out);
                   2285:                                fwrite(&l,4,1,out); // variable
                   2286:                                fputc(8,out);           // int offset
                   2287:                                fputc(1,out);       // int length
                   2288:                                j=0; }                          // place holder
                   2289:                        else
                   2290:                                j=val(src,arg3);
                   2291: 
                   2292:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,PRINTTAIL_VAR_MODE);
1.1.1.2 ! root     2293:                        p=strchr(arg,' ');
1.1       root     2294:                        if(p) *p=0;
                   2295:                        writecrc(src,arg);
                   2296:                        i=val(src,arg2);
                   2297:                        fwrite(&i,2,1,out);
                   2298:                        fwrite(&j,1,1,out);
                   2299:                        continue; }
                   2300: 
                   2301:                if(!stricmp(p,"PRINTFILE_STR")) {
                   2302:                        fprintf(out,"%c",CS_PRINTFILE_STR);
                   2303:                        continue; }
                   2304:                if(!stricmp(p,"PRINTFILE_LOCAL")) {
                   2305:                        if(!(*arg)) break;
                   2306:                        fprintf(out,"%c",CS_PRINTFILE_LOCAL);
                   2307:                        writestr(arg);
                   2308:                        continue; }
                   2309:                if(!stricmp(p,"PRINTFILE_REMOTE")) {
                   2310:                        if(!(*arg)) break;
                   2311:                        fprintf(out,"%c",CS_PRINTFILE_REMOTE);
                   2312:                        writestr(arg);
                   2313:                        continue; }
                   2314: 
                   2315:                if(!stricmp(p,"TELNET_GATE")) {
                   2316:                        if(!(*arg)) break;
                   2317:                        if((l=isvar(arg2))!=0) {
                   2318:                                fputc(CS_USE_INT_VAR,out);
                   2319:                                fwrite(&l,4,1,out); // variable
                   2320:                                fputc(2,out);           // int offset
                   2321:                                fputc(4,out);           // int length
                   2322:                                l=0; }                          // place holder
                   2323:                        else if(*arg2)
                   2324:                                l=val(src,arg2);
                   2325:                        else
                   2326:                                l=0;
                   2327: 
                   2328:                        if(*arg=='"') {
                   2329:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,TELNET_GATE_STR);
                   2330:                                fwrite(&l,4,1,out);
                   2331:                                writestr(arg); 
                   2332:                        } else {
                   2333:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,TELNET_GATE_VAR);
                   2334:                                fwrite(&l,4,1,out);
1.1.1.2 ! root     2335:                                p=strchr(arg,' ');
1.1       root     2336:                                if(p) *p=0;
                   2337:                                writecrc(src,arg);
                   2338:                        }
                   2339:                        continue; 
                   2340:                }
                   2341: 
                   2342:                if(!stricmp(p,"EXEC")) {
                   2343:                        if(!(*arg)) break;
                   2344:                        fprintf(out,"%c",CS_EXEC);
                   2345:                        writestr(arg);
                   2346:                        continue; }
                   2347:                if(!stricmp(p,"EXEC_INT")) {
                   2348:                        if(!(*arg)) break;
                   2349:                        fprintf(out,"%c",CS_EXEC_INT);
                   2350:                        writestr(arg);
                   2351:                        continue; }
                   2352:                if(!stricmp(p,"EXEC_BIN")) {
                   2353:                        if(!(*arg)) break;
                   2354:                        fprintf(out,"%c",CS_EXEC_BIN);
                   2355:                        writestr(arg);
                   2356:                        continue; }
                   2357:                if(!stricmp(p,"EXEC_XTRN")) {
                   2358:                        if(!(*arg)) break;
                   2359:                        fprintf(out,"%c",CS_EXEC_XTRN);
                   2360:                        writestr(arg);
                   2361:                        continue; }
                   2362: 
                   2363:                if(!stricmp(p,"SELECT_SHELL")) {
                   2364:                        fprintf(out,"%c",CS_SELECT_SHELL);
                   2365:                        continue; }
                   2366:                if(!stricmp(p,"SET_SHELL")) {
                   2367:                        fprintf(out,"%c",CS_SET_SHELL);
                   2368:                        continue; }
                   2369:                if(!stricmp(p,"SELECT_EDITOR")) {
                   2370:                        fprintf(out,"%c",CS_SELECT_EDITOR);
                   2371:                        continue; }
                   2372:                if(!stricmp(p,"SET_EDITOR")) {
                   2373:                        fprintf(out,"%c",CS_SET_EDITOR);
                   2374:                        continue; }
                   2375: 
                   2376:                if(!stricmp(p,"YES_NO")) {
                   2377:                        if(!(*arg)) break;
                   2378:                        fprintf(out,"%c",CS_YES_NO);
                   2379:                        writecstr(arg);
                   2380:                        continue; }
                   2381:                if(!stricmp(p,"NO_YES")) {
                   2382:                        if(!(*arg)) break;
                   2383:                        fprintf(out,"%c",CS_NO_YES);
                   2384:                        writecstr(arg);
                   2385:                        continue; }
                   2386:                if(!stricmp(p,"MENU")) {
                   2387:                        if(!(*arg)) break;
                   2388:                        fprintf(out,"%c",CS_MENU);
                   2389:                        writestr(arg);
                   2390:                        continue; }
                   2391:                if(!stricmp(p,"SET_MENU_DIR")) {
                   2392:                        if(!(*arg)) break;
                   2393:                        fprintf(out,"%c",CS_SET_MENU_DIR);
                   2394:                        writestr(arg);
                   2395:                        continue; }
                   2396:                if(!stricmp(p,"SET_MENU_FILE")) {
                   2397:                        if(!(*arg)) break;
                   2398:                        fprintf(out,"%c",CS_SET_MENU_FILE);
                   2399:                        writestr(arg);
                   2400:                        continue; }
                   2401:                if(!stricmp(p,"SEND_FILE_VIA")) {
                   2402:                        if(!(*arg) || !(*arg2)) break;
                   2403:                        if(*arg2=='"') {
                   2404:                                fprintf(out,"%c%c%c",CS_VAR_INSTRUCTION,SEND_FILE_VIA,*arg);
                   2405:                                writestr(arg2); }
                   2406:                        else {
                   2407:                                fprintf(out,"%c%c%c",CS_VAR_INSTRUCTION,SEND_FILE_VIA_VAR,*arg);
                   2408:                                writecrc(src,arg2); }
                   2409:                        continue; }
                   2410:                if(!stricmp(p,"RECEIVE_FILE_VIA")) {
                   2411:                        if(!(*arg) || !(*arg2)) break;
                   2412:                        if(*arg2=='"') {
                   2413:                                fprintf(out,"%c%c%c",CS_VAR_INSTRUCTION,RECEIVE_FILE_VIA,*arg);
                   2414:                                writestr(arg2); }
                   2415:                        else {
                   2416:                                fprintf(out,"%c%c%c",CS_VAR_INSTRUCTION,RECEIVE_FILE_VIA_VAR,*arg);
                   2417:                                writecrc(src,arg2); }
                   2418:                        continue; }
                   2419:                if(!stricmp(p,"CHKFILE")) {
                   2420:                        if(!(*arg)) break;
                   2421:                        if(*arg=='"') {
                   2422:                                fprintf(out,"%c",CS_CHKFILE);
                   2423:                                writestr(arg); }
                   2424:                        else {
                   2425:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,CHKFILE_VAR);
                   2426:                                writecrc(src,arg); }
                   2427:                        continue; }
                   2428:                if(!stricmp(p,"GET_FILE_LENGTH")) {
                   2429:                        if(!(*arg) || !(*arg2))
                   2430:                                break;
                   2431:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,FLENGTH_TO_INT);
1.1.1.2 ! root     2432:                        p=strchr(arg,' ');
1.1       root     2433:                        if(p) *p=0;
                   2434:                        writecrc(src,arg);
                   2435:                        writecrc(src,arg2);
                   2436:                        continue; }
                   2437:                if(!stricmp(p,"GET_FILE_TIME")) {
                   2438:                        if(!(*arg) || !(*arg2))
                   2439:                                break;
                   2440:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,FTIME_TO_INT);
1.1.1.2 ! root     2441:                        p=strchr(arg,' ');
1.1       root     2442:                        if(p) *p=0;
                   2443:                        writecrc(src,arg);
                   2444:                        writecrc(src,arg2);
                   2445:                        continue; }
                   2446:                if(!stricmp(p,"CHARVAL")) {
                   2447:                        if(!(*arg) || !(*arg2))
                   2448:                                break;
                   2449:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,CHARVAL_TO_INT);
1.1.1.2 ! root     2450:                        p=strchr(arg,' ');
1.1       root     2451:                        if(p) *p=0;
                   2452:                        writecrc(src,arg);
                   2453:                        writecrc(src,arg2);
                   2454:                        continue; }
                   2455:                if(!stricmp(p,"SETSTR")) {
                   2456:                        if(!(*arg)) break;
                   2457:                        fprintf(out,"%c",CS_SETSTR);
                   2458:                        writecstr(arg);
                   2459:                        continue; }
                   2460:                if(!stricmp(p,"COMPARE_STR")) {
                   2461:                        if(!(*arg)) break;
                   2462:                        fprintf(out,"%c",CS_COMPARE_STR);
                   2463:                        writecstr(arg);
                   2464:                        continue; }
                   2465:                if(!stricmp(p,"GET_TEMPLATE")) {
                   2466:                        if(!(*arg)) break;
                   2467:                        fprintf(out,"%c",CS_GET_TEMPLATE);
                   2468:                        writestr(arg);
                   2469:                        continue; }
                   2470:                if(!stricmp(p,"READ_SIF")) {
                   2471:                        if(!(*arg)) break;
                   2472:                        fprintf(out,"%c",CS_READ_SIF);
                   2473:                        writestr(arg);
                   2474:                        continue; }
                   2475:                if(!stricmp(p,"CREATE_SIF")) {
                   2476:                        if(!(*arg)) break;
                   2477:                        fprintf(out,"%c",CS_CREATE_SIF);
                   2478:                        writestr(arg);
                   2479:                        continue; }
                   2480:                if(!stricmp(p,"TRASHCAN")) {
                   2481:                        if(!(*arg)) break;
                   2482:                        fprintf(out,"%c",CS_TRASHCAN);
                   2483:                        writestr(arg);
                   2484:                        continue; }
                   2485:                if(!stricmp(p,"CMDSTR")) {
                   2486:                        if(!(*arg)) break;
                   2487:                        fprintf(out,"%c",CS_CMDSTR);
                   2488:                        writecstr(arg);
                   2489:                        continue; }
                   2490:                if(!stricmp(p,"CMDKEYS")) {
                   2491:                        if(!(*arg)) break;
                   2492:                        fprintf(out,"%c",CS_CMDKEYS);
                   2493:                        for(p=arg;*p && *p!='#';p++) {
                   2494:                                ch=*p;
                   2495:                                if(ch=='"')
                   2496:                                        continue;
                   2497:                                if(ch=='/') {
                   2498:                                        p++;
                   2499:                                        ch=*p|0x80; }  /* high bit indicates slash required */
                   2500:                                else if(ch=='^' && *(p+1)>=0x40) {
                   2501:                                        p++;
                   2502:                                        ch=*p;
                   2503:                                        ch-=0x40; }
                   2504:                                else if(ch=='\\') {
                   2505:                                        p++;
                   2506:                                        ch=cesc(*p); }
                   2507:                                fputc(ch,out); }
                   2508:                        fputc(0,out);
                   2509:                        continue; }
                   2510:                if(!stricmp(p,"COMPARE_WORD")) {
                   2511:                        if(!(*arg)) break;
                   2512:                        fprintf(out,"%c",CS_COMPARE_WORD);
                   2513:                        writecstr(arg);
                   2514:                        continue; }
                   2515:                if(!stricmp(p,"GETSTR")) {
1.1.1.2 ! root     2516:                        p=strchr(arg,' ');
1.1       root     2517:                        if(p) *p=0;
                   2518:                        if((!(*arg) || isdigit(*arg) || !stricmp(arg,"STR")) && !(*arg3))
                   2519:                                fprintf(out,"%c%c",CS_GETSTR,atoi(arg) ? atoi(arg)
                   2520:                                        : *arg2 ? atoi(arg2) : 128);
                   2521:                        else {
                   2522:                                if((l=isvar(arg2))!=0) {
                   2523:                                        fputc(CS_USE_INT_VAR,out);
                   2524:                                        fwrite(&l,4,1,out); // variable
                   2525:                                        fputc(6,out);           // int offset
                   2526:                                        fputc(1,out);           // int length
                   2527:                                        i=0; }                          // place holder
                   2528:                                else if(*arg2)
                   2529:                                        i=val(src,arg2);
                   2530:                                else
                   2531:                                        i=0;
                   2532: 
                   2533:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION
                   2534:                                        ,*arg3 ? GETSTR_MODE : GETSTR_VAR);
                   2535:                                writecrc(src,arg);
                   2536:                
                   2537:                                if(!i) i=128;
                   2538:                                fwrite(&i,1,1,out);
                   2539:                                if(*arg3) {
                   2540:                                        l=val(src,arg3);
                   2541:                                        fwrite(&l,4,1,out); } }
                   2542:                        continue; }
                   2543:                if(!stricmp(p,"GETNUM")) {
                   2544:                        if(!(*arg)) break;
1.1.1.2 ! root     2545:                        p=strchr(arg,' ');
1.1       root     2546:                        if(p) *p=0;
                   2547:                        if(isdigit(*arg)) {
                   2548:                                i=val(src,arg);
                   2549:                                fprintf(out,"%c",CS_GETNUM);
                   2550:                                fwrite(&i,2,1,out); }
                   2551:                        else {
                   2552:                                if((l=isvar(arg2))!=0) {
                   2553:                                        fputc(CS_USE_INT_VAR,out);
                   2554:                                        fwrite(&l,4,1,out); // variable
                   2555:                                        fputc(6,out);           // int offset
                   2556:                                        fputc(2,out);           // int length
                   2557:                                        i=0; }                          // place holder
                   2558:                                else
                   2559:                                        i=val(src,arg2);
                   2560: 
                   2561:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,GETNUM_VAR);
                   2562:                                writecrc(src,arg);
                   2563:                                fwrite(&i,2,1,out); }
                   2564:                        continue; }
                   2565:                if(!stricmp(p,"MSWAIT")) {
                   2566:                        if(!(*arg)) break;
                   2567:                        if((l=isvar(arg))!=0) {
                   2568:                                fputc(CS_USE_INT_VAR,out);
                   2569:                                fwrite(&l,4,1,out); // variable
                   2570:                                fputc(1,out);           // int offset
                   2571:                                fputc(2,out);           // int length
                   2572:                                i=0; }                          // place holder
                   2573:                        else
                   2574:                                i=val(src,arg);
                   2575: 
                   2576:                        fprintf(out,"%c",CS_MSWAIT);
                   2577:                        fwrite(&i,2,1,out);
                   2578:                        continue; }
                   2579:                if(!stricmp(p,"GETLINE")) {
1.1.1.2 ! root     2580:                        p=strchr(arg,' ');
1.1       root     2581:                        if(p) *p=0;
                   2582:                        if(!(*arg) || isdigit(*arg))
                   2583:                                fprintf(out,"%c%c",CS_GETLINE,*arg ? atoi(arg) :128);
                   2584:                        else {
                   2585:                                if((l=isvar(arg2))!=0) {
                   2586:                                        fputc(CS_USE_INT_VAR,out);
                   2587:                                        fwrite(&l,4,1,out); // variable
                   2588:                                        fputc(6,out);           // int offset
                   2589:                                        fputc(1,out);           // int length
                   2590:                                        i=0; }                          // place holder
                   2591:                                else
                   2592:                                        i=val(src,arg2);
                   2593: 
                   2594:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,GETLINE_VAR);
                   2595:                                writecrc(src,arg);
                   2596:                                if(!i) i=128;
                   2597:                                fwrite(&i,1,1,out); }
                   2598:                        continue; }
                   2599:                if(!stricmp(p,"GETSTRUPR")) {
1.1.1.2 ! root     2600:                        p=strchr(arg,' ');
1.1       root     2601:                        if(p) *p=0;
                   2602:                        if(!(*arg) || isdigit(*arg))
                   2603:                                fprintf(out,"%c%c",CS_GETSTRUPR,*arg ? atoi(arg) :128);
                   2604:                        else {
                   2605:                                if((l=isvar(arg2))!=0) {
                   2606:                                        fputc(CS_USE_INT_VAR,out);
                   2607:                                        fwrite(&l,4,1,out); // variable
                   2608:                                        fputc(6,out);           // int offset
                   2609:                                        fputc(1,out);           // int length
                   2610:                                        i=0; }                          // place holder
                   2611:                                else
                   2612:                                        i=val(src,arg2);
                   2613: 
                   2614:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,GETSTRUPR_VAR);
                   2615:                                writecrc(src,arg);
                   2616:                                if(!i) i=128;
                   2617:                                fwrite(&i,1,1,out); }
                   2618:                        continue; }
                   2619:                if(!stricmp(p,"GETNAME")) {
1.1.1.2 ! root     2620:                        p=strchr(arg,' ');
1.1       root     2621:                        if(p) *p=0;
                   2622:                        if(!(*arg) || isdigit(*arg))
                   2623:                                fprintf(out,"%c%c",CS_GETNAME,*arg ? atoi(arg) :25);
                   2624:                        else {
                   2625:                                if((l=isvar(arg2))!=0) {
                   2626:                                        fputc(CS_USE_INT_VAR,out);
                   2627:                                        fwrite(&l,4,1,out); // variable
                   2628:                                        fputc(6,out);           // int offset
                   2629:                                        fputc(1,out);           // int length
                   2630:                                        i=0; }                          // place holder
                   2631:                                else
                   2632:                                        i=atoi(arg2);
                   2633: 
                   2634:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,GETNAME_VAR);
                   2635:                                writecrc(src,arg);
                   2636:                                if(!i) i=128;
                   2637:                                fwrite(&i,1,1,out); }
                   2638:                        continue; }
                   2639:                if(!stricmp(p,"SHIFT_STR")) {
                   2640:                        if(!(*arg)) break;
1.1.1.2 ! root     2641:                        p=strchr(arg,' ');
1.1       root     2642:                        if(p) *p=0;
1.1.1.2 ! root     2643:                        if(isdigit(*arg))
1.1       root     2644:                                fprintf(out,"%c%c",CS_SHIFT_STR,atoi(arg));
                   2645:                        else {
                   2646:                                if((l=isvar(arg2))!=0) {
                   2647:                                        fputc(CS_USE_INT_VAR,out);
                   2648:                                        fwrite(&l,4,1,out); // variable
                   2649:                                        fputc(6,out);           // int offset
                   2650:                                        fputc(1,out);           // int length
                   2651:                                        i=0; }                          // place holder
                   2652:                                else
                   2653:                                        i=atoi(arg2);
                   2654: 
                   2655:                                fprintf(out,"%c%c",CS_VAR_INSTRUCTION,SHIFT_STR_VAR);
                   2656:                                writecrc(src,arg);
                   2657:                                if(!i) i=128;
                   2658:                                fwrite(&i,1,1,out); }
                   2659:                        continue; }
1.1.1.2 ! root     2660:                if(!stricmp(p,"SHIFT_TO_FIRST_CHAR") || !stricmp(p,"SHIFT_TO_LAST_CHAR")) {
        !          2661:                        if(!(*arg) || !(*arg2)) break;
        !          2662:                        if((l=isvar(arg2))!=0) {
        !          2663:                                fputc(CS_USE_INT_VAR,out);
        !          2664:                                fwrite(&l,4,1,out); // variable
        !          2665:                                fputc(6,out);           // int offset
        !          2666:                                fputc(1,out);           // int length
        !          2667:                                ch=0; }                         // place holder
        !          2668:                        else
        !          2669:                                ch=val(src,arg2);
        !          2670: 
        !          2671:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION
        !          2672:                                ,!stricmp(p,"SHIFT_TO_FIRST_CHAR") ? SHIFT_TO_FIRST_CHAR : SHIFT_TO_LAST_CHAR);
        !          2673:                        writecrc(src,arg);
        !          2674:                        fwrite(&ch,sizeof(ch),1,out);
        !          2675:                        continue;
        !          2676:                }
1.1       root     2677:                if(!stricmp(p,"TRUNCSP")) {
                   2678:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,TRUNCSP_STR_VAR);
                   2679:                        writecrc(src,arg);
                   2680:                        continue; }
                   2681:                if(!stricmp(p,"STRIP_CTRL")) {
                   2682:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,STRIP_CTRL_STR_VAR);
                   2683:                        writecrc(src,arg);
                   2684:                        continue; }
                   2685:                if(!stricmp(p,"STRUPR")) {
                   2686:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,STRUPR_VAR);
                   2687:                        writecrc(src,arg);
                   2688:                        continue; }
                   2689:                if(!stricmp(p,"STRLWR")) {
                   2690:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,STRLWR_VAR);
                   2691:                        writecrc(src,arg);
                   2692:                        continue; }
                   2693:                if(!stricmp(p,"STRLEN")) {
                   2694:                        if(!(*arg)) break;
                   2695:                        fprintf(out,"%c%c",CS_VAR_INSTRUCTION,STRLEN_INT_VAR);
1.1.1.2 ! root     2696:                        p=strchr(arg,' ');
1.1       root     2697:                        if(!p)
                   2698:                                break;
                   2699:                        *p=0;
                   2700:                        writecrc(src,arg);
                   2701:                        writecrc(src,arg2);
                   2702:                        continue; }
                   2703:                if(!stricmp(p,"REPLACE_TEXT")) {
                   2704:                        if(!(*arg) || !(*arg2)) break;
                   2705:                        if((l=isvar(arg))!=0) {
                   2706:                                fputc(CS_USE_INT_VAR,out);
                   2707:                                fwrite(&l,4,1,out); // variable
                   2708:                                fputc(1,out);           // int offset
                   2709:                                fputc(2,out);           // int length
                   2710:                                i=0; }                          // place holder
                   2711:                        else
                   2712:                                i=val(src,arg);
                   2713: 
                   2714:                        fprintf(out,"%c",CS_REPLACE_TEXT);
                   2715:                        fwrite(&i,2,1,out);
                   2716:                        writecstr(arg2);
                   2717:                        continue; }
                   2718:                if(!stricmp(p,"REVERT_TEXT")) {
                   2719:                        if(!(*arg)) break;
                   2720:                        if(!stricmp(arg,"ALL"))
                   2721:                                i=0xffff;
                   2722:                        else {
                   2723:                                if((l=isvar(arg))!=0) {
                   2724:                                        fputc(CS_USE_INT_VAR,out);
                   2725:                                        fwrite(&l,4,1,out); // variable
                   2726:                                        fputc(1,out);           // int offset
                   2727:                                        fputc(2,out);           // int length
                   2728:                                        i=0; }                          // place holder
                   2729:                                else
                   2730:                                        i=val(src,arg); }
                   2731: 
                   2732:                        fprintf(out,"%c",CS_REVERT_TEXT);
                   2733:                        fwrite(&i,2,1,out);
                   2734:                        continue; }
                   2735:                if(!stricmp(p,"TOGGLE_USER_MISC")
                   2736:                        || !stricmp(p,"COMPARE_USER_MISC")) {
                   2737:                        if(!(*arg)) break;
                   2738: 
                   2739:                        if((l=isvar(arg))!=0) {
                   2740:                                fputc(CS_USE_INT_VAR,out);
                   2741:                                fwrite(&l,4,1,out); // variable
                   2742:                                fputc(1,out);           // int offset
                   2743:                                fputc(4,out);           // int length
                   2744:                                l=0; }                          // place holder
                   2745:                        else
                   2746:                                l=val(src,arg);
                   2747: 
                   2748:                        if(!stricmp(p,"TOGGLE_USER_MISC"))
                   2749:                                fprintf(out,"%c",CS_TOGGLE_USER_MISC);
                   2750:                        else
                   2751:                                fprintf(out,"%c",CS_COMPARE_USER_MISC);
                   2752:                        fwrite(&l,4,1,out);
                   2753:                        continue; }
                   2754: 
                   2755:                if(!stricmp(p,"TOGGLE_USER_CHAT")
                   2756:                        || !stricmp(p,"COMPARE_USER_CHAT")) {
                   2757:                        if(!(*arg)) break;
                   2758: 
                   2759:                        if((l=isvar(arg))!=0) {
                   2760:                                fputc(CS_USE_INT_VAR,out);
                   2761:                                fwrite(&l,4,1,out); // variable
                   2762:                                fputc(1,out);           // int offset
                   2763:                                fputc(4,out);           // int length
                   2764:                                l=0; }                          // place holder
                   2765:                        else
                   2766:                                l=val(src,arg);
                   2767: 
                   2768:                        if(!stricmp(p,"TOGGLE_USER_CHAT"))
                   2769:                                fprintf(out,"%c",CS_TOGGLE_USER_CHAT);
                   2770:                        else
                   2771:                                fprintf(out,"%c",CS_COMPARE_USER_CHAT);
                   2772:                        fwrite(&l,4,1,out);
                   2773:                        continue; }
                   2774: 
                   2775:                if(!stricmp(p,"TOGGLE_USER_QWK")
                   2776:                        || !stricmp(p,"COMPARE_USER_QWK")) {
                   2777:                        if(!(*arg)) break;
                   2778: 
                   2779:                        if((l=isvar(arg))!=0) {
                   2780:                                fputc(CS_USE_INT_VAR,out);
                   2781:                                fwrite(&l,4,1,out); // variable
                   2782:                                fputc(1,out);           // int offset
                   2783:                                fputc(4,out);           // int length
                   2784:                                l=0; }                          // place holder
                   2785:                        else
                   2786:                                l=val(src,arg);
                   2787: 
                   2788:                        if(!stricmp(p,"TOGGLE_USER_QWK"))
                   2789:                                fprintf(out,"%c",CS_TOGGLE_USER_QWK);
                   2790:                        else
                   2791:                                fprintf(out,"%c",CS_COMPARE_USER_QWK);
                   2792:                        fwrite(&l,4,1,out);
                   2793:                        continue; }
                   2794: 
                   2795:                if(!stricmp(p,"TOGGLE_NODE_MISC")
                   2796:                        || !stricmp(p,"COMPARE_NODE_MISC")) {
                   2797:                        if(!(*arg)) break;
                   2798: 
                   2799:                        if((l=isvar(arg))!=0) {
                   2800:                                fputc(CS_USE_INT_VAR,out);
                   2801:                                fwrite(&l,4,1,out); // variable
                   2802:                                fputc(1,out);           // int offset
                   2803:                                fputc(2,out);           // int length
                   2804:                                i=0; }                          // place holder
                   2805:                        else
                   2806:                                i=val(src,arg);
                   2807: 
                   2808:                        if(!stricmp(p,"TOGGLE_NODE_MISC"))
                   2809:                                fprintf(out,"%c",CS_TOGGLE_NODE_MISC);
                   2810:                        else
                   2811:                                fprintf(out,"%c",CS_COMPARE_NODE_MISC);
                   2812:                        fwrite(&i,2,1,out);
                   2813:                        continue; }
                   2814: 
                   2815:                if(!stricmp(p,"TOGGLE_USER_FLAG")) {
                   2816:                        if(!(*arg)) break;
                   2817:                        p=arg;
                   2818:                        fprintf(out,"%c%c",CS_TOGGLE_USER_FLAG,toupper(*p++));
1.1.1.2 ! root     2819:                        while(*p && *p<=' ') p++;
1.1       root     2820:                        fprintf(out,"%c",toupper(*p));
                   2821:                        continue; }
                   2822: 
                   2823:                if(!stricmp(p,"SET_USER_LEVEL")) {
                   2824:                        if(!(*arg)) break;
                   2825: 
                   2826:                        if((l=isvar(arg))!=0) {
                   2827:                                fputc(CS_USE_INT_VAR,out);
                   2828:                                fwrite(&l,4,1,out); // variable
                   2829:                                fputc(1,out);           // int offset
                   2830:                                fputc(1,out);           // int length
                   2831:                                ch=0; }                         // place holder
                   2832:                        else
                   2833:                                ch=val(src,arg);
                   2834: 
                   2835:                        fprintf(out,"%c%c",CS_SET_USER_LEVEL,ch);
                   2836:                        continue; }
                   2837: 
                   2838:                if(!stricmp(p,"SET_USER_STRING")) {
                   2839:                        if(!(*arg)) break;
                   2840: 
                   2841:                        if((l=isvar(arg))!=0) {
                   2842:                                fputc(CS_USE_INT_VAR,out);
                   2843:                                fwrite(&l,4,1,out); // variable
                   2844:                                fputc(1,out);           // int offset
                   2845:                                fputc(1,out);           // int length
                   2846:                                ch=0; }                         // place holder
                   2847:                        else
                   2848:                                ch=val(src,arg);
                   2849: 
                   2850:                        fprintf(out,"%c%c",CS_SET_USER_STRING,ch);
                   2851:                        continue; }
                   2852: 
                   2853: 
                   2854:                if(!stricmp(p,"ADJUST_USER_CREDITS")) {
                   2855:                        if(!(*arg)) break;
                   2856: 
                   2857:                        if((l=isvar(arg))!=0) {
                   2858:                                fputc(CS_USE_INT_VAR,out);
                   2859:                                fwrite(&l,4,1,out); // variable
                   2860:                                fputc(1,out);           // int offset
                   2861:                                fputc(2,out);           // int length
                   2862:                                i=0; }                     // place holder
                   2863:                        else
                   2864:                                i=val(src,arg);
                   2865: 
                   2866:                        fprintf(out,"%c",CS_ADJUST_USER_CREDITS);
                   2867:                        fwrite(&i,2,1,out);
                   2868:                        continue; }
                   2869: 
                   2870:                if(!stricmp(p,"ADJUST_USER_MINUTES")) {
                   2871:                        if(!(*arg)) break;
                   2872: 
                   2873:                        if((l=isvar(arg))!=0) {
                   2874:                                fputc(CS_USE_INT_VAR,out);
                   2875:                                fwrite(&l,4,1,out); // variable
                   2876:                                fputc(1,out);           // int offset
                   2877:                                fputc(2,out);           // int length
                   2878:                                i=0; }                          // place holder
                   2879:                        else
                   2880:                                i=val(src,arg);
                   2881: 
                   2882:                        fprintf(out,"%c",CS_ADJUST_USER_MINUTES);
                   2883:                        fwrite(&i,2,1,out);
                   2884:                        continue; }
                   2885: 
                   2886:                if(!stricmp(p,"SHOW_MEM")) {
                   2887:                        fprintf(out,"%c",CS_SHOW_MEM);
                   2888:                        continue; }
                   2889:                if(!stricmp(p,"GURU_LOG")) {
                   2890:                        fprintf(out,"%c",CS_GURU_LOG);
                   2891:                        continue; }
                   2892:                if(!stricmp(p,"ERROR_LOG")) {
                   2893:                        fprintf(out,"%c",CS_ERROR_LOG);
                   2894:                        continue; }
                   2895:                if(!stricmp(p,"SYSTEM_LOG")) {
                   2896:                        fprintf(out,"%c",CS_SYSTEM_LOG);
                   2897:                        continue; }
                   2898:                if(!stricmp(p,"SYSTEM_YLOG")) {
                   2899:                        fprintf(out,"%c",CS_SYSTEM_YLOG);
                   2900:                        continue; }
                   2901:                if(!stricmp(p,"SYSTEM_STATS")) {
                   2902:                        fprintf(out,"%c",CS_SYSTEM_STATS);
                   2903:                        continue; }
                   2904:                if(!stricmp(p,"NODE_STATS")) {
                   2905:                        fprintf(out,"%c",CS_NODE_STATS);
                   2906:                        continue; }
                   2907:                if(!stricmp(p,"CHANGE_USER")) {
                   2908:                        fprintf(out,"%c",CS_CHANGE_USER);
                   2909:                        continue; }
                   2910:                if(!stricmp(p,"ANSI_CAPTURE")) {
                   2911:                        fprintf(out,"%c",CS_ANSI_CAPTURE);
                   2912:                        continue; }
                   2913:                if(!stricmp(p,"LIST_TEXT_FILE")) {
                   2914:                        fprintf(out,"%c",CS_LIST_TEXT_FILE);
                   2915:                        continue; }
                   2916:                if(!stricmp(p,"EDIT_TEXT_FILE")) {
                   2917:                        fprintf(out,"%c",CS_EDIT_TEXT_FILE);
                   2918:                        continue; }
                   2919: 
                   2920: 
                   2921:                if(!stricmp(p,"COMPARE_KEY")) {
                   2922:                        if(!stricmp(arg,"DIGIT"))
                   2923:                                ch=CS_DIGIT;
                   2924:                        else if(!stricmp(arg,"EDIGIT"))
                   2925:                                ch=CS_EDIGIT;
                   2926:                        else
                   2927:                                ch=toupper(*arg);
                   2928:                        if(ch=='/')
                   2929:                                ch=(*arg)|0x80;   /* high bit indicates slash required */
                   2930:                        else if(ch=='^' && (*(arg+1))>=0x40)
                   2931:                                ch=(*(arg+1))-0x40;   /* ctrl char */
                   2932:                        else if(ch=='\\')
                   2933:                                ch=cesc(*(arg+1));
                   2934:                        else if(ch=='\'')
                   2935:                                ch=*(arg+1);
                   2936:                        fprintf(out,"%c%c",CS_COMPARE_KEY,ch);
                   2937:                        continue; }
                   2938:                if(!stricmp(p,"COMPARE_CHAR")) {
                   2939:                        ch=*arg;
                   2940:                        fprintf(out,"%c%c",CS_COMPARE_CHAR,ch);
                   2941:                        continue; }
                   2942:                if(!stricmp(p,"COMPARE_KEYS")) {
                   2943:                        fputc(CS_COMPARE_KEYS,out);
                   2944:                        for(p=arg;*p && *p!='#';p++) {
                   2945:                                ch=*p;
                   2946:                                if(ch=='"')
                   2947:                                        continue;
                   2948:                                if(ch=='/') {
                   2949:                                        p++;
                   2950:                                        ch=*p|0x80; }  /* high bit indicates slash required */
                   2951:                                else if(ch=='^' && *(p+1)>=0x40) {
                   2952:                                        p++;
                   2953:                                        ch=*p;
                   2954:                                        ch-=0x40; }
                   2955:                                else if(ch=='\\') {
                   2956:                                        p++;
                   2957:                                        ch=cesc(*p); }
                   2958:                                fputc(ch,out); }
                   2959:                        fputc(0,out);
                   2960:                        continue; }
                   2961:                if(!stricmp(p,"GETCMD")) {
                   2962:                        fprintf(out,"%c",CS_GETCMD);
                   2963:                        writecstr(arg);
                   2964:                        continue; }
                   2965:                if(!stricmp(p,"INKEY")) {
                   2966:                        fprintf(out,"%c",CS_INKEY);
                   2967:                        continue; }
1.1.1.2 ! root     2968:                if(!stricmp(p,"INCHAR")) {
        !          2969:                        fprintf(out,"%c",CS_INCHAR);
        !          2970:                        continue; }
1.1       root     2971:                if(!stricmp(p,"GETKEY")) {
                   2972:                        fprintf(out,"%c",CS_GETKEY);
                   2973:                        continue; }
                   2974:                if(!stricmp(p,"GETCHAR")) {
                   2975:                        fprintf(out,"%c",CS_GETCHAR);
                   2976:                        continue; }
                   2977:                if(!stricmp(p,"GETKEYE")) {
                   2978:                        fprintf(out,"%c",CS_GETKEYE);
                   2979:                        continue; }
                   2980:                if(!stricmp(p,"UNGETKEY")) {
                   2981:                        fprintf(out,"%c",CS_UNGETKEY);
                   2982:                        continue; }
                   2983:                if(!stricmp(p,"UNGETSTR")) {
                   2984:                        fprintf(out,"%c",CS_UNGETSTR);
                   2985:                        continue; }
                   2986:                if(!stricmp(p,"PRINTKEY")) {
                   2987:                        fprintf(out,"%c",CS_PRINTKEY);
                   2988:                        continue; }
                   2989:                if(!stricmp(p,"PRINTSTR")) {
                   2990:                        fprintf(out,"%c",CS_PRINTSTR);
                   2991:                        continue; }
                   2992: 
                   2993:                /* FUNCTIONS */
                   2994: 
                   2995:                if(!stricmp(p,"NODELIST_ALL")) {
                   2996:                        fprintf(out,"%c",CS_NODELIST_ALL);
                   2997:                        continue; }
                   2998:                if(!stricmp(p,"NODELIST_USERS")) {
                   2999:                        fprintf(out,"%c",CS_NODELIST_USERS);
                   3000:                        continue; }
                   3001: 
                   3002:                if(!stricmp(p,"USERLIST_ALL")) {
                   3003:                        fprintf(out,"%c",CS_USERLIST_ALL);
                   3004:                        continue; }
                   3005:                if(!stricmp(p,"USERLIST_SUB")) {
                   3006:                        fprintf(out,"%c",CS_USERLIST_SUB);
                   3007:                        continue; }
                   3008:                if(!stricmp(p,"USERLIST_DIR")) {
                   3009:                        fprintf(out,"%c",CS_USERLIST_DIR);
                   3010:                        continue; }
                   3011:                if(!stricmp(p,"USERLIST_LOGONS")) {
                   3012:                        fprintf(out,"%c",CS_USERLIST_LOGONS);
                   3013:                        continue; }
                   3014: 
                   3015:                if(!stricmp(p,"HANGUP")) {
                   3016:                        fprintf(out,"%c",CS_HANGUP);
                   3017:                        continue; }
                   3018: 
                   3019:                if(!stricmp(p,"LOGOFF")) {
                   3020:                        fprintf(out,"%c",CS_LOGOFF);
                   3021:                        continue; }
                   3022: 
                   3023:                if(!stricmp(p,"LOGOFF_FAST")) {
                   3024:                        fprintf(out,"%c",CS_LOGOFF_FAST);
                   3025:                        continue; }
                   3026: 
                   3027:                if(!stricmp(p,"AUTO_MESSAGE")) {
                   3028:                        fprintf(out,"%c",CS_AUTO_MESSAGE);
                   3029:                        continue; }
                   3030: 
                   3031:                if(!stricmp(p,"MINUTE_BANK")) {
                   3032:                        fprintf(out,"%c",CS_MINUTE_BANK);
                   3033:                        continue; }
                   3034: 
                   3035:                if(!stricmp(p,"USER_EDIT")) {
                   3036:                        fprintf(out,"%c",CS_USER_EDIT);
                   3037:                        continue; }
                   3038: 
                   3039:                if(!stricmp(p,"USER_DEFAULTS")) {
                   3040:                        fprintf(out,"%c",CS_USER_DEFAULTS);
                   3041:                        continue; }
                   3042: 
                   3043:                if(!stricmp(p,"PAGE_SYSOP")) {
                   3044:                        fprintf(out,"%c",CS_PAGE_SYSOP);
                   3045:                        continue; }
                   3046:                if(!stricmp(p,"PAGE_GURU")) {
                   3047:                        fprintf(out,"%c",CS_PAGE_GURU);
                   3048:                        continue; }
                   3049:                if(!stricmp(p,"SPY")) {
                   3050:                        fprintf(out,"%c",CS_SPY);
                   3051:                        continue; }
                   3052: 
                   3053: 
                   3054:                if(!stricmp(p,"PRIVATE_CHAT")) {
                   3055:                        fprintf(out,"%c",CS_PRIVATE_CHAT);
                   3056:                        continue; }
                   3057: 
                   3058:                if(!stricmp(p,"PRIVATE_MESSAGE")) {
                   3059:                        fprintf(out,"%c",CS_PRIVATE_MESSAGE);
                   3060:                        continue; }
                   3061: 
1.1.1.2 ! root     3062:                if(!stricmp(p,"MULTINODE_CHAT")) {
        !          3063:                        if(!(*arg)) 
        !          3064:                                ch=1;
        !          3065:                        else {
        !          3066:                                if((l=isvar(arg))!=0) {
        !          3067:                                        fputc(CS_USE_INT_VAR,out);
        !          3068:                                        fwrite(&l,4,1,out); // variable
        !          3069:                                        fputc(1,out);           // int offset
        !          3070:                                        fputc(1,out);       // int length
        !          3071:                                        ch=0; }                         // place holder
        !          3072:                                else
        !          3073:                                        ch=val(src,arg);
        !          3074:                        }
        !          3075: 
        !          3076:                        fprintf(out,"%c%c",CS_MULTINODE_CHAT,ch);
        !          3077:                        continue; }
        !          3078: 
1.1       root     3079:                if(!stricmp(p,"MAIL_READ")) {
                   3080:                        fprintf(out,"%c",CS_MAIL_READ);
                   3081:                        continue; }
                   3082:                if(!stricmp(p,"MAIL_READ_SENT")) {       /* Kill/read sent mail */
                   3083:                        fprintf(out,"%c",CS_MAIL_READ_SENT);
                   3084:                        continue; }
                   3085:                if(!stricmp(p,"MAIL_READ_ALL")) {
                   3086:                        fprintf(out,"%c",CS_MAIL_READ_ALL);
                   3087:                        continue; }
                   3088:                if(!stricmp(p,"MAIL_SEND")) {       /* Send E-mail */
                   3089:                        fprintf(out,"%c",CS_MAIL_SEND);
                   3090:                        continue; }
                   3091:                if(!stricmp(p,"MAIL_SEND_FEEDBACK")) {       /* Feedback */
                   3092:                        fprintf(out,"%c",CS_MAIL_SEND_FEEDBACK);
                   3093:                        continue; }
                   3094:                if(!stricmp(p,"MAIL_SEND_NETMAIL")) {
                   3095:                        fprintf(out,"%c",CS_MAIL_SEND_NETMAIL);
                   3096:                        continue; }
                   3097:                if(!stricmp(p,"MAIL_SEND_NETFILE")) {
                   3098:                        fprintf(out,"%c",CS_MAIL_SEND_NETFILE);
                   3099:                        continue; }
                   3100:                if(!stricmp(p,"MAIL_SEND_FILE")) {   /* Upload Attached File to E-mail */
                   3101:                        fprintf(out,"%c",CS_MAIL_SEND_FILE);
                   3102:                        continue; }
                   3103:                if(!stricmp(p,"MAIL_SEND_BULK")) {
                   3104:                        fprintf(out,"%c",CS_MAIL_SEND_BULK);
                   3105:                        continue; }
                   3106: 
                   3107: 
                   3108:                if(!stricmp(p,"MSG_SET_AREA")) {
                   3109:                        fprintf(out,"%c",CS_MSG_SET_AREA);
                   3110:                        continue; }
                   3111:                if(!stricmp(p,"MSG_SET_GROUP")) {
                   3112:                        fprintf(out,"%c",CS_MSG_SET_GROUP);
                   3113:                        continue; }
                   3114:                if(!stricmp(p,"MSG_SELECT_AREA")) {
                   3115:                        fprintf(out,"%c",CS_MSG_SELECT_AREA);
                   3116:                        continue; }
                   3117:                if(!stricmp(p,"MSG_SHOW_GROUPS")) {
                   3118:                        fprintf(out,"%c",CS_MSG_SHOW_GROUPS);
                   3119:                        continue; }
                   3120:                if(!stricmp(p,"MSG_SHOW_SUBBOARDS")) {
                   3121:                        fprintf(out,"%c",CS_MSG_SHOW_SUBBOARDS);
                   3122:                        continue; }
                   3123:                if(!stricmp(p,"MSG_GROUP_UP")) {
                   3124:                        fprintf(out,"%c",CS_MSG_GROUP_UP);
                   3125:                        continue; }
                   3126:                if(!stricmp(p,"MSG_GROUP_DOWN")) {
                   3127:                        fprintf(out,"%c",CS_MSG_GROUP_DOWN);
                   3128:                        continue; }
                   3129:                if(!stricmp(p,"MSG_SUBBOARD_UP")) {
                   3130:                        fprintf(out,"%c",CS_MSG_SUBBOARD_UP);
                   3131:                        continue; }
                   3132:                if(!stricmp(p,"MSG_SUBBOARD_DOWN")) {
                   3133:                        fprintf(out,"%c",CS_MSG_SUBBOARD_DOWN);
                   3134:                        continue; }
                   3135:                if(!stricmp(p,"MSG_GET_SUB_NUM")) {
                   3136:                        fprintf(out,"%c",CS_MSG_GET_SUB_NUM);
                   3137:                        continue; }
                   3138:                if(!stricmp(p,"MSG_GET_GRP_NUM")) {
                   3139:                        fprintf(out,"%c",CS_MSG_GET_GRP_NUM);
                   3140:                        continue; }
                   3141:                if(!stricmp(p,"MSG_READ")) {
                   3142:                        fprintf(out,"%c",CS_MSG_READ);
                   3143:                        continue; }
                   3144:                if(!stricmp(p,"MSG_POST")) {
                   3145:                        fprintf(out,"%c",CS_MSG_POST);
                   3146:                        continue; }
                   3147:                if(!stricmp(p,"MSG_QWK")) {
                   3148:                        fprintf(out,"%c",CS_MSG_QWK);
                   3149:                        continue; }
                   3150:                if(!stricmp(p,"MSG_PTRS_CFG")) {
                   3151:                        fprintf(out,"%c",CS_MSG_PTRS_CFG);
                   3152:                        continue; }
                   3153:                if(!stricmp(p,"MSG_PTRS_REINIT")) {
                   3154:                        fprintf(out,"%c",CS_MSG_PTRS_REINIT);
                   3155:                        continue; }
                   3156:                if(!stricmp(p,"MSG_NEW_SCAN_CFG")) {
                   3157:                        fprintf(out,"%c",CS_MSG_NEW_SCAN_CFG);
                   3158:                        continue; }
                   3159:                if(!stricmp(p,"MSG_NEW_SCAN")) {
                   3160:                        fprintf(out,"%c",CS_MSG_NEW_SCAN);
                   3161:                        continue; }
                   3162:                if(!stricmp(p,"MSG_NEW_SCAN_SUB")) {
                   3163:                        fprintf(out,"%c",CS_MSG_NEW_SCAN_SUB);
                   3164:                        continue; }
                   3165:                if(!stricmp(p,"MSG_NEW_SCAN_ALL")) {
                   3166:                        fprintf(out,"%c",CS_MSG_NEW_SCAN_ALL);
                   3167:                        continue; }
                   3168:                if(!stricmp(p,"MSG_CONT_SCAN")) {
                   3169:                        fprintf(out,"%c",CS_MSG_CONT_SCAN);
                   3170:                        continue; }
                   3171:                if(!stricmp(p,"MSG_CONT_SCAN_ALL")) {
                   3172:                        fprintf(out,"%c",CS_MSG_CONT_SCAN_ALL);
                   3173:                        continue; }
                   3174:                if(!stricmp(p,"MSG_BROWSE_SCAN")) {
                   3175:                        fprintf(out,"%c",CS_MSG_BROWSE_SCAN);
                   3176:                        continue; }
                   3177:                if(!stricmp(p,"MSG_BROWSE_SCAN_ALL")) {
                   3178:                        fprintf(out,"%c",CS_MSG_BROWSE_SCAN_ALL);
                   3179:                        continue; }
                   3180:                if(!stricmp(p,"MSG_FIND_TEXT")) {
                   3181:                        fprintf(out,"%c",CS_MSG_FIND_TEXT);
                   3182:                        continue; }
                   3183:                if(!stricmp(p,"MSG_FIND_TEXT_ALL")) {
                   3184:                        fprintf(out,"%c",CS_MSG_FIND_TEXT_ALL);
                   3185:                        continue; }
                   3186:                if(!stricmp(p,"MSG_YOUR_SCAN_CFG")) {
                   3187:                        fprintf(out,"%c",CS_MSG_YOUR_SCAN_CFG);
                   3188:                        continue; }
                   3189:                if(!stricmp(p,"MSG_YOUR_SCAN")) {
                   3190:                        fprintf(out,"%c",CS_MSG_YOUR_SCAN);
                   3191:                        continue; }
                   3192:                if(!stricmp(p,"MSG_YOUR_SCAN_ALL")) {
                   3193:                        fprintf(out,"%c",CS_MSG_YOUR_SCAN_ALL);
                   3194:                        continue; }
                   3195:                if(!stricmp(p,"CHAT_SECTION")) {
                   3196:                        fprintf(out,"%c",CS_CHAT_SECTION);
                   3197:                        continue; }
                   3198:                if(!stricmp(p,"TEXT_FILE_SECTION")) {
                   3199:                        fprintf(out,"%c",CS_TEXT_FILE_SECTION);
                   3200:                        continue; }
                   3201:                if(!stricmp(p,"XTRN_EXEC")) {
                   3202:                        fprintf(out,"%c",CS_XTRN_EXEC);
                   3203:                        continue; }
                   3204:                if(!stricmp(p,"XTRN_SECTION")) {
                   3205:                        fprintf(out,"%c",CS_XTRN_SECTION);
                   3206:                        continue; }
                   3207: 
                   3208:                if(!stricmp(p,"FILE_SET_AREA")) {
                   3209:                        fprintf(out,"%c",CS_FILE_SET_AREA);
                   3210:                        continue; }
                   3211:                if(!stricmp(p,"FILE_SET_LIBRARY")) {
                   3212:                        fprintf(out,"%c",CS_FILE_SET_LIBRARY);
                   3213:                        continue; }
                   3214:                if(!stricmp(p,"FILE_SELECT_AREA")) {
                   3215:                        fprintf(out,"%c",CS_FILE_SELECT_AREA);
                   3216:                        continue; }
                   3217:                if(!stricmp(p,"FILE_SHOW_LIBRARIES")) {
                   3218:                        fprintf(out,"%c",CS_FILE_SHOW_LIBRARIES);
                   3219:                        continue; }
                   3220:                if(!stricmp(p,"FILE_SHOW_DIRECTORIES")) {
                   3221:                        fprintf(out,"%c",CS_FILE_SHOW_DIRECTORIES);
                   3222:                        continue; }
                   3223:                if(!stricmp(p,"FILE_LIBRARY_UP")) {
                   3224:                        fprintf(out,"%c",CS_FILE_LIBRARY_UP);
                   3225:                        continue; }
                   3226:                if(!stricmp(p,"FILE_LIBRARY_DOWN")) {
                   3227:                        fprintf(out,"%c",CS_FILE_LIBRARY_DOWN);
                   3228:                        continue; }
                   3229:                if(!stricmp(p,"FILE_DIRECTORY_UP")) {
                   3230:                        fprintf(out,"%c",CS_FILE_DIRECTORY_UP);
                   3231:                        continue; }
                   3232:                if(!stricmp(p,"FILE_DIRECTORY_DOWN")) {
                   3233:                        fprintf(out,"%c",CS_FILE_DIRECTORY_DOWN);
                   3234:                        continue; }
                   3235:                if(!stricmp(p,"FILE_GET_DIR_NUM")) {
                   3236:                        fprintf(out,"%c",CS_FILE_GET_DIR_NUM);
                   3237:                        continue; }
                   3238:                if(!stricmp(p,"FILE_GET_LIB_NUM")) {
                   3239:                        fprintf(out,"%c",CS_FILE_GET_LIB_NUM);
                   3240:                        continue; }
                   3241:                if(!stricmp(p,"FILE_UPLOAD")) {
                   3242:                        fprintf(out,"%c",CS_FILE_UPLOAD);
                   3243:                        continue; }
                   3244:                if(!stricmp(p,"FILE_UPLOAD_USER")) {
                   3245:                        fprintf(out,"%c",CS_FILE_UPLOAD_USER);
                   3246:                        continue; }
                   3247:                if(!stricmp(p,"FILE_UPLOAD_BULK")) {
                   3248:                        fprintf(out,"%c",CS_FILE_UPLOAD_BULK);
                   3249:                        continue; }
                   3250:                if(!stricmp(p,"FILE_UPLOAD_SYSOP")) {
                   3251:                        fprintf(out,"%c",CS_FILE_UPLOAD_SYSOP);
                   3252:                        continue; }
                   3253:                if(!stricmp(p,"FILE_RESORT_DIRECTORY")) {
                   3254:                        fprintf(out,"%c",CS_FILE_RESORT_DIRECTORY);
                   3255:                        continue; }
                   3256:                if(!stricmp(p,"FILE_SET_ALT_PATH")) {
                   3257:                        fprintf(out,"%c",CS_FILE_SET_ALT_PATH);
                   3258:                        continue; }
                   3259:                if(!stricmp(p,"FILE_GET")) {
                   3260:                        fprintf(out,"%c",CS_FILE_GET);
                   3261:                        continue; }
                   3262:                if(!stricmp(p,"FILE_SEND")) {
                   3263:                        fprintf(out,"%c",CS_FILE_SEND);
                   3264:                        continue; }
                   3265:                if(!stricmp(p,"FILE_PUT")) {
                   3266:                        fprintf(out,"%c",CS_FILE_PUT);
                   3267:                        continue; }
1.1.1.2 ! root     3268:                if(!stricmp(p,"FILE_RECEIVE")) {
        !          3269:                        fprintf(out,"%c",CS_FILE_RECEIVE);
        !          3270:                        continue; }
1.1       root     3271:                if(!stricmp(p,"FILE_FIND_OLD")) {
                   3272:                        fprintf(out,"%c",CS_FILE_FIND_OLD);
                   3273:                        continue; }
                   3274:                if(!stricmp(p,"FILE_FIND_OPEN")) {
                   3275:                        fprintf(out,"%c",CS_FILE_FIND_OPEN);
                   3276:                        continue; }
                   3277:                if(!stricmp(p,"FILE_FIND_OFFLINE")) {
                   3278:                        fprintf(out,"%c",CS_FILE_FIND_OFFLINE);
                   3279:                        continue; }
                   3280:                if(!stricmp(p,"FILE_FIND_OLD_UPLOADS")) {
                   3281:                        fprintf(out,"%c",CS_FILE_FIND_OLD_UPLOADS);
                   3282:                        continue; }
                   3283:                if(!stricmp(p,"FILE_DOWNLOAD")) {
                   3284:                        fprintf(out,"%c",CS_FILE_DOWNLOAD);
                   3285:                        continue; }
                   3286:                if(!stricmp(p,"FILE_DOWNLOAD_USER")) {
                   3287:                        fprintf(out,"%c",CS_FILE_DOWNLOAD_USER);
                   3288:                        continue; }
                   3289:                if(!stricmp(p,"FILE_DOWNLOAD_BATCH")) {
                   3290:                        fprintf(out,"%c",CS_FILE_DOWNLOAD_BATCH);
                   3291:                        continue; }
                   3292:                if(!stricmp(p,"FILE_REMOVE")) {
                   3293:                        fprintf(out,"%c",CS_FILE_REMOVE);
                   3294:                        continue; }
                   3295:                if(!stricmp(p,"FILE_LIST")) {
                   3296:                        fprintf(out,"%c",CS_FILE_LIST);
                   3297:                        continue; }
                   3298:                if(!stricmp(p,"FILE_LIST_EXTENDED")) {
                   3299:                        fprintf(out,"%c",CS_FILE_LIST_EXTENDED);
                   3300:                        continue; }
                   3301:                if(!stricmp(p,"FILE_VIEW")) {
                   3302:                        fprintf(out,"%c",CS_FILE_VIEW);
                   3303:                        continue; }
                   3304:                if(!stricmp(p,"FILE_FIND_TEXT")) {
                   3305:                        fprintf(out,"%c",CS_FILE_FIND_TEXT);
                   3306:                        continue; }
                   3307:                if(!stricmp(p,"FILE_FIND_TEXT_ALL")) {
                   3308:                        fprintf(out,"%c",CS_FILE_FIND_TEXT_ALL);
                   3309:                        continue; }
                   3310:                if(!stricmp(p,"FILE_FIND_NAME")) {
                   3311:                        fprintf(out,"%c",CS_FILE_FIND_NAME);
                   3312:                        continue; }
                   3313:                if(!stricmp(p,"FILE_FIND_NAME_ALL")) {
                   3314:                        fprintf(out,"%c",CS_FILE_FIND_NAME_ALL);
                   3315:                        continue; }
                   3316:                if(!stricmp(p,"FILE_BATCH_SECTION")) {
                   3317:                        fprintf(out,"%c",CS_FILE_BATCH_SECTION);
                   3318:                        continue; }
                   3319:                if(!stricmp(p,"FILE_TEMP_SECTION")) {
                   3320:                        fprintf(out,"%c",CS_FILE_TEMP_SECTION);
                   3321:                        continue; }
                   3322:                if(!stricmp(p,"FILE_NEW_SCAN")) {
                   3323:                        fprintf(out,"%c",CS_FILE_NEW_SCAN);
                   3324:                        continue; }
                   3325:                if(!stricmp(p,"FILE_NEW_SCAN_ALL")) {
                   3326:                        fprintf(out,"%c",CS_FILE_NEW_SCAN_ALL);
                   3327:                        continue; }
                   3328:                if(!stricmp(p,"FILE_NEW_SCAN_CFG")) {
                   3329:                        fprintf(out,"%c",CS_FILE_NEW_SCAN_CFG);
                   3330:                        continue; }
                   3331:                if(!stricmp(p,"FILE_PTRS_CFG")) {
                   3332:                        fprintf(out,"%c",CS_FILE_PTRS_CFG);
                   3333:                        continue; }
                   3334:                if(!stricmp(p,"FILE_BATCH_ADD")) {
                   3335:                        fprintf(out,"%c",CS_FILE_BATCH_ADD);
                   3336:                        continue; }
                   3337:                if(!stricmp(p,"FILE_BATCH_ADD_LIST")) {
                   3338:                        fprintf(out,"%c",CS_FILE_BATCH_ADD_LIST);
                   3339:                        continue; }
                   3340:                if(!stricmp(p,"FILE_BATCH_CLEAR")) {
                   3341:                        fprintf(out,"%c",CS_FILE_BATCH_CLEAR);
                   3342:                        continue; }
                   3343: 
                   3344:                if(!stricmp(p,"INC_MAIN_CMDS")) {
                   3345:                        fprintf(out,"%c",CS_INC_MAIN_CMDS);
                   3346:                        continue; }
                   3347:                if(!stricmp(p,"INC_FILE_CMDS")) {
                   3348:                        fprintf(out,"%c",CS_INC_FILE_CMDS);
                   3349:                        continue; }
                   3350: 
                   3351:                break; }
                   3352: 
                   3353: 
                   3354:        if(!feof(in)) {
                   3355:                printf("SYNTAX ERROR:\n");
                   3356:                printf(linestr,src,line,save);
1.1.1.2 ! root     3357:                bail(1); }
1.1       root     3358:        fclose(in);
                   3359:        free(str);
                   3360:        free(save);
                   3361: }
                   3362: 
                   3363: char *banner=  "\n"
1.1.1.2 ! root     3364:                                "BAJA v2.33 - Synchronet Shell/Module Compiler - "
        !          3365:                                "Copyright 2003 Rob Swindell\n";
1.1       root     3366: 
                   3367: char *usage=   "\n"
1.1.1.2 ! root     3368:                                "usage: baja [-opts] file[.src]\n"
1.1       root     3369:                                "\n"
1.1.1.2 ! root     3370:                                " opts: -d display debug during compile\n"
        !          3371:                                "       -c case sensitive variables, labels, and macros\n"
        !          3372:                                "       -o set output directory (e.g. -o/sbbs/exec)\n"
        !          3373:                                "       -i set include directory (e.g. -i/sbbs/exec)\n"
        !          3374:                                "       -q quiet mode (no banner)\n"
        !          3375:                                "       -p pause on error\n"
1.1       root     3376:                                ;
                   3377: 
                   3378: int main(int argc, char **argv)
                   3379: {
1.1.1.2 ! root     3380:        uchar str[128],src[128]="",*p;
1.1       root     3381:        int i,j;
                   3382:        int show_banner=1;
                   3383: 
                   3384:        for(i=1;i<argc;i++)
1.1.1.2 ! root     3385:                if(argv[i][0]=='-'
        !          3386: #ifdef _WIN32
        !          3387:                        || argv[i][0]=='/'
        !          3388: #endif
        !          3389:                        )
1.1       root     3390:                        switch(toupper(argv[i][1])) {
                   3391:                                case 'D':
                   3392:                                        display=1;
                   3393:                                        break;
                   3394:                                case 'C':
                   3395:                                        case_sens=1;
                   3396:                                        break;
                   3397:                                case 'O':
1.1.1.2 ! root     3398:                                        SAFECOPY(output_dir,argv[i]+2);
        !          3399:                                        backslash(output_dir);
        !          3400:                                        break;
        !          3401:                                case 'I':
        !          3402:                                        SAFECOPY(include_dir,argv[i]+2);
        !          3403:                                        backslash(include_dir);
        !          3404:                                        break;
        !          3405:                                case 'P':
        !          3406:                                        pause_on_error=TRUE;
1.1       root     3407:                                        break;
                   3408:                                case 'Q':
                   3409:                                        show_banner=0;
                   3410:                                        break;
                   3411:                                default:
                   3412:                                        printf(banner);
                   3413:                                        printf(usage);
1.1.1.2 ! root     3414:                                        bail(1); }
1.1       root     3415:                else
                   3416:                        strcpy(src,argv[i]);
                   3417: 
                   3418:        if(show_banner)
                   3419:                printf(banner);
                   3420: 
                   3421:        if(!src[0]) {
                   3422:                printf(usage);
1.1.1.2 ! root     3423:                bail(1)        !          3424:        }
        !          3425: 
        !          3426:        if(include_dir[0]==0) {                         /* Include directory not specified */
        !          3427:                SAFECOPY(include_dir,src);              /* Default to same dir as src file */
        !          3428:                if((p=getfname(include_dir))!=NULL)
        !          3429:                        *p=0;                                           /* Truncate off the src filename */
        !          3430:        }
        !          3431:        if(getfext(src)==NULL)
        !          3432:                strcat(src,".src");
1.1       root     3433: 
1.1.1.2 ! root     3434:        SAFECOPY(bin_file,src);
        !          3435:        if((p=getfext(bin_file))!=NULL)
1.1       root     3436:                *p=0;
1.1.1.2 ! root     3437:        strcat(bin_file,".bin");
1.1       root     3438: 
1.1.1.2 ! root     3439:        if(output_dir[0]) {
        !          3440:                p=getfname(bin_file);
        !          3441:                sprintf(str,"%s%s",output_dir,bin_file);
        !          3442:                SAFECOPY(bin_file,str); 
        !          3443:        }
1.1       root     3444: 
1.1.1.2 ! root     3445:        if((out=fopen(bin_file,"w+b"))==NULL) {
        !          3446:                printf("error %d opening %s for write\n",errno,bin_file);
        !          3447:                bail(1)        !          3448:        }
1.1       root     3449: 
                   3450:        printf("\nCompiling %s...\n",src);
                   3451: 
                   3452:        compile(src);
                   3453: 
                   3454:        /****************************/
                   3455:        /* Resolve GOTOS and CALLS */
                   3456:        /****************************/
                   3457: 
                   3458:        printf("Resolving labels...\n");
                   3459: 
                   3460:        for(i=0;i<gotos;i++) {
                   3461:                for(j=0;j<labels;j++)
                   3462:                        if(!stricmp(goto_label[i],label_name[j]))
                   3463:                                break;
                   3464:                if(j>=labels) {
                   3465:                        printf("%s line %d: label (%s) not found.\n"
                   3466:                                ,goto_file[i],goto_line[i],goto_label[i]);
1.1.1.2 ! root     3467:                        bail(1); }
1.1       root     3468:                fseek(out,(long)(goto_indx[i]+1),SEEK_SET);
                   3469:                fwrite(&label_indx[j],2,1,out); }
                   3470: 
                   3471:        for(i=0;i<calls;i++) {
                   3472:                for(j=0;j<labels;j++)
                   3473:                        if((!case_sens
                   3474:                                && !strnicmp(call_label[i],label_name[j],strlen(call_label[i])))
                   3475:                        || (case_sens
                   3476:                                && !strncmp(call_label[i],label_name[j],strlen(call_label[i]))))
                   3477:                                break;
                   3478:                if(j>=labels) {
                   3479:                        printf("%s line %d: label (%s) not found.\n"
                   3480:                                ,call_file[i],call_line[i],call_label[i]);
1.1.1.2 ! root     3481:                        bail(1); }
1.1       root     3482:                fseek(out,(long)(call_indx[i]+1),SEEK_SET);
                   3483:                fwrite(&label_indx[j],2,1,out); }
                   3484: 
                   3485:        printf("\nDone.\n");
                   3486:        return(0);
                   3487: }
                   3488: 
                   3489: 
                   3490: 

unix.superglobalmegacorp.com

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