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