home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XMENU2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-20  |  15.7 KB  |  354 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. #include "msg.h"
  33. #include "xext.h"
  34.  
  35.  
  36.     struct _menu {
  37.         char prompt[81];
  38.         char key;
  39.         char action;
  40.         char data[133];
  41.         char color;
  42.     };
  43.  
  44. void pascal xmenu (char *menuname);
  45.  
  46.  
  47.  
  48. char pascal do_item (struct _menu **m,char which) {
  49.  
  50.     register int x;
  51.     char s[133],s1[133];
  52.     char *p,*pp;
  53.     struct ffblk f;
  54.  
  55.     switch ((int)m[which]->action) {
  56.         case 255:   break;              /* Quit menu (also return from a gosub) */
  57.         case 0:     break;              /* NOOP */
  58.         case 1:     break;              /* Goto, handled in xmenu() */
  59.         case 2:     xmenu(m[which]->data);  /* Gosub */
  60.                     break;
  61.         case 3:     readfile(m[which]->data,1,1,1); /* Read menu file */
  62.                     break;                      /* The most powerful action */
  63.         case 4:     readtext(m[which]->data);       /* Read text file */
  64.                     break;
  65.         case 5:     password();
  66.                     break;
  67.         case 6:     handler();
  68.                     break;
  69.         case 7:     say_prompt(240);
  70.                     city();
  71.                     break;
  72.         case 8:     say_prompt(241);
  73.                     state();
  74.                     break;
  75.         case 9:     say_prompt(244);
  76.                     phone1();
  77.                     break;
  78.         case 10:    say_prompt(245);
  79.                     phone2();
  80.                     break;
  81.         case 11:    say_prompt(242);
  82.                     zip();
  83.                     break;
  84.         case 12:    say_prompt(246);
  85.                     length();
  86.                     break;
  87.         case 13:    say_prompt(247);
  88.                     width();
  89.                     break;
  90.         case 14:    comptype();
  91.                     break;
  92.         case 15:    logoff();           /* Log user off */
  93.                     fossil(DTR,DOWN);
  94.                     baud=0;
  95.                     exit(253);
  96.         case 16:    strcpy(s,m[which]->data);   /* Raw directory--data="path type" */
  97.                     p=strtok(s," ");
  98.                     rawdir(p,(char)atoi(strtok(0,"\n")));
  99.                     break;
  100.         case 17:    strcpy(s,m[which]->data);   /* Bulls-mode--data="filename type" */
  101.                     p=strtok(s," ");
  102.                     dobulls(p,(char)atoi(strtok(0,"\n")));
  103.                     break;
  104.         case 18:    strcpy(s,m[which]->data);   /* Files-mode--data="filename statnum" */
  105.                     p=strtok(s," ");
  106.                     xfile(p,(char)atoi(strtok(0,"\n")));
  107.                     break;
  108.         case 19:    strcpy(s,m[which]->data);   /* Doors-mode--data="filename statnum" */
  109.                     p=strtok(s," ");
  110.                     xdoor(p,(char)atoi(strtok(0,"\n")));
  111.                     break;
  112.         case 20:    strcpy(s,m[which]->data);   /* Look up named help--data="filename helptopic" */
  113.                     p=strtok(s," ");
  114.                     find_help(p,strtok(0,"\n"),0);
  115.                     break;
  116.         case 21:    strncpy(startfile,m[which]->data,13);   /* Restart XBBS--data="textfilename" */
  117.                     startfile[12]=0;
  118.                     longjmp(envbuf,99);
  119.                     break;
  120.         case 22:                                /* Read any files */
  121.                     strcpy(s,m[which]->data);
  122.                     p=strtok(s," ");
  123.                     pp=strtok(0," ");
  124.                     readany(p,pp,(char)atoi(strtok(0,"\n")));
  125.                     break;
  126.         case 23:                                /* Read all new files */
  127.                     strcpy(s,m[which]->data);
  128.                     p=strtok(s," ");
  129.                     readnew(p,(char)atoi(strtok(0,"\n")));
  130.                     break;
  131.         case 24:                                /* Read messages */
  132.                     readamessage((char)atoi(m[which]->data),0);
  133.                     break;
  134.         case 25:                                /* Write message */
  135.                     if (!askwrite((char)atoi(m[which]->data))) {
  136.                       if (!writemessage((char)atoi(m[which]->data))) {
  137.                           makemessage((char)atoi(m[which]->data));
  138.                       }
  139.                     }
  140.                     break;
  141.         case 26:                                /* List FILES.BBS */
  142.                     strcpy(s,m[which]->data);
  143.                     p=strtok(s," ");
  144.                     x=atoi(strtok(0," "));
  145.                     pp=strtok(0," ");
  146.                     filesbbs(p,(char)x,pp,strtok(0,"\n"));
  147.                     break;
  148.         case 27:                                /* Upload */
  149.                     if(!stricmp(fboard.upath,"NUL") || !stricmp(fboard.upath,"NUL\\")) {
  150.                         say_prompt(451);
  151.                         break;
  152.                     }
  153.                     strcpy(s,m[which]->data);
  154.                     upload(s,0);
  155.                     break;
  156.         case 28:                                /* Download */
  157.                     if(isleech(fboard.leechpercent)) {
  158.                         say_prompt(598);
  159.                         break;
  160.                     }
  161.                     strcpy(s,m[which]->data);
  162.                     p=strtok(s," ");
  163.                     x=atoi(strtok(0," "));
  164.                     askdl(p,(char)x,strtok(0,"\n"),0);
  165.                     break;
  166.         case 29:                                /* Export FTN packet */
  167.                     strcpy(s,m[which]->data);
  168.                     x=atoi(strtok(s," "));
  169.                     export_mail((char)x,(char)atoi(strtok(0,"\n")));
  170.                     break;
  171.         case 30:                                /* Read all areas */
  172.                     strcpy(s,m[which]->data);
  173.                     p=strtok(s," ");
  174.                     x=atoi(strtok(0," "));
  175.                     pp=strtok(0," ");
  176.                     do_all_msg_areas(p,(char)x,(char)atoi(pp),(char)atoi(strtok(0,"\n")),0);
  177.                     break;
  178.         case 31:                                /* Hypertext */
  179.                     strcpy(s,m[which]->data);
  180.                     p=strtok(s," ");
  181.                     load_topics(p);
  182.                     pp=strtok(0," ");
  183.                     set_topic(pp);
  184.                     x=atoi(strtok(0,"\n"));
  185.                     if(x<0 || x>9)x=0;
  186.                     display_topic(user.stat[x],&pp);
  187.                     break;
  188.         case 32:    user.graphics=1-user.graphics;
  189.                     break;
  190.         case 33:    user.hiok=1-user.hiok;
  191.                     break;
  192.         case 34:    user.scrnclr=1-user.scrnclr;
  193.                     break;
  194.         case 35:    user.more=1-user.more;
  195.                     break;
  196.         case 36:    user.commodore=1-user.commodore;
  197.                     break;
  198.         case 37:    user.fullscreen=1-user.fullscreen;
  199.                     break;
  200.         case 38:                    /* Change msg area--data same as for @M */
  201.                     strcpy(s,m[which]->data);
  202.                     strncpy(mboard.name,strtok(s,","),48);
  203.                     mboard.name[47]=0;
  204.                     mboard.attr=(word)atoi(strtok(0," ,"));
  205.                     mboard.max=(word)atoi(strtok(0," ,"));
  206.                     mboard.number=(word)atoi(strtok(0," ,"));
  207.                     mboard.substat1=(word)atoi(strtok(0," ,"));
  208.                     mboard.substat2=(word)atoi(strtok(0," ,"));
  209.                     p=strtok(0,",");
  210.                     if(p!=NULL)strncpy(mboard.forceto,p,36);
  211.                     else *mboard.forceto=0;
  212.                     mboard.forceto[35]=0;
  213.                     mboard.age=0;
  214.                     mboard.flags=0;
  215.                     p=strtok(0,",");
  216.                     if(p!=NULL) mboard.minwrite=(word)atol(p);
  217.                     else mboard.minwrite=0;
  218.                     break;
  219.         case 39:                    /* Change file area--data same as for @F */
  220.                     strcpy(s,m[which]->data);
  221.                     strncpy(fboard.name,strtok(s,","),48);
  222.                     fboard.name[46]=0;
  223.                     strncpy(fboard.dpath,strtok(0," ,"),81);
  224.                     fboard.dpath[80]=0;
  225.                     strncpy(fboard.upath,strtok(0," ,"),81);
  226.                     fboard.upath[80]=0;
  227.                     fboard.flags=(char)atoi(strtok(0," ,"));
  228.                     fboard.age=0;
  229.                     fboard.userflags=0;
  230.                     p=strtok(0," ,");
  231.                     if(p) fboard.leechpercent=(char)atoi(p);
  232.                     else fboard.leechpercent=0;
  233.                     break;
  234.         case 40:                    /* List msg areas */
  235.                     if(!*m[which]->data) find_msgarea(say_prompt(486),"",2);
  236.                     else find_msgarea(m[which]->data,"",2);
  237.                     break;
  238.         case 41:                    /* List file areas */
  239.                     find_filearea(say_prompt(446),"___",user.stat[(char)atoi(m[which]->data)]);
  240.                     break;
  241.          case 42:                    /* Select msg area by name */
  242. MsgList:
  243.                    say_prompt(599);  /* Change current msg area */
  244.                    helpnum=0;
  245.                    strcpy(s,genin(48,0,1,0,ALLL));
  246.                    printm("\n");
  247.                    if(*s=='?') {
  248.                      sprintf(s,"%sBULLS\\BOARDLST.XBS",conf.menupath);
  249.                      if(findfirst(s,&f,0)) {
  250.                         if(!*m[which]->data) find_msgarea(say_prompt(486),"",2);
  251.                         else find_msgarea(m[which]->data,"",2);
  252.                      }
  253.                      else readfile(s,1,1,1);
  254.                      goto MsgList;
  255.                    }
  256.                    if(*s) {
  257.                        if(atol(s)) {
  258.                             if(!*m[which]->data) find_msgarea(say_prompt(486),s,1);
  259.                             else find_msgarea(m[which]->data,s,1);
  260.                        }
  261.                        else {
  262.                             if(!*m[which]->data) find_msgarea(say_prompt(486),s,0);
  263.                             else find_msgarea(m[which]->data,s,0);
  264.                        }
  265.                    }
  266.                    break;
  267.         case 43:                    /* Select file area by name */
  268. FileList:
  269.                    gprintf(0,say_prompt(490),fboard.name);
  270.                    say_prompt(449);  /* Change current file area */
  271.                    helpnum=592;
  272.                    strcpy(s,genin(48,0,1,0,ALLL));
  273.                    helpnum=0;
  274.                    printm("\n");
  275.                    if(*s=='?') {
  276.                      sprintf(s,"%sAREALIST.XBS",conf.menupath);
  277.                      if(findfirst(s,&f,0)) {
  278.                         find_filearea(say_prompt(446),"___",user.stat[(char)atoi(m[which]->data)]);
  279.                      }
  280.                      else readfile(s,1,1,1);
  281.                      goto FileList;
  282.                    }
  283.                    if(*s) {
  284.                        if(atol(s)) {
  285.                          strcpy(s1,"#");
  286.                          strcat(s1,s);
  287.                        }
  288.                        else strcpy(s1,s);
  289.                        if(!find_filearea(say_prompt(446),s,user.stat[(char)atoi(m[which]->data)])) {
  290.                              say_prompt(450);
  291.                        }
  292.                    }
  293.                    break;
  294.         case 44:    if (pages>conf.pages) {     /* Request chat */
  295.                          readfile("getlost.xbs",0,0,1);
  296.                          pages++;
  297.                          break;
  298.                     }
  299.                     addtolog("Requested chat.");
  300.                     if (conf.sysopin) readfile("chat.xbs",0,0,1);
  301.                     else readfile("nochat.xbs",0,0,1);
  302.                     pages++;
  303.                     break;
  304.         case 45:    user.twit=1-user.twit;      /* Toggle twit bit */
  305.                     break;
  306.         case 46:    user.expert=1-user.expert;  /* Toggle expert bit */
  307.                     break;
  308.         case 47:    save_lastread();    /* Reload lastread pointers */
  309.                     break;
  310.         case 48:    load_lastread();    /* Save lastread pointers */
  311.                     break;
  312.         case 49:    userlist(0);    /* List users by handles */
  313.                     break;
  314.         case 50:    userlist(1);    /* List users by real names */
  315.                     break;
  316.         case 51:    strncpy(menufile,m[which]->data,81);   /* Restart XBBS--data="menufilename" */
  317.                     menufile[80]=0;
  318.                     longjmp(envbuf,98);
  319.                     break;
  320.         case 52:    strcpy(s,m[which]->data);   /* Output a quote */
  321.                     x=atoi(s);
  322.                     strtok(s," ,");
  323.                     p=strtok(0," ,");
  324.                     stripcr(p);
  325.                     spit((char)x,p);
  326.                     break;
  327.  
  328.     /* Run external programs */
  329.         case 201:
  330.         case 202:
  331.         case 203:
  332.         case 204:
  333.         case 205:
  334.         case 206:   userinfo(0,0);
  335.         case 207:
  336.         case 208:
  337.                     strcpy(s,m[which]->data);
  338.                     x=(int)m[which]->action;
  339.                     if(x==208) spawnit("",4,(char)atoi(s));
  340.                     else if(x==201) spawnit(s,0,0);
  341.                     else if(x==202) spawnit(s,7,0);
  342.                     else if(x==203) spawnit(s,6,0);
  343.                     else if(x==204) spawnit(s,8,0);
  344.                     else if(x==205) spawnit(s,9,0);
  345.                     else if(x==206) spawnit(s,3,0);
  346.                     else if(x==207) spawnit(s,1,0);
  347.                     break;
  348.  
  349.         default:    gprintf(LOCALONLY,"\n\04Unsupported menu action %hu\n",m[which]->action);
  350.                     break;
  351.     }
  352.     return m[which]->action;
  353. }
  354.