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.....Modem/local I/O */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
- #include "bios.h"
-
- char pascal specialkey (char a) { /* Special extended local keys */
-
- char tempause;
- char middle[136];
- int temp=0;
- word tempbaud;
- int handle;
-
- tempause=pauser;
- pauser=0;
-
- if ((a>58) && (a<69)) { /* F-KEY FILES */
- sprintf(middle,"%s%u%s","F",a-58,".XBS");
- if (conf.debug) {
- gprintf(LOCALONLY,"\n\x4%s\n",middle);
- }
- readfile(middle,0,0,1);
- return 0;
- }
-
- if ((a>83) && (a<113)) { /* ALT, SHIFT or CTRL F-KEY FILES */
- sprintf(middle,"%s%u%s","AF",a-83,".XBS");
- if (conf.debug) {
- gprintf(LOCALONLY,"\n\x4%s\n",middle);
- }
- readfile(middle,0,0,1);
- return 0;
- }
-
- if ((a>119) && (a<130)) { /* ALT-# SHELLS */
-
- char *p;
- char shelltype;
- char elevel;
-
- if (a==129) a=119;
- a-=119;
- strncpy(middle,say_prompt(402+a),136);
- middle[135]=0;
- stripcr(middle);
- rstrip(middle);
- if (!*middle) return 0;
- p=middle;
- p++;
- shelltype=*middle-'0';
- elevel=a+119;
- if (shelltype==EXIT) elevel=(char)atoi(p);
- adjust_time(0);
- spawnit(p,shelltype,elevel);
- adjust_time(1);
- chatted=1;
- return 0;
- }
-
- switch ((int)a) {
-
- case 48: /* QUIT */
- say_prompt(2);
- exit(254);
-
- case 131: /* MORE TIME... ALT + */
- timelimit++;
- if (conf.whichstat!=3)conf.whichstat=0;
- redraw_stat(NULL);
- return 0;
-
- case 130: /* LESS TIME... ALT - */
- if (timelimit<1) timelimit=0;
- else timelimit--;
- if (conf.whichstat!=3) conf.whichstat=0;
- redraw_stat(NULL);
- return 0;
-
- case 36: /* SysOp SHELL */
- sysop_shell();
- return 0;
-
- case 113: /* SysOp Help File */
- tempbaud=baud;
- baud=0;
- readfile("SYSHELP.XBS",1,1,1);
- baud=tempbaud;
- return 0;
-
- case 46: /* CHAT ON/OFF */
- if (!chatting) {
- chatting=1;
- temp=safe;
- safe=0;
- chat();
- safe=temp;
- }
- else chatting=0;
- redraw_stat(NULL);
- return 0;
-
- case 22: /* ALT-U...User edit window */
- edit_user(0);
- return 0;
-
- case 24: /* ALT-O...Option window */
- other_options(0);
- return 0;
-
- case 79:
- conf.whichstat++; /* Toggle status lines */
- redraw_stat(NULL);
- return 0;
-
- case 34: /* Ring a bell */
- (baud) ? mprint("\x7") : lprint("\x7");
- return 0;
-
- case 75: return 1; /* Arrow left */
- case 77: return 2; /* Arrow right */
- case 72: return 4; /* Arrow up */
- case 80: return 5; /* Arrow down */
-
- case 71:
- say_prompt(345);
- return 0;
-
- default:
- start=getxbbstime();
- pauser=tempause;
- return (a | 128);
- }
- }
-
-
-
- char pascal fossil (char function, char arg) {
- /* HANDLES MOST USEFUL FOSSIL CALLS */
-
- static char inited=0;
-
- if(!baud) if (function!=DEINIT || !inited) return 0;
-
- if (function==FLUSHOUT) {
- do {
- carrchk();
- r.x.dx=conf.commport;
- r.h.ah=3;
- int86(20,&r,&r);
- } while (!(r.h.ah & 64));
- return 0;
- }
-
- r.h.al=arg; /* Do the rest */
- r.x.dx=conf.commport;
- r.h.ah=function;
- int86(20,&r,&r);
-
- switch ((int)function) {
- case TRANSMIT: return (r.x.ax);
- case GETSTAT: arg = r.h.ah;
- if (r.h.al & 128) {
- arg |= 128;
- return (arg);
- }
- arg &= 127;
- return (arg);
- case RECVWAIT: return (r.h.al);
- case INIT: if (r.x.ax != INITOK) {
- say_prompt(17);
- exit(253);
- }
- inited=1;
- return 0;
- case DEINIT: inited=0;
- default: return 0;
- }
- }
-
-
-
- char pascal printm (char *text) { /* PRINTS TO MODEM AND SCREEN */
-
- char arg=0;
- char *p;
- char t[2];
- char tempause;
- unsigned long t1;
-
- if(!slowprint) {
- mprint(text);
- arg=lprint(text);
- if (baud) {
- carrchk();
- if (baud<=conf.purgebaud) if (text[1] && text[2]) fossil(FLUSHOUT,0);
- }
- }
- else {
- tempause=pauser;
- pauser=2;
- p=text;
- t[1]=0;
- if(baud)fossil(FLUSHOUT,0);
- while(*p) {
- *t=*p;
- mprint(t);
- lprint(t);
- inkey();
- t1=(unsigned long)biostime(0,0L)+(unsigned long)slowprint;
- while((unsigned long)biostime(0,0L)<t1 && t1<(unsigned long)biostime(0,0L)+256L) {
- if(baud)carrchk();
- }
- p++;
- }
- pauser=tempause;
- }
- return arg;
- }
-
- void pascal mprint (char *text) { /* PRINTS TO MODEM */
-
- char *text2;
-
- getxbbstime();
-
- if(!baud) return;
- if ((text==NULL) || (!*text)) return;
- text2=text;
-
- if (baud) {
- carrchk();
- while (*text2) {
- if (*text2=='\n' || *text2=='\r') {
- if (text2[1]!='\n') {
- while (!fossil(TRANSMIT,'\r')) {
- carrchk();
- }
- *text2='\n';
- }
- }
- WaitLoop:
- r.h.al=*text2; /* A little faster than calling fossil() */
- if (!user.graphics && !user.hiok) r.h.al &=127; /* No hibit for these users */
- r.x.dx=conf.commport;
- r.h.ah=TRANSMIT;
- int86(20,&r,&r);
- if (!r.x.ax) {
- carrchk();
- goto WaitLoop;
- }
- text2++;
- }
- }
- }
-
-
-
- char * pascal genin (length,password,caps,hot,type) /* GENERIC INPUT ROUTINE */
-
- char length;
- char password;
- char caps;
- char hot;
- char type;
-
- {
-
- static char geninput[257];
- char record=0;
- int x;
- register word y;
- char one;
- char beep;
- static char ansi;
- char *holdem;
- word templast;
- char pos;
-
- templast=lastprompt;
-
- ReStartIt:
-
- if(type & 128) {
- type=(type &(~128));
- record++;
- }
- x=0;
- one=beep=0;
- fossil(FLUSHOUT,0);
- if(hot==1 && user.cold && type!=YESNOM) hot=0;
- if (user.cold) fossil(PURGEIN,0);
- lines=pauser=0;
- *geninput=0;
- if (type==ANSISET) {
- ansi=length;
- level=0;
- return (geninput);
- }
- if (length) length--;
-
- if (type==PHONE && conf.genphone) type=ALPHANUM;
- if(type==PHONE) printm("(");
-
- AfterChat:
-
- start=getxbbstime();
- chatted=0;
-
- while ((getxbbstime()-start)<(conf.idleseconds+1)) {
-
- Continue:
-
- if(*keybuf && type!=YESNOM && !record) {
- one=*keybuf;
- memmove(keybuf,&keybuf[1],81);
- if(one=='|') one='\r';
- }
- else one=inkey();
-
- if(type==THRU && !one) return "";
- if(type==FORWINDOW) {
- if(!one) continue;
- else {
- geninput[x]=one;
- x++;
- geninput[x]=0;
- return geninput;
- }
- }
-
- if(one && one==conf.helpkey) { /* Help key (CTRL-T) pressed */
-
- char tempsafe;
-
- if(type==ARROWS || type==TRUEANSI || type==ANSIIN || helpnum==65535) {
- printm("\x7");
- continue;
- }
- if(type==YESNOM) {
- say_prompt(453);
- say_prompt(18);
- continue;
- }
- if(!helpnum) {
- say_prompt(467);
- sleep(1);
- say_prompt(468);
- continue;
- }
- tempsafe=safe;
- safe=0;
- say_prompt(462);
- ReHelp:
- if ((getxbbstime()-start)>(conf.idleseconds+1)) continue;
- while(!(one=toupper(inkey())) && ((getxbbstime()-start)<(conf.idleseconds+1)));
- switch ((int)one) {
- case '\r':
- case 'Y': say_prompt(463);
- if(*geninput) {
- holdem=(char *)mmalloc(strlen(geninput)+1);
- if(holdem) strcpy(holdem,geninput);
- }
- else {
- holdem=(char *)mmalloc(1);
- *holdem=0;
- }
- say_prompt(helpnum);
- safe=tempsafe;
- AfterWentAway:
- *geninput=0;
- if(holdem) {
- strcpy(geninput,holdem);
- ffree(holdem);
- x=strlen(geninput);
- if(type==PHONE) printm("(");
- for(y=0;y<x+1;y++) {
- if (type==PHONE) {
- if (y==6) printm("-");
- else if (y==3) printm(")");
- }
- if (type==DATE && (y==2 || y==4)) printm("/");
- if(y==x) break;
- if(password) gprintf(0,"%c",(char)(random(10)+33));
- else gprintf(0,"%c",geninput[y]);
- }
- one=0;
- }
- start=getxbbstime();
- lastprompt=templast;
- goto Continue;
- case 'N':
- case 27: say_prompt(463);
- break;
- default: printm("\x7");
- goto ReHelp;
- }
- safe=tempsafe;
- continue;
- }
- if (!disablesub && safe && !leaving) if (*conf.subkey[0]) {
- for (y=0;y<10;y++) {
- if(*conf.subkey[y]==0) break;
- if(one==*conf.subkey[y]) {
- disablesub=1;
- if(*geninput) {
- holdem=(char *)mmalloc(strlen(geninput)+1);
- if(holdem) strcpy(holdem,geninput);
- }
- else {
- holdem=(char *)mmalloc(1);
- *holdem=0;
- }
- readfile(conf.subfile[y],0,0,1);
- disablesub=0;
- say_prompt(423);
- goto AfterWentAway;
- }
- }
- }
- if (!one) {
- if (((getxbbstime()-start)>(conf.idleseconds-30)) && (!beep) && (!chatted)) {
- printm("\07\07");
- beep++;
- }
- continue;
- }
-
- Nogo:
-
- if (type==ARROWS) {
- switch (one) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 201:
- case 209:
- case 27:
- case 11: *geninput=one;
- return (geninput);
- case '\r': *geninput=0;
- return (geninput);
- }
- if (isprint(one)) {
- *geninput=toupper(one);
- return (geninput);
- }
- continue;
- }
- if (type==ANSIIN) {
- if (!ansi) ansi++;
- switch (one) {
- case '4':
- case 4:
- case 1: if (ansi==1) ansi=length+1;
- else ansi--;
- sprintf(geninput,"%hu",ansi);
- return (geninput);
- case '6':
- case 5:
- case 2: if (ansi==length+1) ansi=1;
- else ansi++;
- sprintf(geninput,"%hu",ansi);
- return (geninput);
- case 11: strcpy(geninput,"0");
- return (geninput);
- case '\r': sprintf(geninput,"%hu",ansi);
- level=1;
- return (geninput);
- }
- continue;
- }
- if (type==TRUEANSI) {
- switch (one) {
- case 1: sprintf(geninput,"\x1b[1D");
- return geninput;
- case 2: sprintf(geninput,"\x1b[1C");
- return geninput;
- case 4: sprintf(geninput,"\x1b[1A");
- return geninput;
- case 5: sprintf(geninput,"\x1b[1B");
- return geninput;
- case 11: strcpy(geninput,"0");
- return geninput;
- case '\r': *geninput=0;
- return geninput;
- }
- continue;
- }
-
- if (one == '\r') {
- if(type!=YESNOM && !record) {
- keyqueue[keyptr]='|';
- keyptr++;
- if(keyptr==80)keyptr=0;
- }
- break;
- }
-
- if ((one == '\b') || (one == 127)) {
- if (x) {
- if(type!=YESNOM) {
- keyptr--;
- if(!keyptr) keyptr=79;
- keyqueue[keyptr]=0;
- }
- /* memmove(&geninput[pos],geninput[pos+1],strlen(&geninput[pos+1])+1);
- x--;
- if(!user.graphics) printm(BACKSPACE);
- else {
- int xx;
-
- printm(&geninput[pos]);
- printm(" ");
- for(xx=0;xx<strlen(&geninput[pos])+1;xx++) printm("\x1b[1D");
- }
- */
- geninput[--x]=0;
- if(!user.graphics) printm(BACKSPACE);
- else {
- printm("\x1b[1D \x1b[1D");
- }
- if ((type==PHONE) && (x==2 || x==5)) printm(BACKSPACE);
- if ((type==DATE) && (x==1 || x==3)) printm(BACKSPACE);
- }
- #ifdef DEBUG
-
- printf("\x1b[s\x1b[1;1H\x1b[K%s\n\x1b[K%d\x1b[u",geninput,x);
-
- #endif
- continue;
- }
- if (caps || type==YESNO || type==YESNOM || type==YESNOQ || type==BITS) one=toupper(one);
- if (x <= length) {
- if(type==ANY || type==ANYNOECHO) goto BreakOutOfIt;
- if(type==HYPER) {
- if ((one==27 || one==11) || (user.ansimenus && one<6 && one!=3)) goto BreakOutOfIt;
- }
- if(type==BITS) {
- if(one==' ') one='-';
- if(one!='-' && one!='X') continue;
- }
- if (type==NAME) {
- if(conf.genphone && strchr("{}[]|",one)) goto SpecOK;
- if(!isalpha(one) && !strchr(" .-\'",one)) continue;
- if (!conf.genphone) {
- if (one==' ' && strchr(geninput,' ')) continue;
- }
- }
- if (type==NEAT) {
- if((!isalnum(one) && one!=' ')) continue;
- }
- SpecOK:
- if(type==NAME || type==NEAT) {
- if(!x) {
- if(one==' ') continue;
- one=toupper(one);
- }
- else {
- if(one==' ' && geninput[x-1]==' ') continue;
- if (strchr(" .-\'",geninput[x-1])) one=toupper(one);
- else one=tolower(one);
- }
- }
- if (type==WORD && !isalpha(one)) continue;
- if (type==WORDNUM && !isalnum(one)) continue;
- if (type==SUBJECT && !x) one=toupper(one);
- if ((type==ALLL || type==SUBJECT) && !isprint(one)) continue;
- if (type==ALPHA && !isalpha(one) && one!=' ') continue;
- if ((type==NUM || type==PHONE || type==DATE) && !isdigit(one)) continue;
- if (type==ALPHANUM && !isalnum(one) && one!=' ') continue;
- if ((type==YESNO || type==YESNOM) && (one!='Y' && one!='N')) continue;
- if (type==YESNOQ && !strchr("YNQ",one)) continue;
- if (type==FLE) {
- if (!isalnum(one) && !strchr("._-+=!@#$%^&<>{}[]",one)) continue;
- }
- if (type==FBATCH) {
- if (!isalnum(one) && !strchr(" ._-+=!@#$%^&<>{}[]",one)) continue;
- }
- if (type==FBATCHW) {
- if (!isalnum(one) && !strchr(" ._-+=!@#$%^&<>?*{}[]",one)) continue;
- }
- if (type==FBATCHWP) {
- if (!isalnum(one) && !strchr(" ._-+=!@#$%^&<>?*\\{}[]",one)) continue;
- }
- if (type==FBATCHP) {
- if (!isalnum(one) && !strchr(" ._-+=!@#$%^&<>\\{}[]",one)) continue;
- }
- if (type==FLEX) {
- if (!isalnum(one) && !strchr("_-+=!@#$%^&<>{}[]",one)) continue;
- }
- if (type==FLEP) {
- if (!isalnum(one) && !strchr("._-+=!@#$%^&<>\\:{}[]",one)) continue;
- }
- if (type==FLEW) {
- if (!isalnum(one) && !strchr("._-+=!@#$%^&<>?*{}[]",one)) continue;
- }
- if (type==FLEPW) {
- if (!isalnum(one) && !strchr("._-+=!@#$%^&<>?*\\:{}[]",one)) continue;
- }
- if ((type==FLE) || (type==FLEP) || (type==FLEW) || (type==FLEPW)) {
- if (one=='.') {
- if(strchr(geninput,'.')) continue;
- }
- }
- BreakOutOfIt:
- ;
- }
- if (one && x <= length) {
- if(type!=YESNOM && one && !record) {
- keyqueue[keyptr]=one;
- keyptr++;
- if(keyptr==80)keyptr=0;
- }
- geninput[x]=one;
- x++;
- geninput[x]=0; /* Gotta change for ANSI users... */
-
- #ifdef DEBUG
-
- printf("\x1b[s\x1b[1;1H\x1b[K%s\n\x1b[K%d\x1b[u",geninput,x);
-
- #endif
-
- if (type==THRU || type==YESNOM || type==HYPER) return(geninput);
- if (!password) {
- if(type!=ANYNOECHO) gprintf(0,"%c",geninput[x-1]);
- }
- else if (type!=ANYNOECHO) {
- gprintf(0,"%c",(char)(random(10)+33));
- }
- /* if(!user.graphics) { */
- if (type==PHONE) {
- if (x==6) printm("-");
- else if (x==3) printm(")");
- }
- if (type==DATE && (x==2 || x==4)) printm("/");
- /* } */
- if (hot && x >= length) return (geninput);
- start=getxbbstime();
- }
- }
- if (((getxbbstime()-start)>conf.idleseconds) && !chatted && !timer_off) {
- say_prompt(192);
- user.violations++;
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- logoff();
- baud=0;
- userno=0;
- exit(254);
- }
- if (chatted) {
- chatted=0;
- if (one!='\r') goto AfterChat;
- }
- return (geninput);
- }
-
-
-
- char pascal specialmod (void) {
-
- char arg;
- int register x;
-
- for (x=0;x<256;x++) {
- arg=carrchk();
- if (arg & 1) break;
- }
- if (!(arg & 1)) return 0;
- arg=(fossil(RECVWAIT,arg));
- if (arg!='[') return 27;
- for (x=0;x<256;x++) {
- arg=carrchk();
- if (arg & 1) break;
- }
- if (!(arg & 1)) return 27;
- arg=(fossil(RECVWAIT,arg));
- if ((arg!='1') && (arg!='C') && (arg!='D') && (arg!='A') && (arg!='B')) return 27;
- if (arg=='C') return 2;
- if (arg=='D') return 1;
- if (arg=='A') return 4;
- if (arg=='B') return 5;
- for (x=0;x<256;x++) {
- arg=carrchk();
- if (arg & 1) break;
- }
- if (!(arg & 1)) return 27;
- arg=(fossil(RECVWAIT,arg));
- if ((arg!='C') && (arg!='D') && (arg!='A') && (arg!='B')) return 27;
- if (arg=='C') return 2;
- if (arg=='D') return 1;
- if (arg=='A') return 4;
- if (arg=='B') return 5;
-
- return 27;
- }
-
-
- void pascal sysop_shell (void) {
-
- int drive;
- char dir[MAXDIR];
- char middle[133];
-
- if (readfile("jumpout.xbs",0,0,1)==2) say_prompt(3);
- fossil(FLUSHOUT,0);
- drive=getdisk();
- getcurdir(++drive,dir);
- fossil(DEINIT,0);
- adjust_time(0);
- say_prompt(4);
- fputs("\x1b[2J",stdout);
- if (conf.swap) {
-
- char *p;
- char *pp;
-
- p=getenv("COMSPEC");
- if (!p) pp=searchpath("COMMAND.COM");
- else pp=searchpath(p);
- if (doswap(pp,"")==(-1)) system("");
- }
- else system("");
- adjust_time(1);
- fossil(INIT,0);
- setdisk (--drive);
- strcpy(middle,"\\");
- strcat(middle,dir);
- chdir(middle);
- chatted=1;
- fputs("\x1b[2J",stdout);
- redraw_stat(NULL);
- if(readfile("jumpback.xbs",0,0,1)==2) say_prompt(5);
- }
-