home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /*======================================================================*/
- /* XBBS Bulletin Board System.....XBS file interpreter */
- /* This is the heart of XBBS and a really nasty function. Will only */
- /* compile via assembly due to bloated size. Bleach. */
- /* This has to be reentrant. */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
- extern struct _mboard far *marea;
- extern struct _fboard holdboard;
- extern struct _mboard holdmboard;
- extern char exporting;
- extern word maxareas;
- extern word higharea;
- word lastlevel[10]={
- 0,0,0,0,0,0,0,0,0,0
- };
-
-
- char pascal readfile (file,abort,pause,imbed) /* READS FILE TO MODEM & SCREEN */
-
- char *file;
- char abort;
- char pause;
- char imbed;
-
- {
-
- static int outputhandle=-1;
- static int inputhandle=-1;
- int handle=-1;
- char ext[5];
- char str[396];
- char a;
- word register x;
- char arg;
- char p;
- char *pp;
- char *cm;
- char *b=NULL;
- static char c[256];
- static char d[396];
- char tempause;
- char filename[104];
- static char label[33];
- long markedplace;
- word secl;
- char alabel[33];
- char hotkeys[37];
- long markedspots[10];
- char already=0;
- word nofiles=0;
- ulong totalbytes=0;
- char tempsafe;
- struct ffblk f1;
-
- *label=0;
- *alabel=0;
- strcpy(filename,file);
-
- restart:
-
- for (x=0;x<10;x++) markedspots[x]=0;
- *hotkeys=0;
- stripcr(filename);
- arg = 0;
- a='*';
- redraw_stat(NULL);
- right(ext,filename,4);
- if (!stricmp(ext,".XBS") && !strchr(filename,'\\')) {
- if (!strcmp(filename,"GOODBYE.XBS")) leaving=1;
- strcpy(d,filename);
- sprintf(filename,"%s%s",conf.menupath,d);
- }
- if (user.graphics) {
- /* REPLACE .XBS suffix with .GBS if available */
- if (!stricmp(ext,".XBS")) {
- b=strchr(filename,'.');
- b++;
- *b='G';
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) *b='X';
- cclose(handle);
- }
- }
- /* cls(); */
- handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE);
-
- GotGraphics:
-
- if (handle == -1) {
- if (stricmp(ext,".XBS")) {
- say_prompt(8);
- lprint(filename);
- }
- return(2);
- }
-
- if (eof(handle)) {
- cclose(handle);
- return (2);
- }
-
- if(conf.logmenu) gprintf(LOGONLY,"Read menu %s",filename);
- if (!pause) pauser=1;
- tempause=pauser;
- do {
- getxbbstime();
- b=fgetsx(str, 396, handle);
- BreakIn:
- if (b==NULL) break;
- if(conf.trace)redraw_stat(b);
-
- /* Embedded command processing here */
-
- if (imbed) {
- do {
- if (b==NULL) break;
- cm=strchr(b,1);
- if (cm) {
- pauser=2;
- if (strlen(cm) > 1) {
- cm[0]='\0';
- cm++;
- printm(b);
- arg=cm[0];
- b = ++cm;
- switch (arg) {
-
- case 'l': /* SKIP LABELS (^a=Text[Enter]) */
- case ';': /* Skip comments */
- b=NULL;
- break;
-
-
- case 't': /* TIME */
- a=*b;
- b++;
- switch (a) {
- case 'c': { /* CURRENT TIME */
-
- struct time dos_time;
-
- gettime(&dos_time);
- gprintf(0,saytime(&dos_time));
- }
- break;
- case 'r': /* TIME REMAINING */
- gprintf(0,"%u",(word)(timelimit-((word)getxbbstime()/60)));
- break;
- case '=': /* TIME BRANCHING */
- case '<': /* AND SETTING */
- case '>':
- case '-':
- case '+':
- if(*b=='@') {
- b++;
- secl=(word)atol(variable[*b-'0']);
- b++;
- }
- else if (*b=='e') {
- b++;
- secl=lastlevel[*b-'0'];
- b++;
- }
- else secl=(word)atol(b);
- b=strchr(b,'l');
- if (a=='=') timelimit=((word)(getxbbstime()/60L)+(secl));
- else if (a=='-') {
- if ((long)(timelimit-secl)<(long)0) timelimit=0;
- else timelimit-=secl;
- }
- else if (a=='+') {
- if (((long)timelimit+(long)secl)<(long)65535) timelimit+=secl;
- }
- if (b==NULL) break;
- strcpy(label,b);
- b=NULL;
- if (a=='<') {
- if ((timelimit-(word)(getxbbstime()/60L))<secl) goto seeklabel;
- }
- else if ((timelimit-(word)(getxbbstime()/60L))>secl) goto seeklabel;
- break;
- case 'o': /* Timer controls...0=off/save, 1=on/restore, 2=on */
- a=*b-'0';
- b++;
- if(a<2) adjust_time(a);
- else timer_off=0;
- break;
- case 'l': /* Minutes since last caller */
- {
- long temp;
-
- temp=((time(NULL)-conf.lastcall)/60L);
- if(temp>65535L) level=65535; /* Max permissible */
- else level=(word)temp;
- }
- break;
- case 'e': /* Time sensitive events */
- { /* @texx:xx:xx yy:yy:yy lLabel */
- /* Branch to lLabel if time is */
- /* not outside of hours spec'd */
-
- struct time dos_time;
-
- struct ftime {
- bit sec: 5;
- bit min: 6;
- bit hour: 5;
- };
- union tf {
- struct ftime ft;
- int x;
- } fdt;
- b=strtok(b,":");
- fdt.ft.hour=(unsigned)atoi(b);
- fdt.ft.min=(unsigned)atoi(strtok(0,":"));
- fdt.ft.sec=(unsigned)atoi(strtok(0," ,"));
- secl=(word)fdt.x;
- fdt.ft.hour=(unsigned)atoi(strtok(0,":"));
- fdt.ft.min=(unsigned)atoi(strtok(0,":"));
- fdt.ft.sec=(unsigned)atoi(strtok(0," ,"));
- x=(word)fdt.x;
- strcpy(label,strtok(0,"\n"));
- gettime(&dos_time);
- fdt.ft.hour=dos_time.ti_hour;
- fdt.ft.min=dos_time.ti_min;
- fdt.ft.sec=dos_time.ti_sec;
- if ((word)fdt.x<secl || (word)fdt.x>x) goto seeklabel;
- b=NULL;
- }
- break;
- }
- break;
-
- case 'd': /* DATE */
- a=*b;
- b++;
- switch (a) {
- case 'c': { /* CURRENT DATE */
-
- struct date dos_date;
-
- getdate(&dos_date);
- gprintf(0,saydate(&dos_date));
- break;
- }
- case 'w': /* DAY OF WEEK */
- strncpy(c,getdttm(),3);
- c[3]=0;
- printm(c);
- if (!stricmp(c,"Tue")) printm("s");
- if (!stricmp(c,"Wed")) printm("nes");
- if (!stricmp(c,"Thu")) printm("rs");
- if (!stricmp(c,"Sat")) printm("ur");
- printm("day");
- break;
- case 'd': /* BRANCH IF NOT EQUAL TO DAY OF WEEK */
- stripcr(b);
- strncpy(c,getdttm(),3);
- c[3]=0;
- strtok(b," ,");
- strcpy(d,b);
- strcpy(label,strtok(0," ,"));
- b=NULL;
- if (!stricmp(c,d)) goto seeklabel;
- break;
- case 'a': /* BRANCH IF NOT EQUAL TO DAY */
- case 'm': { /* BRANCH IF NOT EQUAL TO MONTH */
- struct date dos_date;
- stripcr(b);
- getdate(&dos_date);
- arg=atoi(b);
- strtok(b," ,");
- strcpy(label,strtok(0," ,"));
- b=NULL;
- if (a=='m') {
- if (arg!=dos_date.da_mon) goto seeklabel;
- }
- else if (arg!=dos_date.da_day) goto seeklabel;
- break;
- }
- case 'l': { /* # days since user's last call */
-
- long temp;
-
- temp=dostounix(&user.lastdate,&user.lasttime);
- level=(word)((time(NULL)-temp)/86400L);
- }
- break;
- }
- break;
-
- case 'D': /* SET LABEL TO SEEK IF ABORTED */
- strcpy(alabel,b);
- b=NULL;
- break;
-
- case 'u': /* USER PARAMETERS */
- a=*b;
- b++;
- user_param(a);
- break;
-
- case 'j': /* JUMP TO ANOTHER FILE (ABSOLUTE) */
- *hotkeys=0;
- markedplace=tell(handle);
- if (markedplace<0) return (2);
- cclose(handle);
- strcpy(c,filename);
- if ((*b-'0')<0 || (*b-'0')>9) {
- strcpy(filename,strtok(b," ,"));
- b=strtok(0," ,");
- }
- else {
- strcpy(filename,variable[*b-'0']);
- b++;
- if (*b==' ' || *b==',') b++;
- stripcr(b);
- }
- if (b!=NULL && *b!=0) {
-
- struct ffblk f;
-
- if ((*b-'0')<0 || (*b-'0')>9) strcpy(label,b);
- else strcpy(label,variable[*b-'0']);
- b=NULL;
- if (stristr(filename,".XBS") && !strchr(filename,'\\') && !strchr(filename,':')) {
- strcpy(d,filename);
- d[12]=0;
- sprintf(filename,"%s%s",conf.menupath,d);
- }
- if (findfirst(filename,&f,0)) {
- strcpy(filename,c);
- break;
- }
- markedplace=tell(handle);
- cclose(handle);
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- gprintf(LOCALONLY,"\n\x4 Can't open `%s'\n",filename);
- strcpy(filename,c);
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) return (2);
- lseek(handle,markedplace,SEEK_SET);
- break;
- }
- goto seeklabel;
- }
- b=NULL;
- goto restart;
-
- case 'H': /* SETUP HOTKEY STRING */
- strcpy(alabel,strtok(b," ,"));
- strcat(alabel,"\n");
- strncpy(hotkeys,strupr(strtok(0," ")),36);
- stripcr(hotkeys);
- hotkeys[36]=0;
- b=strtok(0,"\n");
- break;
-
- case 'J': /* JUMP TO ANOTHER FILE (GOSUB) */
- if (*b<('9'+1) && *b>('0'-1) && b[1]=='\n') {
- readfile(variable[*b-'0'],0,0,1);
- }
- else readfile(b,0,0,1);
- b=NULL;
- break;
-
- case 'q': /* QUIT READING FILE */
- goto donereading;
-
- case 'B': /* HANG UP */
- do_hangup(handle);
-
- case 'b': /* BRANCH TO LABEL IN label */
- seeklabel2: /* Label in b */
- if (b==NULL) break;
- strcpy(label,b);
- seeklabel: /* Label already in label */
- stripcr(label);
- if(*label=='@') { /* Variable label */
- a=label[1]-'0';
- strcpy(label,variable[a]);
- }
- if(*label=='#') { /* Numeric label */
- a=label[1]-'0';
- sprintf(label,"l%u",lastlevel[a]);
- }
- if (eof(handle)) {
- cclose(handle);
- goto commanderror;
- }
- if (*label=='\01') {
- if (lseek(handle,atol(&label[1]),SEEK_SET)!=atol(&label[1]))
- lprint("\n\04Direct branch failure\n");
- goto BreakLabel;
- }
- ReTry:
- markedplace=findlabel(label,handle);
- if (markedplace==-1) {
- if (already) {
- cclose(handle);
- already=0;
- goto commanderror;
- }
- else {
- lseek(handle,0L,SEEK_SET);
- already++;
- goto ReTry;
- }
- }
- else lseek(handle,markedplace,SEEK_SET);
-
- BreakLabel:
- already=0;
- b=NULL;
- *label=0;
- break;
-
- case 'Z': /* ASSIGN FILE TO READ ON COMPLETION */
- a=*b; /* 2 Set StartFile */
- b++; /* 1 Set FileToRead */
- switch (a) /* 0 Zero FileToRead */
- {
- case '2':
- strcpy(startfile,b);
- stripcr(startfile);
- b=NULL;
- break;
- case '1':
- strcpy(filetoread,b);
- stripcr(filetoread);
- b=NULL;
- break;
- case '0':
- *filetoread=0;
- b=NULL;
- break;
- }
- break;
-
- case'E': /* RUN ANOTHER PROGRAM */
- stripcr(b);
- if (strlen(b)<2) break;
- a=*b;
- b++;
- switch (a)
- {
- case 'S': /* SHELL & SPAWN */
- case 'I':
- case 'O':
- case 'D':
- case 's':
- case 'd':
- strcpy(d,b);
- b=NULL;
- markedplace=tell(handle);
- cclose(handle);
- if (a=='S') spawnit(d,0,0);
- else if (a=='I') spawnit(d,7,0);
- else if (a=='O') spawnit(d,6,0);
- else if (a=='s') spawnit(d,8,0);
- else if (a=='d') spawnit(d,9,0);
- else spawnit(d,3,0);
- if (markedplace<0) return (2);
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) return 2;
- if (eof(handle)) {
- cclose(handle);
- return (2);
- }
- lseek(handle,markedplace,SEEK_SET);
- break;
- case 'E': /* EXECUTE */
- strcpy(d,b);
- b=NULL;
- cclose(handle);
- spawnit(d,1,0);
- b=NULL;
- goto donereading;
- case 'B': /* BATCH EXIT */
- a=atoi(b);
- b=strchr(b,' ');
- if(b)strcpy(d,b++);
- else *d=0;
- b=NULL;
- cclose(handle);
- spawnit(d,2,a);
- goto donereading;
- case 'X': /* EXIT WITH ERRORLEVEL */
- strcpy(d,b);
- b=NULL;
- cclose(handle);
- spawnit("",4,atoi(d));
- goto donereading;
- case 'W': /* WRITE CONVERTED STRING TO FILE */
- strcpy(d,b);
- b=NULL;
- spawnit(d,5,0);
- b=NULL;
- break;
- case 'w': /* Write unconverted string to file */
- strcpy(d,b);
- b=NULL;
- spawnit(d,10,0);
- b=NULL;
- break;
- }
- break;
-
- case'0': /* VARIABLE MANIPULATION*/
- case'1':
- case'2':
- case'3':
- case'4':
- case'5':
- case'6':
- case'7':
- case'8':
- case'9':
-
- p=*b;
- b++;
-
- if(p=='b') { /* Assign assocfile from var */
- strcpy(assocfile,variable[arg-'0']);
- break;
- }
-
- if(p=='g') { /* Environment variable manipulation */
- if(!(pp=strtok(b," \n"))) {
- level=2;
- b=NULL;
- break;
- }
- b=strtok(0,"\r");
- pp=getenv(pp);
- level=0;
- if(!pp){
- level=1;
- pp="";
- }
- if(*pp=='@') {
- if(isdigit(pp[1])) {
- a=pp[1]-'0';
- pp=variable[a];
- }
- }
- assignvar(pp,arg-'0');
- break;
- }
- if(p=='l') { /* Uppercase var */
- strlwr(variable[arg-'0']);
- break;
- }
- else if(p=='u') { /* Lowercase var */
- strupr(variable[arg-'0']);
- break;
- }
- else if (p=='V') { /* Compare two variables, branch on = */
- a=*b-'0';
- b++;
- if (!strcmp(variable[arg-'0'],variable[a])) goto seeklabel2;
- b=NULL;
- break;
- }
- else if (p=='A') { /* ASSIGN A VARIABLE */
- strcpy(d,b);
- stripcr(d);
- b=NULL;
- assignvar(d,arg-'0');
- break;
- }
- else if(p=='a') { /* Parse a var one char at a time */
- /* source a dest */
- a=*b-'0';
- b++;
- if (!*variable[arg-'0']) {
- *variable[a]=0;
- }
- else {
- *variable[a]=*variable[arg-'0'];
- variable[a][1]=0;
- memmove(variable[arg-'0'],&variable[arg-'0'][1],strlen(variable[arg-'0']));
- }
- break;
- }
- else if (p=='k') { /* Copy keybuf into var */
- assignvar(keybuf,arg-'0');
- break;
- }
- else if (p=='=') { /* Copy an operating var to a variable */
- sprintf(c,"*%s",stripcr(b));
- b=NULL;
- assignvar(convertstring(c),arg-'0');
- break;
- }
- else if (p=='U') { /* Put variable in user.variable */
- a=*b-'0';
- b++;
- if(a<5) {
- strncpy(user.variable[a],variable[arg-'0'],76);
- user.variable[a][75]=0;
- }
- break;
- }
- else if (p=='s') { /* Strip leading & trailing spaces */
- lstrip(variable[arg-'0']);
- rstrip(variable[arg-'0']);
- break;
- }
- else if (p=='p') { /* Parse a var */
-
- a=(*b)-'0';
- b++;
- if (a>9) break;
- stripcr(b);
- strcpy(d,variable[arg-'0']);
- if (!*b) b=" ";
- if(strstr(d,b)==d) {
- *variable[a]=0;
- strcpy(d,&variable[arg-'0'][1]);
- strcpy(variable[arg-'0'],d);
- b=NULL;
- break;
- }
- pp=strtok(d,b);
- if (pp==NULL) *variable[a]=0;
- else {
- strcpy(variable[a],pp);
- pp=strtok(0,"\n");
- if (pp) strcpy(variable[arg-'0'],pp);
- else *variable[arg-'0']=0;
- }
- b=NULL;
- break;
- }
- else if (p=='|') { /* Concatenate vars */
- a=*b-'0';
- b++;
- strncat(variable[arg-'0'],variable[a],81);
- variable[arg-'0'][81]=0;
- break;
- }
- else if (p=='/') { /* Do MID$-like operation with var */
- strtok(b," ,");
- if(*b=='e') {
- b++;
- a=(char)lastlevel[*b-'0'];
- }
- else a=(char)atoi(b);
- level=0;
- if (a>strlen(variable[arg-'0']) || !a) {
- level=1;
- b=NULL;
- break;
- }
- strcpy(c,&variable[arg-'0'][a-1]);
- b=strtok(0," \n");
- if(*b=='e') {
- b++;
- a=(char)lastlevel[*b-'0'];
- b++;
- }
- else a=(char)atoi(b);
- if (a>=0 && (a<=strlen(c))) c[a]=0;
- assignvar(c,arg-'0');
- b=NULL;
- break;
- }
- else if (p=='P') { /* PRINT A VARIABLE */
- printm(variable[arg-48]);
- break;
- }
- else if (p=='I') /* INPUT A VARIABLE */
- {
- *alabel=0;
- *hotkeys=0;
- lines=0;
- strcpy(d,b);
- b=NULL;
- c[0]=atoi(strtok(d," ,"));
- for(x=1;x<=4;)
- {
- c[x]=atoi(cm=strtok('\0'," ,"));
- if (!cm && x!=4) goto inputerror;
- ++x;
- }
- assignvar(genin(c[0],c[1],c[2],c[3],c[4]),arg-'0');
- break;
- }
-
- else if (p=='F') /* CHECK EXISTENCE OF FILE AND GET NAME */
- /* (FINDFIRST) (U=Upload Path, */
- /* D=Download Path, N=No Path */
- {
- a=toupper(*b);
- b++;
- stripcr(b);
- if (a=='U') sprintf(c,"%s%s",fboard.upath,variable[arg-'0']);
- else if (a=='D') sprintf(c,"%s%s",fboard.dpath,variable[arg-'0']);
- else strcpy(c,variable[arg-'0']);
- if (!findfirst(c,&f1,0)) {
- assignvar(f1.ff_name,arg-'0');
- level=0;
- }
- else level=1;
- break;
- }
-
- else if (p=='f') { /* FINDNEXT FILE AND GET NAME */
- if (!findnext(&f1)) {
- assignvar(f1.ff_name,arg-'0');
- level=0;
- }
- else level=1;
- break;
- }
- else if (p=='D') { /* Validate batch file d/l string */
- /* level=1 no match level=2 not enuf time */
- ulong temp2;
-
- stripcr(b);
- nofiles=0;
- level=0;
- strcpy(c,variable[arg-'0']);
- totalbytes=check_dls(c,&nofiles,1);
- if (!secl || !totalbytes) {
- level=1;
- break;
- }
- temp2=transfer_time(totalbytes,75);
- if (temp2>=(ulong)((ulong)timelimit-(getxbbstime()/60))) level=2;
- break;
- }
- else if (p=='+') { /* ADD ONE TO TIME STAMP OF FILE IN VAR */
- add_one(variable[arg-'0']);
- break;
- }
- else if (p=='C') { /* COMPARE A VARIABLE */
- /* ! branch if not equal */
- /* = branch if equal) */
- a=*b;
- b++;
- if (eof(handle)) {
- cclose(handle);
- goto commanderror;
- }
- strcpy(d,b);
- stripcr(d);
- b=fgetsx(str, 396, handle);
- if (b==NULL) {
- cclose(handle);
- goto commanderror;
- }
- if (a=='!') {
- if (strcmp(d,variable[arg-'0'])!=0) goto seeklabel2;
- }
- else if (!strcmp(d,variable[arg-'0'])) goto seeklabel2;
- b=NULL;
- break;
- }
- else if(p=='c') /* COPY ONE VARIABLE TO ANOTHER */
- /* source c dest */
- {
- a=*b-'0';
- b++;
- assignvar(variable[arg-'0'],a);
- break;
- }
- else if(p=='t') /* Test variable as a number */
- /* Set ERRORLEVEL if not in range */
- {
- level=0;
- b=strtok(b," ");
- if(*b=='e') {
- b++;
- secl=lastlevel[*b-'0'];
- }
- else secl=(word)atol(b);
- if (secl>(word)atol(variable[arg-'0'])) level=1;
- b=strtok(0," ");
- if(*b=='e') {
- b++;
- secl=lastlevel[*b-'0'];
- }
- else secl=(word)atol(b);
- if (secl<(word)atol(variable[arg-'0'])) level=1;
- b=NULL;
- break;
- }
- else if (p=='T') { /* Do ON variable-as-# GOTO */
- b=strtok(b,",");
- for (x=0;x<(char)atoi(variable[arg-'0']);x++) {
- b=strtok(0,",\n");
- }
- if (b==NULL) {
- if (conf.debug) say_prompt(256);
- break;
- }
- strcpy(label,b);
- b=NULL;
- goto seeklabel;
- }
- else if (p=='E') { /* Events */
- event[arg-'0'].secsleft=(ulong)atol(strtok(b,", "));
- b=strtok(0," \n,");
- b[12]=0;
- strcpy(event[arg-'0'].filename,b);
- if(conf.debug) gprintf(LOCALONLY,"\n\04Event #%hu @ %lu secs will read %s\n",arg-'0',event[arg-'0'].secsleft,event[arg-'0'].filename);
- b=NULL;
- break;
- }
- else if (p=='S' || p=='Z') { /* Partial compare or INSTR */
- strcpy(d,b); /* S is part comp, Z is instr */
- b=fgetsx(str, 396, handle);
- if (b==NULL) {
- cclose(handle);
- goto commanderror;
- }
- stripcr(d);
- if (p=='S') {
- if (!strncmp(d,variable[arg-'0'],strlen(d))) goto seeklabel2;
- }
- else {
- if (cm=strstr(variable[arg-'0'],d)) {
- level=(word)((int)cm-(int)variable[arg-'0'])+1;
- goto seeklabel2;
- }
- }
- break;
- }
- else if (p=='i') { /* Do INSTR for vars */
- a=*b-'0';
- b++;
- if (a<0 || a>9) break;
- level=0;
- if (cm=strstr(variable[arg-'0'],variable[a])) {
- level=(word)((int)cm-(int)variable[arg-'0'])+1;
- goto seeklabel2;
- }
- b=NULL;
- break;
- }
- else if (p=='e') { /* Get saved errorlevel */
- a=*b-'0';
- b++;
- if(a<0 || a>9) break;
- sprintf(variable[arg-'0'],"%u",lastlevel[a]);
- break;
- }
- else if (p=='d') { /* Convert and print */
- printm(convertstring(variable[arg-'0']));
- break;
- }
- else b--;
- break;
-
- case '+': /* (CHANGE CURRENT FILENAME) AND RESTART */
- stripcr(b);
- if (strlen(b)) strcpy(filename,b);
- else strcpy(filename,file);
- b=NULL;
- cclose(handle);
- goto restart;
-
- case 'x': /* LOGOFF */
- safe=0;
- cclose(handle);
- fossil(FLUSHOUT,0);
- if (*b>'0') baud=0;
- fossil(DTR,DOWN);
- baud=0;
- leaving++;
- logoff();
- userno=0;
- if(*b<'2') exit(254);
-
- case 'Q': /* QUERY USERLIST */
- userlist((word)atoi(b=strtok(b," ")));
- b++;
- break;
-
- case 'R': /* RESTART AT LABEL */
- strcpy(label,b);
- lseek(handle,0L,SEEK_SET);
- goto seeklabel;
-
- case '\x1b': /* ANSI IF THEY GOT IT */
- if(!user.graphics) b=NULL;
- continue;
-
- case 'P': /* PAUSE # SECONDS */
- fossil(PURGEOUT,0);
- sleep(atoi(b));
- lines=0;
- b=strchr(b,' ');
- break;
-
- case 'a': /* ABORT ON OR OFF */
- abort=(char)atoi(b++);
- break;
-
- case 'p': /* PAUSE ON OR OFF */
- pause=(char)atoi(b++);
- tempause=1 - pause;
- break;
-
- case 'Y': /* DISABLE COMMANDS */
- imbed=0;
- break;
-
- case 'v': /* CHANGE USER PARAMS */
- a=*b;
- b++;
- if(*b=='e') {
- secl=lastlevel[b[1]-'0'];
- }
- else secl=(word)atol(b);
- lines=0;
- if(change_parm(a,secl,f1.ff_fsize,totalbytes,nofiles,b)) b=NULL;
- break;
-
- case 'h': /* HALT UNTIL [Enter] HIT */
- hitreturn();
- break;
-
- case 'S': /* BRANCH ON SEC LEVELS */
- a=*b; /* </> */
- b++;
- arg=b[0]-'0'; /* Sec# */
- b++;
- if(*b=='e') secl=lastlevel[b[1]-'0'];
- else secl=(word)atoi(b); /* Level */
- b=strchr(b,'l');
- if (b==NULL) break;
- strcpy(label,b);
- b=NULL;
- if (a=='<')
- {
- if (secl>user.stat[arg]) goto seeklabel;
- }
- else if (secl<user.stat[arg]) goto seeklabel;
- break;
-
- case 'y': /* SYSTEM PARAMETERS */
- lines=0;
- a=*b;
- b++;
- if(system_parms (a,*b)) b++;
- break;
-
- case 'f': /* Do raw dir, readany, readnew, filesbbs, readtext, etc. */
- a=*b;
- b++;
- stripcr(b);
- switch (a) {
- case 'f': /* FILES.BBS-style read (filename,type (0=down
- 1=up 2=new 4=new 8=asktodl 128=limitarea)) */
- a=atoi(b);
- strtok(b," ,");
- b=strtok(0," ,");
- cm=strtok(0," ,");
- if(!cm)cm=saydate(&user.lastdate);
- if(*cm=='@') {
- strcpy(c,variable[cm[1]-'0']);
- cm=c;
- }
- pp=strtok(0," ,");
- if(pp && *pp=='@') {
- strcpy(d,variable[pp[1]-'0']);
- pp=d;
- }
- level=0;
- level=filesbbs(b,a,cm,pp);
- b=NULL;
- break;
- case 'r': /* Raw dir...type (0-2) and directory */
- a=atoi(b);
- strtok(b," ,");
- rawdir(strtok(0," ,"),a);
- b=NULL;
- break;
- case 'a': /* Read any, directory, extension (or null) */
- cm=strtok(b," ,");
- if (cm[0]=='*') cm[0]=0;
- b=strtok(0," ,");
- readany(b,cm,(char)atoi(strtok(0," ,")));
- b=NULL;
- cm=NULL;
- break;
- case 'n': /* Read new files */
- readnew(strtok(b," ,"),(char)atoi(strtok(0," ,")));
- b=NULL;
- break;
- case 'd': { /* Output file description in f1 */
- struct fdate {
- bit day: 5;
- bit month: 4;
- bit year: 7;
- };
- union df {
- struct fdate fd;
- int x;
- } fdf;
- secl=baud;
- if (!secl) secl=1200;
- markedplace=(long)((((f1.ff_fsize)/secl)*1000)/80);
- fdf.x=f1.ff_fdate;
- gprintf(0,"%-12s (%lu bytes) %02u/%02u/%02u %d mins %d secs @ %u baud\n",f1.ff_name,f1.ff_fsize,fdf.fd.month,fdf.fd.day,fdf.fd.year+80,(int)markedplace/60,(int)markedplace%60,secl);
- break;
- }
- case 'D': { /* Branch if drivespace < arg */
-
- struct dfree drivefree;
-
- a=*b;
- b++;
- getdfree((a-'@'),&drivefree);
- strtok(b," ,");
- b=strtok(0," ,");
- if (b==NULL) break;
- if ((long)drivefree.df_avail*(drivefree.df_bsec*drivefree.df_sclus)<atol(b)) {
- b=strtok(0," ,");
- if (b==NULL) break;
- strcpy(label,b);
- b=NULL;
- goto seeklabel;
- }
- b=NULL;
- break;
- }
- case 't': /* Read straight text file */
- if ((strlen(b)==1) && strchr("0123456789",*b)!=0) readtext (variable[*b-'0']);
- else readtext (b);
- b=NULL;
- break;
- }
- break;
-
- case 'F': /* Set up FILE area */
- setup_file(b);
- b=NULL;
- break;
-
- case 'M': /* Set up MESSAGE area */
- setup_msg(b);
- b=NULL;
- break;
-
- case 'X': /* Write exit files */
- b=write_exit(b);
- break;
-
- case 'e': /* ERRORLEVEL BRANCHING */
- /* < branch if < */
- /* > branch if > */
- /* 0 clear level */
- /* -- decrement level */
- /* ++ increment level */
- /* +#<#> inc saved level */
- /* -#<#> dec saved level */
- /* = set level */
- /* == branch if equal */
- /* s save level */
- /* r restore level */
- /* L level = lastread */
- /* l lastread = level */
- /* S put level in user var */
- /* V put user var in level */
- /* ~ not level */
- /* t time */
- /* /+-*%|& level */
- /* U Upload K */
- /* u Upload # */
- /* D Dload K */
- /* d Dload # */
- /* K Dload K today */
- /* k Uload K today */
- /* E Last exit time */
- /* n Number calls */
- /* R Random number */
- /* F level = user.attr2 */
- /* f user.attr2 = level */
- /* O level = tempuserno */
- /* o level = scroll lock */
- /* e>0 branch on any elevel */
- /* @# level = strlen(var#) */
- /* ? Last prompt # */
- /* P # posts (as a word) */
- /* p level = #chat pages */
- /* a level = lastmsgarea */
- /* m level = #msgs in curr */
- /* M min write accs = level */
- /* c leech% = level */
- a=*b;
- b++;
- if (a=='0') level=0;
- else if (a=='-' && *b=='-') {
- level--;
- b++;
- }
- else if (a=='+' && *b=='+') {
- level++;
- b++;
- }
- else if((a=='+' || a=='-') && *b=='#') {
- b++;
- if(isdigit(*b)) {
- if(a=='+') lastlevel[*b-'0']++;
- else lastlevel[*b-'0']--;
- b++;
- }
- }
- else if (a=='@') {
- level=strlen(variable[*b-'0']);
- b++;
- }
- else if (a=='?') level=lastprompt;
- else if (a=='~') level=(~level);
- else if (a=='n') level=(word)user.times;
- else if (a=='t') level=(word)(getxbbstime()/60L);
- else if (a=='D') level=(word)user.downk;
- else if (a=='d') level=(word)user.downno;
- else if (a=='U') level=(word)user.upk;
- else if (a=='u') level=(word)user.upno;
- else if (a=='K') level=(word)user.dktoday;
- else if (a=='k') level=(word)user.uktoday;
- else if (a=='R') level=(word)random(32767);
- else if (a=='E') level=(word)lastexittime;
- else if (a=='L') level=(word)lastread[mboard.number-1];
- else if (a=='l') lastread[mboard.number-1]=(word)level;
- else if (a=='F') level=user.attr2;
- else if (a=='f') user.attr2=level;
- else if (a=='P') level=(word)user.posts;
- else if (a=='p') level=(word)pages;
- else if (a=='a') level=(word)user.lastmsgarea;
- else if (a=='O') level=tempuserno;
- else if (a=='o') level=chk_scroll_lock();
- else if (a=='M') mboard.minwrite=level;
- else if (a=='c') fboard.leechpercent=level;
- else if (a=='m') {
-
- struct ffblk f;
- char s[133];
-
- sprintf(s,"%sXDATA.%03x",messpath,mboard.number);
- if(findfirst(s,&f,0)) level=0;
- else {
- level=(word)(f.ff_fsize/(long)sizeof(struct _xmsg));
- }
- break;
- }
- else if (a=='S') {
- a=*b-'0';
- b++;
- if(a<10)user.numvars[a]=level;
- break;
- }
- else if (a=='V') {
- a=*b-'0';
- b++;
- if(a<10)level=user.numvars[a];
- break;
- }
- else if (a=='s') {
- a=*b-'0';
- b++;
- lastlevel[a]=level;
- break;
- }
- else if (a=='r') {
- a=*b-'0';
- b++;
- level=lastlevel[a];
- break;
- }
- else if (a=='=') {
- if(*b=='=') {
- b++;
- goto CompareLevel;
- }
- else {
- if (*b=='@') {
- b++;
- level=(word)atol(variable[*b-'0']);
- }
- else if (*b=='$') {
- b++;
- stripcr(b);
- level=(word)atol(lookup_var(b));
- }
- else {
- level=(word)atol(b);
- }
- b=NULL;
- }
- break;
- }
- else if (a=='+' || a=='-' || a=='|' || a=='/' || a=='*' || a=='%' || a=='&' || a=='^') {
- if(*b=='@') {
- b++;
- secl=(word)atol(variable[*b-'0']);
- }
- else if (*b=='e') {
- b++;
- secl=lastlevel[*b-'0'];
- }
- else secl=(word)atol(b);
- b=NULL;
- switch ((int)a) {
- case '+': level += secl;
- break;
- case '-': level -= secl;
- break;
- case '/': level /= secl;
- break;
- case '*': level *= secl;
- break;
- case '%': level %= secl;
- break;
- case '|': level |= secl;
- break;
- case '&': level &= secl;
- break;
- case '^': level ^= secl;
- break;
- }
- break;
- }
- else {
- CompareLevel:
- if(*b=='e') {
- b++;
- secl=lastlevel[*b-'0'];
- strtok(b," ,");
- }
- else secl=(word)atol(strtok(b," ,"));
- strcpy(label,strtok(0," ,"));
- b=NULL;
- if (a=='<') {
- if (secl>level) goto seeklabel;
- }
- else if (a=='>') {
- if (secl<level) goto seeklabel;
- }
- else if(secl==level) goto seeklabel;
- }
- break;
-
- case 'L': /* BRANCH ON USER PARAMS */
- a=*b;
- b++;
- switch (a) {
- case 'F':
- a=(char)atoi(strtok(b," ,"));
- strcpy(label,strtok(0," ,"));
- b=NULL;
- if (a<1 || a>16) break;
- secl=1;
- secl=secl<<(--a);
- if (user.attr2 & secl) goto seeklabel;
- break;
- case 'f':
- a=(char)atoi(strtok(b," ,"));
- strcpy(label,strtok(0," ,"));
- if (a<1 || a>3) break;
- switch (a) {
- case 1: if (user.gen1) goto seeklabel;
- break;
- case 2: if (user.gen2) goto seeklabel;
- break;
- case 3: if (user.gen3) goto seeklabel;
- break;
- }
- break;
- case 's':
- if(user.scrnclr) goto seeklabel2;
- break;
- case 'g':
- if(user.fullscreen) goto seeklabel2;
- break;
- case 'A':
- if (!user.ansimenus && user.graphics) goto seeklabel2;
- break;
- case 'm':
- if(user.more) goto seeklabel2;
- break;
- case 'M':
- if (user.arq) goto seeklabel2;
- break;
- case 'T':
- if (user.twit) goto seeklabel2;
- break;
- case 'G':
- if (user.graphics) goto seeklabel2;
- break;
- case 'N':
- if (user.nokill) goto seeklabel2;
- break;
- case 'S':
- if (user.commodore) goto seeklabel2;
- break;
- case 'E':
- if (user.expert) goto seeklabel2;
- break;
- case 'H':
- if (user.ignorehrs) goto seeklabel2;
- break;
- case 'D':
- if (user.deleted) goto seeklabel2;
- break;
- case 'R':
- if (user.ignorerat) goto seeklabel2;
- break;
- case 'n':
- case 'h':
- strcpy(c,strtok(b,","));
- strcpy(label,strtok(0," ,"));
- b=NULL;
- if (a=='n') {
- if (!stricmp(user.name,c)) goto seeklabel;
- }
- else if (!stricmp(user.handle,c)) goto seeklabel;
- break;
- }
- arg=*b;
- b++;
- if(*b=='e') {
- b++;
- secl=lastlevel[*b-'0'];
- strtok(b," ,");
- }
- else secl=(word)atol(strtok(b," ,"));
- strcpy(label,strtok(0," ,"));
- b=NULL;
- switch (a) {
- case 'C': /* COMPUTER TYPE */
- if (arg=='!') {
- if (user.comptype!=(byte)secl) goto seeklabel;
- }
- else if (user.comptype==(byte)secl) goto seeklabel;
- break;
- case 'k': /* U/D KBYTE RATIO */
- if (user.downno<(word)conf.startat) break;
- if (arg=='<') {
- if ((word)((user.downk+1)/(user.upk+1))<secl) goto seeklabel;
- }
- else if ((word)((user.downk+1)/(user.upk+1))>secl) goto seeklabel;
- break;
- case '#': /* U/D # RATIO */
- if (user.downno<(word)conf.startat) break;
- if (arg=='<') {
- if ((user.downno+1)/(user.upno+1)<secl) goto seeklabel;
- }
- else if ((user.downno+1)/(user.upno+1)>secl) goto seeklabel;
- break;
- case 'b': { /* BAUD RATE */
-
- word temp;
-
- temp=baud;
- if (!temp) temp=9600;
- if (arg=='<') {
- if (temp<secl) goto seeklabel;
- }
- else if (temp>secl) goto seeklabel;
- break;
- }
- case 'v': /* VIOLATIONS */
- if (arg=='<') {
- if (user.violations<(char)secl) goto seeklabel;
- }
- else if (user.violations>(char)secl) goto seeklabel;
- break;
- case 'a': /* AGE */
- if (arg=='<') {
- if (age<(char)secl) goto seeklabel;
- }
- else if (age>(char)secl) goto seeklabel;
- break;
- case 'l': /* LENGTH */
- if (arg=='<') {
- if (user.length<(char)secl) goto seeklabel;
- }
- else if (user.length>(char)secl) goto seeklabel;
- break;
- case 'w': /* WIDTH */
- if (arg=='<') {
- if (user.width<(char)secl) goto seeklabel;
- }
- else if (user.width>(char)secl) goto seeklabel;
- break;
- case 'u': /* Upload K today */
- if (arg=='<') {
- if (user.uktoday<secl) goto seeklabel;
- }
- else if (user.uktoday>secl) goto seeklabel;
- break;
- case 'd': /* Download K today */
- if (arg=='<') {
- if (user.dktoday<secl) goto seeklabel;
- }
- else if (user.dktoday>secl) goto seeklabel;
- break;
- }
- break;
-
- case 'c': /* CHAT REQUEST */
- do_request(b);
- break;
-
- case '~': /* CLEAR SCREEN */
- cls();
- break;
-
- case 'r': /* READ A MESSAGE */
- a=(char)atoi(b);
- if(*b=='e') {
- b++;
- a=(char)lastlevel[*b-'0'];
- }
- strtok(b," ,");
- b=strtok(0," ,");
- if(*b=='@') {
- b++;
- readamessage(a,(word)atol(variable[*b-'0']));
- }
- else if (*b=='e') {
- b++;
- readamessage(a,lastlevel[*b-'0']);
- }
- else readamessage(a,(word)atol(b));
- b=NULL;
- break;
-
- case '@': /* ASSIGN SELECTED READ VARS */
- a=*b-'0';
- b++;
- stripcr(b);
- switch((int)a) {
- case 0: *msgfrom=0;
- *msgto=0;
- *msgsubj=0;
- *msgbody=0;
- break;
- case 1: if ((*b-'0')<0 || (*b-'0')>9) {
- strncpy(msgfrom,b,36);
- msgfrom[35]=0;
- }
- else {
- strncpy(msgfrom,variable[*b-'0'],36);
- msgfrom[35]=0;
- }
- break;
- case 3: if ((*b-'0')<0 || (*b-'0')>9) {
- msgsubj[63]=0;
- }
- else {
- strncpy(msgsubj,variable[*b-'0'],64);
- msgsubj[63]=0;
- }
- break;
- case 4: if ((*b-'0')<0 || (*b-'0')>9) {
- strncpy(msgbody,b,80);
- msgto[80]=0;
- }
- else {
- strncpy(msgbody,variable[*b-'0'],80);
- msgbody[80]=0;
- }
- break;
- case 2: if ((*b-'0')<0 || (*b-'0')>9) {
- strncpy(msgto,b,36);
- msgto[35]=0;
- }
- else {
- strncpy(msgto,variable[*b-'0'],36);
- msgto[35]=0;
- }
- break;
- }
- b=NULL;
- break;
-
- case 'i': { /* File input to vars */
- a=*(b++);
- switch ((int)a) {
- case 'i': if(inputhandle==-1) {
- level=1;
- b++;
- break;
- }
- if(eof(inputhandle)) {
- level=1;
- b++;
- break;
- }
- if(fgetsx(variable[*b-'0'],80,inputhandle)==NULL) {
- level=1;
- b++;
- break;
- }
- variable[*b-'0'][79]=0;
- stripcr(variable[*b-'0']);
- b++;
- level=0;
- break;
- case 'c': if(*b=='i') {
- cclose(inputhandle);
- inputhandle=(-1);
- }
- else {
- cclose(outputhandle);
- outputhandle=(-1);
- }
- b++;
- break;
- case 'a':
- case 'm': if(outputhandle!=-1) cclose(outputhandle);
- stripcr(b);
- if(*b=='@') {
- b++;
- arg=*b;
- b=variable[arg-'0'];
- }
- if(a=='m')outputhandle=ccreat(b,S_IWRITE);
- else outputhandle=oopen(b,O_RDWR | O_APPEND | O_BINARY | O_DENYWRITE);
- if(outputhandle==-1) level=1;
- else level=0;
- b=NULL;
- if(a=='a' && !level) lseek(outputhandle,0L,SEEK_END);
- break;
- case 'w': if(outputhandle==-1) {
- level=1;
- b=NULL;
- break;
- }
- if (*b=='@') {
- b++;
- if (_write(outputhandle,variable[*b-'0'],strlen(variable[*b-'0']))==-1) level=1;
- else {
- level=0;
- _write(outputhandle,"\r\n",2);
- }
- }
- else {
- stripcr(b);
- if(*b) if(_write(outputhandle,b,strlen(b))==-1) level=1;
- else {
- level=0;
- _write(outputhandle,"\r\n",2);
- }
- }
- b=NULL;
- break;
- case 'o': if(inputhandle!=-1) cclose(inputhandle);
- stripcr(b);
- if(*b=='@') {
- b++;
- arg=*b;
- b=variable[arg-'0'];
- }
- inputhandle=oopen(b,O_RDONLY | O_BINARY | O_DENYNONE);
- if(inputhandle==-1) level=1;
- else level=0;
- b=NULL;
- break;
- case 'r': if(inputhandle!=-1) level=(word)lseek(inputhandle,0L,SEEK_SET);
- else level=1;
- break;
- }
- break;
- }
-
- case 'I': { /* SCAN NODELIST */
-
- struct nodeidx nid;
- char temp[6];
-
- a=*b-'0';
- b++;
- if(!*b || *b=='\n') {
- say_prompt(418);
- helpnum=557;
- strcpy(temp,genin(5,0,1,0,NUM));
- helpnum=0;
- if (!atoi(temp)) {
- b=NULL;
- break;
- }
- nid.zone=(word)atol(temp);
- say_prompt(419);
- helpnum=558;
- strcpy(temp,genin(5,0,1,0,NUM));
- helpnum=0;
- if (!atoi(temp)) {
- b=NULL;
- break;
- }
- nid.net=(word)atol(temp);
- if (a) {
- say_prompt(420);
- helpnum=559;
- strcpy(temp,genin(5,0,1,0,NUM));
- helpnum=0;
- if (!atoi(temp)) {
- b=NULL;
- break;
- }
- nid.node=(word)atol(temp);
- }
- else nid.node=0;
- }
- else {
- if(*b=='@') {
- b++;
- arg=*b;
- b=variable[arg-'0'];
- }
- strcpy(c,b);
- nid.zone=(word)atol(strtok(c,":"));
- nid.net=(word)atol(strtok(0,"/"));
- nid.node=(word)atol(strtok(0,"\n"));
- }
- nid.type=255;
- if (nodelist(&nid,1)==(-1)){
- if (!a) say_prompt(421);
- b=NULL;
- break;
- }
- nid.type=0;
- if (!a) {
- lines=3;
- pauser=1;
- while(nodelist(&nid,2)>(-1)) if (toupper(inkey())=='S') break;
- pauser=tempause;
- }
- b=NULL;
- break;
- }
-
- case 'w': /* WRITE A MESSAGE */
- if(user.stat[0]<mboard.minwrite) {
- say_prompt(591);
- b=NULL;
- break;
- }
- tempsafe=safe;
- safe=0;
- a=(char)atoi(strtok(b," ,"));
- if (!a) {
- arg=(char)atoi(strtok(0," ,"));
- if (!(level=(word)askwrite(arg))) {
- if (!(level=(word)writemessage(arg))) {
- level=(word)makemessage(arg);
- }
- }
- }
- else if (a==1) {
- if (!(level=(word)askwrite(atoi(strtok(0," ,"))))) {
- writemessage((char)atoi(strtok(0," ,")));
- }
- }
- else if (a==2) {
- level=(word)askwrite(atoi(strtok(0," ,")));
- }
- else if (a==3) {
- level=(word)makemessage(atoi(strtok(0," ,")));
- }
- safe=tempsafe;
- b=NULL;
- break;
-
-
- case '*': /* Go to Bulls-mode */
- stripcr(b);
- b=strtok(b," ,");
- if(*b=='@') b=variable[b[1]-'0'];
- dobulls(b,(char)atoi(strtok(0," ,")));
- b=NULL;
- break;
-
- case '&': /* Find file/msg areas in list files */
- do_list(b);
- b=NULL;
- break;
-
- case 'A': /* Add comment from text file to log */
- addtolog(convertstring(stripcr(b)));
- b=NULL;
- break;
-
- case 'z': /* OUTPUT A QUOTE */
- do_quote(b);
- b=NULL;
- break;
-
- case '!': /* TURN ON COM WATCHDOG */
- a=atoi(b);
- b=NULL;
- if ((baud) && (a>0)) {
- update();
- fossil(WATCHDOG,1);
- say_prompt(13);
- }
- else {
- fossil(WATCHDOG,0);
- say_prompt(14);
- }
- break;
-
- case 's': /* Get msg header of a msg# */
- if(*b=='@') {
- b++;
- level=(word)atol(variable[*b-'0']);
- }
- else if(*b=='e') {
- b++;
- level=lastlevel[*b-'0'];
- }
- else level=(word)atol(b);
- level=get_mess(level);
- b=NULL;
- break;
-
- case 'C': /* Check MBoard Stats */
- a=*b;
- b++;
- if (!isdigit(a)) {
- tellabout(0);
- break;
- }
- secl=tellabout(a-'0');
- if (secl) goto seeklabel2;
- b=NULL;
- break;
-
- case 'k': /* Stuff/clear macro buffer */
- b=do_macro_buffer(b);
- break;
-
-
- case 'N': /* Msgarea readloop */
- do_readloop(b);
- b=NULL;
- break;
-
-
- case 'K': /* U/D STUFF */
- a=*b;
- b++;
- b=stripcr(b);
- switch (a) {
- case 'u': upload("",0); /* Upload any file */
- b=NULL;
- break;
- case 'V': strtok(b,",");
- cm=strtok(0,"\n");
- if(!*cm) cm="";
- upload(var_trans(b),*cm); /* Upload specific file */
- b=NULL;
- break;
- case 'v': strtok(b," ,"); /* Upload variable name */
- arg=0;
- pp=strtok(0," \n");
- if(*pp=='@'){
- p=pp[1];
- pp=variable[p-'0'];
- }
- upload(variable[(char)atoi(b)],pp[0]);
- b=NULL;
- break;
- case 'c': if(isleech(fboard.leechpercent)) {
- say_prompt(598);
- b=NULL;
- break;
- }
- case 'd': /* D/L any file */
- askdl(NULL,0,NULL,0);
- b=NULL;
- break;
- case 'C': if(isleech(fboard.leechpercent)) {
- say_prompt(598);
- b=NULL;
- break;
- }
- case 'D': /* D/L specific file */
- b=strtok(var_trans(b)," ,");
- arg=(char)atoi(strtok(0," ,"));
- askdl(b,arg,strtok(0," ,"),0);
- b=NULL;
- break;
- /* D/L variable name */
- case 'k':
- a=(char)atoi(strtok(b," ,"));
- arg=(char)atoi(strtok(0," ,"));
- cm=strtok(0," ,");
- pp=strtok(0," \n");
- if(!pp)pp="";
- if(*pp=='@'){
- p=pp[1];
- pp=variable[p-'0'];
- }
- askdl(variable[a],arg,cm,pp[0]);
- b=NULL;
- break;
- case 'K': /* Set d/l credits */
- /* for variable name */
- case 'U': arg=atoi(b); /* Add u/l credits */
- /* for variable name */
- {
- struct protocol proto;
-
- proto.key=*b;
- proto.dszlog=0;
- proto.noname=0;
- strcpy(c,variable[arg]);
- if(a=='U')getentry(c,&proto);
- else check_dls(c,&level,2);
- }
- b=NULL;
- break;
- case 'a': user.uktoday=lastlevel[*b-'0'];
- strcat(b,"\n");
- b++;
- break;
- case 'A': user.dktoday=lastlevel[*b-'0'];
- strcat(b,"\n");
- b++;
- break;
- case 'l': arg=*b-'0';
- stripcr(b++);
- if(*b=='@') b=variable[b[1]-'0'];
- if(!*b) find_filearea(say_prompt(446),"___",user.stat[arg]);
- else find_filearea(b,"___",user.stat[arg]);
- b=NULL;
- break;
- case 'n': arg=*b-'0';
- stripcr(b++);
- if(*b=='@') b=variable[b[1]-'0'];
- if(!*b) next_filearea(say_prompt(446),user.stat[arg]);
- else next_filearea(b,user.stat[arg]);
- b=NULL;
- break;
- case 'N': b=NULL;
- next_filearea(NULL,0);
- break;
- case 'm': stripcr(b);
- if(*b=='@') b=variable[b[1]-'0'];
- if(!*b) next_msgarea(say_prompt(486));
- else next_msgarea(b);
- b=NULL;
- break;
- case 'M': b=NULL;
- next_msgarea(NULL);
- break;
- }
- break;
-
- case 'G': /* Special ANSI Input */
- do_special_ANSI_input(b);
- b=NULL;
- break;
-
- case '$':
- a=*b-'0';
- b++;
- switch ((int)a) {
- case 0: strcpy(startfile,var_trans(b)); /* Reset gosub stacks and start a new file */
- stripcr(startfile);
- cclose(handle);
- return 255;
- case 1: if(safe) {
- strcpy(startfile,var_trans(b)); /* Set startfile and longjmp (restart) */
- stripcr(startfile);
- cclose(handle);
- longjmp(envbuf,99);
- }
- case 2: disablesub=(*b-'0');
- b++;
- break;
- case 3: disablejump=(*b-'0');
- b++;
- }
- break;
-
- case '|': /* Link to hypertext functions */
- b=do_hyper(b);
- break;
-
- case 'W': /* Mark/Return to a place */
- a=*b-'0';
- b++;
- arg=(char)atoi(var_trans(b));
- if (arg>9) arg=0;
- b=NULL;
- if (!a) {
- if (!markedspots[arg]) break;
- lseek(handle,markedspots[arg],SEEK_SET);
- }
- else markedspots[arg]=tell(handle);
- break;
-
- case '-': /* Adjust security levels */
- a=*b-'0';
- b++;
- secl=(word)atol(var_trans(b));
- b=NULL;
- if (a<10) user.stat[a]=secl;
- break;
-
- case '_': /* Tie-in to unused func for expansion by users */
- user_func(b);
- b=NULL;
- break;
-
- case '\\': /* Change Alternate Zone:Net/Node */
- do_alt_addr(b);
- b=NULL;
- break;
-
- case ':': /* Change message path temporarily */
- change_msgpath(b);
- b=NULL;
- break;
-
- case '': /* Turn "hot"/"cold" on/off or test cold */
- if (*b=='0') user.cold=0;
- else if (*b=='1') user.cold=1;
- else level=(word)user.cold;
- b++;
- break;
-
- case '': /* Emit if special (commodore) flag is set */
- if (!user.commodore) b=NULL;
- continue;
-
- case '': /* Emit if high ASCII can be received */
- if(!user.hiok && !user.graphics) b=NULL;
- continue;
-
- case '': /* Emit if ASCII only (no graphics at all) */
- if(user.graphics || user.hiok) b=NULL;
- continue;
-
- case '': /* Emit if user.hiok (high ASCII) is on */
- if(!user.hiok) b=NULL;
- continue;
-
- case '': /* Emit if arq flag is set */
- if(!user.arq) b=NULL;
- continue;
-
- case '': /* Emit if genx flag is set */
- if(*b=='1') if(!user.gen1) b=NULL;
- if(*b=='2') if(!user.gen2) b=NULL;
- if(*b=='3') if(!user.gen3) b=NULL;
- if(b)b++;
- continue;
-
- case '': /* Emit if expert flag is set */
- if(!user.expert) b=NULL;
- continue;
-
- case '': /* Emit if twit flag is set */
- if(!user.twit) b=NULL;
- continue;
-
- case '': /* Emit if flag a is set */
- a=(char)atoi(var_trans(b));
- pp=b;
- b=strchr(pp,',');
- if(b) {
- b++;
- if(a>0 && a<17) {
- secl=1;
- secl=secl<<(a-1);
- if(!(user.attr2 & a)) b=NULL;
- }
- }
- continue;
-
- case '': /* Put variable into input stream as text */
- strcpy(str,variable[*b-'0']);
- b=str;
- goto BreakIn;
-
-
- case '': /* Display line locally only */
- lprint(convertstring(--b));
- b=NULL;
- break;
-
- case '': /* Convert line and display */
- strncpy(str,convertstring(b),396);
- str[395]=0;
- b=str;
- break;
-
- case '': /* Set help # */
- helpnum=(word)atol(var_trans(b));
- b=NULL;
- break;
-
- case '?': /* Random branching */
- arg=(char)random(*var_trans(b)-'0');
- b++;
- strtok(b,",");
- while (arg) {
- b=strtok(0,",");
- arg--;
- }
- if(*b==',')b++;
- goto seeklabel2;
-
- case 'g': /* Assign to dlstr */
- stripcr(b);
- if(!*b) *dlstr=0;
- else {
- strncpy(dlstr,convertstring(var_trans(b)),80);
- dlstr[79]=0;
- }
- break;
-
- case '/': /* Keyqueue routines */
- a=*b;
- b++;
- if(a=='c') {
- strset(keyqueue,0);
- keyptr=0;
- }
- else {
- a-='0';
- if(!keyptr && !*keyqueue) {
- strset(variable[a],0);
- lprint("\x4 Empty\n");
- break;
- }
- arg=keyptr;
- p=0;
- while(keyqueue[arg] && arg<81) {
- variable[a][p++]=keyqueue[arg++];
- variable[a][p]=0;
- }
- if(keyptr) {
- arg=0;
- while(keyqueue[arg] && arg<keyptr && p<81) {
- variable[a][p++]=keyqueue[arg++];
- variable[a][p]=0;
- }
- }
- }
- break;
-
- case '=': /* Assign msginfo */
- stripcr(b);
- strncpy(msginfo,var_trans(b),81);
- msginfo[80]=0;
- b=NULL;
- break;
-
- case '\'': /* ANSI pull-downs */
- do_pulldowns(b,lastlevel);
- b=NULL;
- break;
-
- case '\"': /* Clear from current line to end of screen */
- a=(char)wherey();
- for(p=a;p<(user.length+1);p++) {
- if(p<24) printm("\x1b[K");
- else mprint("\x1b[K");
- if(p<23) printm("\n");
- else mprint("\x1b[K");
- }
- if(user.length<23) {
- for(p=user.length;p<24;p++) {
- lprint("\x1b[K");
- if(p<23) lprint("\n");
- }
- }
- break;
-
- case '.': /* Invoke Doors-mode */
- stripcr(b);
- if(!*b)a=3;
- else {
- a=*b-'0';
- b++;
- }
- pp=strtok(b," \n");
- if(*pp=='@') pp=variable[pp[1]-'0'];
- xdoor(pp,a);
- b=NULL;
- break;
-
- case ',': /* Invoke Files-mode */
- stripcr(b);
- if(!*b) a=2;
- else {
- a=*b-'0';
- b++;
- }
- pp=strtok(b," \n");
- if(*pp=='@') pp=variable[pp[1]-'0'];
- xfile(pp,a);
- b=NULL;
- break;
-
- case 'U': /* Update user's record in USERS.BBS, & lastread reload/save */
- a=*b;
- if(a=='1' || a=='2') {
- b++;
- if(a=='1') load_lastread();
- else save_lastread();
- }
- else {
- update();
- if(a=='0') b++;
- }
- break;
-
- case '[':
- case '{':
- case '}':
- case ']':
- case '`': do_picks(arg,b,lastlevel);
- b=NULL;
- break;
-
-
- case 'T': /* Set slow printing mode */
- a=*b;
- b++;
- if(a=='@') {
- slowprint=(char)atoi(variable[*b]);
- b++;
- }
- else if(a=='e') {
- slowprint=(char)lastlevel[*b];
- b++;
- }
- else {
- b--;
- slowprint=(char)atoi(b);
- while(*b && *b!=' ' && *b!='\n') b++;
- if(*b==' ')b++;
- }
- break;
-
- case 'V': /* Named variables */
- a=*b;
- b++;
- lstrip(b);
- stripcr(b);
- switch ((int)a) {
- case 'D': delete_var(b);
- b=NULL;
- break;
- case 'a':
- case 'A': pp=strtok(b,"=");
- cm=strtok(0,"\n");
- if(a=='A')assign_var(pp,cm);
- else assign_var(pp,convertstring(cm));
- b=NULL;
- break;
- case 'P': b=lookup_var(b);
- break;
- case 'p': b=lookup_var(b);
- strncpy(str,convertstring(b),396);
- str[395]=0;
- b=str;
- break;
- case 'S': b=lookup_var(b);
- goto BreakIn;
- case 's': b=lookup_var(b);
- strncpy(str,convertstring(b),396);
- str[395]=0;
- b=str;
- goto BreakIn;
- case 'F': free_vars();
- b=NULL;
- break;
- default: level=5; /* Syntax error */
- b-=2;
- break;
- }
- break;
-
- case '>': /* Fidonet packet export */
- cm=strtok(b,", \n");
- marea=NULL;
- if((word)atol(b)==0) {
- memcpy(&holdboard,&fboard,sizeof(struct _fboard));
- memcpy(&holdmboard,&mboard,sizeof(struct _mboard));
- load_areas(say_prompt(486));
- }
- export_mail((word)atol(b),(word)atol(cm));
- if(marea) {
- ffree(marea);
- maxareas=0;
- memcpy(&fboard,&holdboard,sizeof(struct _fboard));
- memcpy(&mboard,&holdmboard,sizeof(struct _mboard));
- }
- b=NULL;
- break;
-
- case 'O': /* Set system variables */
- setsystem(b);
- b=NULL;
- break;
-
- case 'n': /* Run a .MNU file */
- stripcr(b);
- xmenu(b);
- b=NULL;
- break;
-
- case 'm': /* Manipulate shadow user buffer */
- a=*b;
- b++;
- stripcr(b);
- level=0;
- if(a!='0' && a!='1') {
- if(!finduser(0,var_trans(b))) level=1;
- }
- else {
- if(a=='0') {
- if(!load_user((word)atol(var_trans(b)))) level=1;
- }
- else if(a=='1') {
- if(!save_user((word)atol(var_trans(b)))) level=1;
- }
- else if(a=='2') {
- save_lastread();
- }
- else if(a=='3') {
- load_lastread();
- }
- }
- b=NULL;
- break;
-
- case 'o':
- ansi_interface(b);
- b=NULL;
- break;
-
- case '\x14': /* CTRL_T, print to modem only */
- stripcr(b);
- mprint(convertstring(b));
- b=NULL;
- break;
-
- case '\x15': /* CTRL_U, bit fields in user str vars */
- a=*b;
- b++;
- arg=*b-'0';
- b++;
- if(a!='c') {
- if(*b!='e') {
- secl=(word)atol(b);
- b=strchr(b,' ');
- if(b)b++;
- }
- else {
- b++;
- secl=lastlevel[*b-'0'];
- b++;
- }
- }
- switch ((int)a) {
- case 's': BitOn(user.variable[arg],secl);
- break;
- case 'r': BitOff(user.variable[arg],secl);
- break;
- case 't': level=IsBit(user.variable[arg],secl);
- break;
- case 'c': strset(user.variable[arg],0);
- break;
- }
-
-
- errorreturn:
-
- default: printm("\x1");
- break;
- }
- }
- }
- } while (cm);
- }
- pauser=tempause;
- p=0;
- if (b!=NULL && *b) p=printm(b);
- a=toupper(inkey());
- if (*hotkeys) {
- if (a) {
- if (strchr(hotkeys,a)) {
- variable[0][0]=a;
- variable[0][1]=0;
- *hotkeys=0;
- fossil(PURGEOUT,0);
- fossil(PURGEIN,0);
- goto donereading;
- }
- }
- }
- if (safe && !disablesub && !leaving) if (*conf.subkey[0]) {
- if (a) {
- for (x=0;x<10;x++) {
- if(!*conf.subkey[x]) break;
- if(a==*conf.subkey[x]) {
- disablesub=1;
- readfile(conf.subfile[x],0,0,1);
- disablesub=0;
- break;
- }
- }
- }
- }
- if (!abort && (a == 'S' || a == ' ' || p)) {
- goto donereading;
- }
- if (!pause && (a == 'P' || a == 19)) pauseit();
- }
- while (!eof(handle));
-
- donereading:
-
- if (*hotkeys) {
- *hotkeys=0;
- *alabel=0;
- }
- if (*alabel && !eof(handle)) {
- strcpy(label,alabel);
- *alabel=0;
- goto seeklabel;
- }
- cclose(handle);
- pauser=0;
- if (stristr(filename,"GOODBYE.")!=NULL) {
- leaving=1;
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- baud=0;
- logoff();
- userno=0;
- exit(254);
- }
- if (*filetoread) {
-
- gprintf(LOCALONLY,"\nFile to read: %s\n",filetoread);
-
- imbed=1;
- strcpy(filename,filetoread);
- *filetoread=0;
- goto restart;
- }
- return 0;
-
- inputerror:
- gprintf(LOCALONLY | LOGONLY,say_prompt(15));
- goto Commonerror;
- commanderror:
- if (eof(handle)==-1) {
- cclose(handle);
- goto Commonerror;
- }
- gprintf(LOCALONLY | LOGONLY,"ERROR: EOF during command");
- Commonerror:
- if (conf.debug) {
- gprintf(LOCALONLY | LOGONLY,"%s%s (LL: %s)",say_prompt(16),filename,label);
- lprint("\n");
- }
- return 3;
- }
-