home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XDOOR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  7.2 KB  |  182 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31. /************************************************************************/
  32. /* XBBS Door-mode module                                                */
  33. /************************************************************************/
  34.  
  35. #include "msg.h"
  36. #include "xext.h"
  37.  
  38. void xdoor (char *fname,char statnum) {
  39.  
  40.    char filename[133];
  41.    char string[256];
  42.    char tempstring[48];
  43.    register word x;
  44.    word y;
  45.    int  handle;
  46.    char type;
  47.    static char name[26]="";     /* Marker--been here before? */
  48.    word seclvl;
  49.    char atleastone;
  50.    char elevel;
  51.    char *pp;
  52.    char *p;
  53.    char spawnme[133];
  54.  
  55.    if(!fname || !*fname) strcpy(filename,say_prompt(493));
  56.    else strcpy(filename,fname);
  57.    handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE);
  58.    if(handle == -1) {
  59.        say_prompt(479);
  60.        return;
  61.    }
  62.  
  63.    if(!*name)say_prompt(499);
  64.    statnum=min(statnum,9);
  65.  
  66. DoorOver:
  67.       say_prompt(480);
  68.       helpnum=593;
  69.       strcpy(tempstring,genin(25,0,1,0,ALLL));
  70.       helpnum=0;
  71.       printm("\n");
  72.       if(!*tempstring) {
  73.           cclose(handle);
  74.           return;
  75.       }
  76.       if(!strcmp(tempstring,"*")) {
  77.             readfile("DOORXTRA.XBS",0,0,1);
  78.             goto DoorOver;
  79.       }
  80.       if(!strcmp(tempstring,"?")) {
  81.            x=0;
  82.            atleastone=0;
  83.            lines=0;
  84.            lseek(handle,0L,SEEK_SET);
  85.            while (!eof(handle)) {
  86.              if (!fgetsx(string,256,handle)) break;
  87.              if (!*string || *string=='\n' || *string=='\r' || *string==';') continue;
  88.              stripcr(string);
  89.              seclvl=(word)atol(strtok(string," "));
  90.              if(seclvl > user.stat[statnum]) continue;
  91.              p=strtok(0," ");
  92.              if(!p) continue;
  93.              strncpy(name,p,26);
  94.              name[23]=0;
  95.              while((p=strchr(name,'_'))!=NULL) *p=' ';
  96.              atleastone=1;
  97.              pauser=2;
  98.              if(gprintf(0,"%-5u  %s",++x,name)) break;
  99.              strtok(0," ");
  100.              strtok(0," ");
  101.              p=strtok(0," \n");
  102.              if(p) {    /* Display description */
  103.                 while((pp=strchr(p,'_'))!=NULL) *pp=' ';
  104.                 if(gprintf(0,"...%s",p)) break;
  105.              }
  106.              pauser=1;
  107.              if(printm("\n"))break;
  108.           }
  109.           pauser=0;
  110.           if(!atleastone) {
  111.             say_prompt(481);
  112.             return;
  113.           }
  114.           goto DoorOver;
  115.       }
  116.       else {
  117.           atleastone=0;
  118.           lseek(handle,0L,SEEK_SET);
  119.           if((word)atol(tempstring))x=(word)atol(tempstring);
  120.           else x=0;
  121.           y=0;
  122.           while (!eof(handle)) {
  123.                 if (!fgetsx(string,256,handle)) break;
  124.                 if (*string=='\n' || *string=='\r' || *string==';') continue;
  125.                 stripcr(string);
  126.                 seclvl=(word)atol(strtok(string," "));
  127.                 if(seclvl>user.stat[statnum]) continue;
  128.                 p=strtok(0," ");
  129.                 if(!p) continue;
  130.                 strncpy(name,p,26);
  131.                 name[23]=0;
  132.                 while((p=strchr(name,'_'))!=NULL) *p=' ';
  133.                 if(x) {
  134.                     if(++y>x) break;
  135.                     if(y!=x) continue;
  136.                 }
  137.                 else {
  138.                     if(stricmp(name,tempstring)) continue;
  139.                 }
  140.                 p=strtok(0," ");
  141.                 if(!p) break;
  142.                 type=*p;
  143.                 if(type=='X') elevel=(char)atoi(&p[1]);
  144.                 p=strtok(0," \n"); /* String to execute */
  145.                 strncpy(spawnme,p,133);
  146.                 spawnme[132]=0;
  147.                 while((pp=strchr(spawnme,'_'))!=NULL) *pp=' ';
  148.                 if(conf.debug)gprintf(LOCALONLY,"\n\04%s\n",spawnme);
  149.                 if(!p) break;
  150.                 atleastone=1;
  151.           }
  152.           if(!atleastone) {
  153.                 say_prompt(10);
  154.                 goto DoorOver;
  155.           }
  156.           else {
  157.                 cclose(handle);
  158.                 userinfo(baud,0);
  159.                 switch((int)type) {
  160.                     case 'X':  spawnit(spawnme,EXIT,elevel);
  161.                                break;
  162.                     case 'E':  spawnit(spawnme,EXEC,0);
  163.                                break;
  164.                     case 'S':  spawnit(spawnme,SPAWN,0);
  165.                                break;
  166.                     case 'D':  spawnit(spawnme,DOS,0);
  167.                                break;
  168.                     case 's':  spawnit(spawnme,SPAWNR,0);
  169.                                break;
  170.                     case 'd':  spawnit(spawnme,DOSR,0);
  171.                                break;
  172.                     case 'I':  spawnit(spawnme,SWAP,0);
  173.                                break;
  174.                     case 'H':  spawnit(spawnme,HOT,0);
  175.                                break;
  176.                     default:   break;
  177.                 }
  178.           }
  179.       }
  180.       printm("\n");
  181. }
  182.