home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 036 / less232.zip / HELP.C < prev    next >
C/C++ Source or Header  |  1994-09-24  |  3KB  |  89 lines

  1. /*
  2.  * Copyright (c) 1984,1985,1989,1994  Mark Nudelman
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice in the documentation and/or other materials provided with 
  12.  *    the distribution.
  13.  *
  14.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
  15.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  17.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
  18.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  19.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
  20.  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
  21.  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  22.  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
  23.  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 
  24.  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25.  */
  26.  
  27.  
  28. /*
  29.  * Display some help.
  30.  * Just invoke another "less" to display the help file.
  31.  *
  32.  * {{ This makes this function very simple, and makes changing the
  33.  *    help file very easy, but it may present difficulties on
  34.  *    (non-Unix) systems which do not supply the "system()" function. }}
  35.  */
  36.  
  37. #include  "less.h"
  38.  
  39. extern char *progname;
  40.  
  41.     public void
  42. help(nomsg)
  43.     int nomsg;
  44. {
  45.     char *helpfile;
  46.     char *cmd;
  47.  
  48.     helpfile = find_helpfile();
  49.     if (helpfile == NULL)
  50.     {
  51.         error("Cannot find help file", NULL_PARG);
  52.         return;
  53.     }
  54. #if !HAVE_SYSTEM
  55.     /*
  56.      * Just examine the help file.
  57.      */
  58.     (void) edit(helpfile);
  59. #else
  60.     /*
  61.      * Use lsystem() to invoke a new instance of less
  62.      * to view the help file.
  63.      */
  64. #if MSOFTC
  65.     putenv("LESS=-m -H -+E -+s -PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done");
  66.     cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 3,
  67.                 sizeof(char));
  68.     sprintf(cmd, "-%s %s", progname, helpfile);
  69. #else
  70.     cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 150,
  71.                 sizeof(char));
  72. #if OS2
  73.     sprintf(cmd,
  74.      "-%s -m -H -+E -+s \"-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done \" %s",
  75.         progname, helpfile);
  76. #else
  77.     sprintf(cmd, 
  78.      "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s",
  79.         progname, helpfile);
  80. #endif
  81. #endif
  82.     free(helpfile);
  83.     lsystem(cmd);
  84.     if (!nomsg)
  85.         error("End of help", NULL_PARG);
  86.     free(cmd);
  87. #endif
  88. }
  89.