home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / less / help.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-27  |  1.6 KB  |  65 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. #ifndef HELPFILE
  13. #define HELPFILE "less.hlp"
  14. #endif
  15.  
  16. #if __MSDOS__
  17. #include <io.h>
  18. #include <dir.h>
  19. #include <string.h>
  20. #include <stdlib.h>
  21. extern int output_mode;
  22. #endif
  23.  
  24. extern char *progname;
  25.  
  26.     public void
  27. help()
  28. {
  29.     char *helpfile;
  30.     char *cmd;
  31.  
  32.     helpfile = find_helpfile();
  33.     if (helpfile == NULL)
  34.     {
  35.         error("Cannot find help file", NULL_PARG);
  36.         return;
  37.     }
  38. #if __MSDOS__
  39.     putenv("LESS=-+v -+E -+s -mHPmHELP -- ?eEND -- Press g to see "
  40.         "it again:Press RETURN for more., or q when done ");
  41.     cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 50,
  42.                 sizeof(char));
  43.     if (output_mode == 0)
  44.         sprintf(cmd, "-%s %s", progname, helpfile);
  45.     else
  46.         sprintf(cmd, "-%s -qVW4,4,76,23,Help %s", progname, helpfile);
  47. #else
  48.     cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 150,
  49.                 sizeof(char));
  50. #ifdef OS2
  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. #else
  55.     sprintf(cmd,
  56.      "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s",
  57.         progname, helpfile);
  58. #endif
  59. #endif
  60.     free(helpfile);
  61.     lsystem(cmd);
  62.     error("End of help", NULL_PARG);
  63.     free(cmd);
  64. }
  65.