[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.3

1.3     ! deraadt     1: /*     $OpenBSD: help.c,v 1.2 2001/01/29 01:58:02 niklas Exp $ */
1.2       niklas      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;
1.3     ! deraadt    49:        size_t len;
1.1       etheisen   50:
                     51:        helpfile = find_helpfile();
                     52:        if (helpfile == NULL)
                     53:        {
                     54:                error("Cannot find help file", NULL_PARG);
                     55:                return;
                     56:        }
                     57: #if !HAVE_SYSTEM
                     58:        /*
                     59:         * Just examine the help file.
                     60:         */
                     61:        (void) edit(helpfile);
                     62: #else
                     63:        /*
                     64:         * Use lsystem() to invoke a new instance of less
                     65:         * to view the help file.
                     66:         */
                     67: #if MSOFTC
                     68:        putenv("LESS=-m -H -+E -+s -PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done");
1.3     ! deraadt    69:        len = strlen(helpfile) + strlen(progname) + 3;
        !            70:        cmd = (char *) ecalloc(len, sizeof(char));
        !            71:        snprintf(cmd, len, "-%s %s", progname, helpfile);
1.1       etheisen   72: #else
1.3     ! deraadt    73:        len = strlen(helpfile) + strlen(progname) + 150;
        !            74:        cmd = (char *) ecalloc(len, sizeof(char));
1.1       etheisen   75: #if OS2
1.3     ! deraadt    76:        snprintf(cmd, len,
1.1       etheisen   77:         "-%s -m -H -+E -+s \"-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done \" %s",
                     78:                progname, helpfile);
                     79: #else
1.3     ! deraadt    80:        snprintf(cmd, len,
1.1       etheisen   81:         "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s",
                     82:                progname, helpfile);
                     83: #endif
                     84: #endif
                     85:        free(helpfile);
                     86:        lsystem(cmd);
                     87:        if (!nomsg)
                     88:                error("End of help", NULL_PARG);
                     89:        free(cmd);
                     90: #endif
                     91: }