home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / LESS177.ZIP / src / help.c < prev    next >
C/C++ Source or Header  |  1992-07-18  |  2KB  |  61 lines

  1. /*
  2.  * Display some help.
  3.  * Just invoke another "less" to display the help file.
  4.  *
  5.  * {{ This makes this function very simple, and makes changing the
  6.  *    help file very easy, but it may present difficulties on
  7.  *    (non-Unix) systems which do not supply the "system()" function. }}
  8.  */
  9.  
  10. #include  "less.h"
  11.  
  12. #if __MSDOS__
  13. #include <io.h>
  14. #include <dir.h>
  15. #include <string.h>
  16. #include <stdlib.h>
  17. extern int output_mode;
  18. #endif
  19.  
  20. extern char *progname;
  21.  
  22.     public void
  23. help()
  24. {
  25.     char *helpfile;
  26.     char *cmd;
  27.  
  28.     helpfile = find_helpfile();
  29.     if (helpfile == NULL)
  30.     {
  31.         error("Cannot find help file", NULL_PARG);
  32.         return;
  33.     }
  34. #if __MSDOS__
  35.     putenv("LESS=-+v -+E -+s -mHPmHELP -- ?eEND -- Press g to see "
  36.         "it again:Press RETURN for more., or q when done ");
  37.     cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 50,
  38.                 sizeof(char));
  39.     if (output_mode == 0)
  40.         sprintf(cmd, "-%s %s", progname, helpfile);
  41.     else
  42.         sprintf(cmd, "-%s -qVW4,4,76,23,Help %s", progname, helpfile);
  43. #else
  44.     cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 150,
  45.                 sizeof(char));
  46. #if OS2
  47.     sprintf(cmd, 
  48.      "-%s -m -H -+E -+s \"-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done \" %s",
  49.         progname, helpfile);
  50. #else
  51.     sprintf(cmd, 
  52.      "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s",
  53.         progname, helpfile);
  54. #endif /*OS2*/
  55. #endif
  56.     free(helpfile);
  57.     lsystem(cmd);
  58.     error("End of help", NULL_PARG);
  59.     free(cmd);
  60. }
  61.