home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / HELP.C < prev    next >
C/C++ Source or Header  |  2000-07-13  |  10KB  |  274 lines

  1. /******************************************************************************
  2. HELP.C       HELP command processor.
  3.  
  4.     Copyright 1993 - 2000 Paul J. Sidorsky
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License, version 2, as
  8.     published by the Free Software Foundation.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19. Processes the HELP command to display help files.
  20. ******************************************************************************/
  21. #include "top.h"
  22.  
  23. /* help_proc() - Process the HELP command.
  24.    Parameters:  helpwds - Number of words in the command string.
  25.    Returns:  Nothing.
  26. */
  27. void help_proc(XINT helpwds)
  28.     { // Will need to change the order to the order proc'd later.
  29.     char hused = 0; /* Flag if a help file has been shown or not. */
  30.     unsigned char *helpfile = NULL; /* Name of help file to show. */
  31.  
  32.     /* In this function, basically every command is checked to see if it
  33.        follows the HELP command.  If a match is found, the name of the
  34.        file to show is set, as is a flag. */
  35.  
  36.     /* Due to the simplicity of this function, comments have been kept
  37.        to a minimum. */
  38.  
  39.     /* Regular commands. */
  40.     if (!hused && (helpwds < 2 ||
  41.                    checkcmdmatch(get_word(1), getlang("CmdsHelp"))))
  42.         {
  43.         hused = 1;
  44.         helpfile = "HELP_HLP";
  45.         }
  46.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsQuit")))
  47.         {
  48.         hused = 1;
  49.         helpfile = "HELPQUIT";
  50.         }
  51.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsCommands")))
  52.         {
  53.         hused = 1;
  54.         helpfile = "HELPCMDS";
  55.         }
  56.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsColourHelp")))
  57.         {
  58.         hused = 1;
  59.         helpfile = "HELPCHLP";
  60.         }
  61.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsTime")))
  62.         {
  63.         hused = 1;
  64.         helpfile = "HELPTIME";
  65.         }
  66.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsWho")))
  67.         {
  68.         hused = 1;
  69.         helpfile = "HELP_WHO";
  70.         }
  71.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsProfile")))
  72.         {
  73.         hused = 1;
  74.         helpfile = "HELPPROF";
  75.         }
  76.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsLookUp")))
  77.         {
  78.         hused = 1;
  79.         helpfile = "HELPLKUP";
  80.         }
  81.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsNodes")))
  82.         {
  83.         hused = 1;
  84.         helpfile = "HELPNODS";
  85.         }
  86.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPage")))
  87.         {
  88.         hused = 1;
  89.         helpfile = "HELPPAGE";
  90.         }
  91.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsForget")))
  92.         {
  93.         hused = 1;
  94.         helpfile = "HELP_FGT";
  95.         }
  96.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsRemember")))
  97.         {
  98.         hused = 1;
  99.         helpfile = "HELPRMBR";
  100.         } // May need slight mods below
  101.     /* Whispers have two command forms; each is checked. */
  102.     if (!hused && (checkcmdmatch(get_word(1), getlang("CmdsWhisperLong1")) ||
  103.                    checkcmdmatch(get_word(1), getlang("WhisperShortChar"))))
  104.         {
  105.         hused = 1;
  106.         helpfile = "HELPWHIS";
  107.         }
  108.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsGA")))
  109.         {
  110.         hused = 1;
  111.         helpfile = "HELP_GA1";
  112.         }
  113.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsGA2")))
  114.         {
  115.         hused = 1;
  116.         helpfile = "HELP_GA2";
  117.         } // May need slight mods below
  118.     /* Directed messages have two command forms; each is checked. */
  119.     if (!hused && (checkcmdmatch(get_word(1), getlang("CmdsDirectedLong1")) ||
  120.                    checkcmdmatch(get_word(1), getlang("DirectedShortChar"))))
  121.         {
  122.         hused = 1;
  123.         helpfile = "HELP_DIR";
  124.         }
  125.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsJoin")))
  126.         {
  127.         hused = 1;
  128.         helpfile = "HELPJOIN";
  129.         }
  130.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPrivChat")))
  131.         {
  132.         hused = 1;
  133.         helpfile = "HELPCHAT";
  134.         }
  135.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPrivDenyChat")))
  136.         {
  137.         hused = 1;
  138.         helpfile = "HELPDENY";
  139.         }
  140.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsLogOff")))
  141.         {
  142.         hused = 1;
  143.         helpfile = "HELPLGOF";
  144.         }
  145.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsConfList")))
  146.         {
  147.         hused = 1;
  148.         helpfile = "HELPCLST";
  149.         }
  150.  
  151.     /* Multi-part commands.  If a valid secondary command is recognized
  152.        then its specific help file will be shown, otherwise a general help
  153.        file for the multi-part command will be shown. */
  154.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsAction")))
  155.         {
  156.         hused = 1;
  157.         helpfile = "HELPACT0";
  158.         if (helpwds >= 2)
  159.             {
  160.             if (checkcmdmatch(get_word(2), getlang("CmdsActionList")))
  161.                 helpfile = "HELPACT1";
  162.             if (checkcmdmatch(get_word(2), getlang("CmdsActionOn")))
  163.                 helpfile = "HELPACT2";
  164.             if (checkcmdmatch(get_word(2), getlang("CmdsActionOff")))
  165.                 helpfile = "HELPACT3";
  166.             }
  167.         }
  168.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsChange")))
  169.         {
  170.         hused = 1;
  171.         helpfile = "HELPCHG0";
  172.         if (helpwds >= 2)
  173.             {
  174.             if (checkcmdmatch(get_word(2), getlang("CmdsChangeHandle")))
  175.                 helpfile = "HELPCHG1";
  176.             if (checkcmdmatch(get_word(2), getlang("CmdsChangeEMessage")))
  177.                 helpfile = "HELPCHG2";
  178.             if (checkcmdmatch(get_word(2), getlang("CmdsChangeXMessage")))
  179.                 helpfile = "HELPCHG3";
  180.             if (checkcmdmatch(get_word(2), getlang("CmdsChangeSex")))
  181.                 helpfile = "HELPCHG4";
  182.             if (checkcmdmatch(get_word(2), getlang("CmdsChangeChatMode")))
  183.                 helpfile = "HELPCHG5";
  184.             if (checkcmdmatch(get_word(2), getlang("CmdsChangeListed")))
  185.                 helpfile = "HELPCHG6";
  186.             }
  187.         }
  188.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsSysop")))
  189.         {
  190.         hused = 1;
  191.         helpfile = "HELPSYS0";
  192.         if (helpwds >= 2)
  193.             {
  194.             if (checkcmdmatch(get_word(2), getlang("CmdsSysopClear")))
  195.                 helpfile = "HELPSYS1";
  196.             if (checkcmdmatch(get_word(2), getlang("CmdsSysopToss")))
  197.                 helpfile = "HELPSYS2";
  198.             if (checkcmdmatch(get_word(2), getlang("CmdsSysopZap")))
  199.                 helpfile = "HELPSYS3";
  200.             if (checkcmdmatch(get_word(2), getlang("CmdsSysopSetSec")))
  201.                 helpfile = "HELPSYS4";
  202.             }
  203.         }
  204.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsModerator")))
  205.         {
  206.         hused = 1;
  207.         helpfile = "HELPMOD0";
  208.         if (helpwds >= 2)
  209.             {
  210.             if (checkcmdmatch(get_word(2), getlang("CmdsModTopicChg")))
  211.                 helpfile = "HELPMOD1";
  212.             if (checkcmdmatch(get_word(2), getlang("CmdsModModChg")))
  213.                 helpfile = "HELPMOD2";
  214.             if (checkcmdmatch(get_word(2), getlang("CmdsModBan")))
  215.                 helpfile = "HELPMOD3";
  216.             if (checkcmdmatch(get_word(2), getlang("CmdsModUnBan")))
  217.                 helpfile = "HELPMOD4";
  218.             if (checkcmdmatch(get_word(2), getlang("CmdsModInvite")))
  219.                 helpfile = "HELPMOD5";
  220.             if (checkcmdmatch(get_word(2), getlang("CmdsModUnInvite")))
  221.                 helpfile = "HELPMOD6";
  222.             }
  223.         }
  224.  
  225.     /* Non-command help topics. */
  226.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpTopics")))
  227.         {
  228.         hused = 1;
  229.         helpfile = "HELP_TOP";
  230.         }
  231.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpGeneral")))
  232.         {
  233.         hused = 1;
  234.         helpfile = "HELP_GEN";
  235.         }
  236.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpActions")))
  237.         {
  238.         hused = 1;
  239.         helpfile = "HELPACTS";
  240.         }
  241.     if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpChannels")))
  242.         {
  243.         hused = 1;
  244.         helpfile = "HELPCHAN";
  245.         }
  246.  
  247.     if (hused)
  248.         {
  249.         /* Show the help file if one was set. */
  250.         show_helpfile(helpfile);
  251.         }
  252.     else
  253.         {
  254.         /* Unknown command. */
  255.         top_output(OUT_SCREEN, getlang("NoHelpAvailable"));
  256.         }
  257.  
  258.     }
  259.  
  260. /* show_helpfile() - Displays a help file to the screen.
  261.    Parameters:  hlpname - Base name of the help file to show.
  262.    Returns:  Nothing.
  263.    Notes:  This function is really just a wrapper for show_file() that
  264.            adds in the help prefix and suffix as well.
  265. */
  266. void show_helpfile(unsigned char *hlpname)
  267.     {
  268.  
  269.     top_output(OUT_SCREEN, getlang("HelpPrefix"));
  270.     show_file(hlpname, SCRN_RESETCOL);
  271.     top_output(OUT_SCREEN, getlang("HelpSuffix"));
  272.  
  273.     }
  274.