[BACK]Return to help.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / less

Annotation of src/usr.bin/less/help.c, Revision 1.2

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