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 Door-mode module */
- /************************************************************************/
-
- #include "msg.h"
- #include "xext.h"
-
- void xdoor (char *fname,char statnum) {
-
- char filename[133];
- char string[256];
- char tempstring[48];
- register word x;
- word y;
- int handle;
- char type;
- static char name[26]=""; /* Marker--been here before? */
- word seclvl;
- char atleastone;
- char elevel;
- char *pp;
- char *p;
- char spawnme[133];
-
- if(!fname || !*fname) strcpy(filename,say_prompt(493));
- else strcpy(filename,fname);
- handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE);
- if(handle == -1) {
- say_prompt(479);
- return;
- }
-
- if(!*name)say_prompt(499);
- statnum=min(statnum,9);
-
- DoorOver:
- say_prompt(480);
- helpnum=593;
- strcpy(tempstring,genin(25,0,1,0,ALLL));
- helpnum=0;
- printm("\n");
- if(!*tempstring) {
- cclose(handle);
- return;
- }
- if(!strcmp(tempstring,"*")) {
- readfile("DOORXTRA.XBS",0,0,1);
- goto DoorOver;
- }
- if(!strcmp(tempstring,"?")) {
- x=0;
- atleastone=0;
- lines=0;
- lseek(handle,0L,SEEK_SET);
- while (!eof(handle)) {
- if (!fgetsx(string,256,handle)) break;
- if (!*string || *string=='\n' || *string=='\r' || *string==';') continue;
- stripcr(string);
- seclvl=(word)atol(strtok(string," "));
- if(seclvl > user.stat[statnum]) continue;
- p=strtok(0," ");
- if(!p) continue;
- strncpy(name,p,26);
- name[23]=0;
- while((p=strchr(name,'_'))!=NULL) *p=' ';
- atleastone=1;
- pauser=2;
- if(gprintf(0,"%-5u %s",++x,name)) break;
- strtok(0," ");
- strtok(0," ");
- p=strtok(0," \n");
- if(p) { /* Display description */
- while((pp=strchr(p,'_'))!=NULL) *pp=' ';
- if(gprintf(0,"...%s",p)) break;
- }
- pauser=1;
- if(printm("\n"))break;
- }
- pauser=0;
- if(!atleastone) {
- say_prompt(481);
- return;
- }
- goto DoorOver;
- }
- else {
- atleastone=0;
- lseek(handle,0L,SEEK_SET);
- if((word)atol(tempstring))x=(word)atol(tempstring);
- else x=0;
- y=0;
- while (!eof(handle)) {
- if (!fgetsx(string,256,handle)) break;
- if (*string=='\n' || *string=='\r' || *string==';') continue;
- stripcr(string);
- seclvl=(word)atol(strtok(string," "));
- if(seclvl>user.stat[statnum]) continue;
- p=strtok(0," ");
- if(!p) continue;
- strncpy(name,p,26);
- name[23]=0;
- while((p=strchr(name,'_'))!=NULL) *p=' ';
- if(x) {
- if(++y>x) break;
- if(y!=x) continue;
- }
- else {
- if(stricmp(name,tempstring)) continue;
- }
- p=strtok(0," ");
- if(!p) break;
- type=*p;
- if(type=='X') elevel=(char)atoi(&p[1]);
- p=strtok(0," \n"); /* String to execute */
- strncpy(spawnme,p,133);
- spawnme[132]=0;
- while((pp=strchr(spawnme,'_'))!=NULL) *pp=' ';
- if(conf.debug)gprintf(LOCALONLY,"\n\04%s\n",spawnme);
- if(!p) break;
- atleastone=1;
- }
- if(!atleastone) {
- say_prompt(10);
- goto DoorOver;
- }
- else {
- cclose(handle);
- userinfo(baud,0);
- switch((int)type) {
- case 'X': spawnit(spawnme,EXIT,elevel);
- break;
- case 'E': spawnit(spawnme,EXEC,0);
- break;
- case 'S': spawnit(spawnme,SPAWN,0);
- break;
- case 'D': spawnit(spawnme,DOS,0);
- break;
- case 's': spawnit(spawnme,SPAWNR,0);
- break;
- case 'd': spawnit(spawnme,DOSR,0);
- break;
- case 'I': spawnit(spawnme,SWAP,0);
- break;
- case 'H': spawnit(spawnme,HOT,0);
- break;
- default: break;
- }
- }
- }
- printm("\n");
- }
-