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

Annotation of src/usr.bin/less/less.h, Revision 1.2

1.1       etheisen    1: /*
                      2:  * Copyright (c) 1984,1985,1989,1994,1995  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:  * Standard include file for "less".
                     30:  */
                     31:
                     32: /*
                     33:  * Include the file of compile-time options.
                     34:  * The <> make cc search for it in -I., not srcdir.
                     35:  */
                     36: #include <defines.h>
                     37:
                     38: #ifdef _SEQUENT_
                     39: /*
                     40:  * Kludge for Sequent Dynix systems that have sigsetmask, but
                     41:  * it's not compatible with the way less calls it.
                     42:  * {{ Do other systems need this? }}
                     43:  */
                     44: #undef HAVE_SIGSETMASK
                     45: #endif
                     46:
                     47: /*
                     48:  * Language details.
                     49:  */
                     50: #if HAVE_VOID
                     51: #define        VOID_POINTER    void *
                     52: #else
                     53: #define        VOID_POINTER    char *
                     54: #define        void  int
                     55: #endif
                     56:
                     57: #define        public          /* PUBLIC FUNCTION */
                     58:
                     59: /* Library function declarations */
                     60:
                     61: #if HAVE_SYS_TYPES_H
                     62: #include <sys/types.h>
                     63: #endif
                     64: #if HAVE_STDIO_H
                     65: #include <stdio.h>
                     66: #endif
                     67: #if HAVE_FCNTL_H
                     68: #include <fcntl.h>
                     69: #endif
                     70: #if HAVE_UNISTD_H
                     71: #include <unistd.h>
                     72: #endif
                     73: #if HAVE_CTYPE_H
                     74: #include <ctype.h>
                     75: #endif
                     76: #if STDC_HEADERS
                     77: #include <stdlib.h>
                     78: #include <string.h>
                     79: #endif
                     80:
                     81: #if !STDC_HEADERS
                     82: char *getenv();
                     83: off_t lseek();
                     84: VOID_POINTER calloc();
                     85: void free();
                     86: #endif
                     87:
                     88: #if !HAVE_UPPER_LOWER
                     89: #define        isupper(c)      ((c) >= 'A' && (c) <= 'Z')
                     90: #define        islower(c)      ((c) >= 'a' && (c) <= 'z')
                     91: #define        toupper(c)      ((c) - 'a' + 'A')
                     92: #define        tolower(c)      ((c) - 'A' + 'a')
                     93: #endif
                     94:
                     95: #ifndef NULL
                     96: #define        NULL    0
                     97: #endif
                     98:
                     99: #ifndef TRUE
                    100: #define        TRUE            1
                    101: #endif
                    102: #ifndef FALSE
                    103: #define        FALSE           0
                    104: #endif
                    105:
                    106: #define        OPT_OFF         0
                    107: #define        OPT_ON          1
                    108: #define        OPT_ONPLUS      2
                    109:
                    110: #ifndef HAVE_MEMCPY
                    111: #ifndef memcpy
                    112: #define        memcpy(to,from,len)     bcopy((from),(to),(len))
                    113: #endif
                    114: #endif
                    115:
                    116: #define        BAD_LSEEK       ((off_t)-1)
                    117:
                    118: /*
                    119:  * Special types and constants.
                    120:  */
1.2     ! millert   121: typedef off_t          POSITION;
1.1       etheisen  122: /*
                    123:  * {{ Warning: if POSITION is changed to other than "long",
                    124:  *    you may have to change some of the printfs which use "%ld"
                    125:  *    to print a variable of type POSITION. }}
                    126:  */
                    127:
                    128: #define        NULL_POSITION   ((POSITION)(-1))
                    129:
                    130: /*
                    131:  * Flags for open()
                    132:  */
                    133: #if MSOFTC || OS2
                    134: #define        OPEN_READ       (O_RDONLY|O_BINARY)
                    135: #else
                    136: #define        OPEN_READ       (0)
                    137: #endif
                    138: #if MSOFTC || OS2
                    139: #define        OPEN_APPEND     (O_APPEND|O_WRONLY)
                    140: #else
                    141: #define        OPEN_APPEND     (1)
                    142: #endif
                    143:
                    144: #if MSOFTC || OS2
                    145: #define        OPEN_TTYIN()    open("CON", O_BINARY|O_RDONLY)
                    146: #else
                    147: #define        OPEN_TTYIN()    open("/dev/tty", 0)
                    148: #endif
                    149:
                    150: /*
                    151:  * An IFILE represents an input file.
                    152:  */
                    153: #define        IFILE           VOID_POINTER
                    154: #define        NULL_IFILE      ((IFILE)NULL)
                    155:
                    156: /*
                    157:  * The structure used to represent a "screen position".
                    158:  * This consists of a file position, and a screen line number.
                    159:  * The meaning is that the line starting at the given file
                    160:  * position is displayed on the ln-th line of the screen.
                    161:  * (Screen lines before ln are empty.)
                    162:  */
                    163: struct scrpos
                    164: {
                    165:        POSITION pos;
                    166:        int ln;
                    167: };
                    168:
                    169: typedef union parg
                    170: {
                    171:        char *p_string;
                    172:        int p_int;
                    173: } PARG;
                    174:
                    175: #define        NULL_PARG       ((PARG *)NULL)
                    176:
                    177: struct textlist
                    178: {
                    179:        char *string;
                    180:        char *endstring;
                    181: };
                    182:
                    183: #define        EOI             (-1)
                    184:
                    185: #define        READ_INTR       (-2)
                    186:
                    187: /* How quiet should we be? */
                    188: #define        NOT_QUIET       0       /* Ring bell at eof and for errors */
                    189: #define        LITTLE_QUIET    1       /* Ring bell only for errors */
                    190: #define        VERY_QUIET      2       /* Never ring bell */
                    191:
                    192: /* How should we prompt? */
                    193: #define        PR_SHORT        0       /* Prompt with colon */
                    194: #define        PR_MEDIUM       1       /* Prompt with message */
                    195: #define        PR_LONG         2       /* Prompt with longer message */
                    196:
                    197: /* How should we handle backspaces? */
                    198: #define        BS_SPECIAL      0       /* Do special things for underlining and bold */
                    199: #define        BS_NORMAL       1       /* \b treated as normal char; actually output */
                    200: #define        BS_CONTROL      2       /* \b treated as control char; prints as ^H */
                    201:
                    202: /* How should we search? */
                    203: #define        SRCH_FORW       0001    /* Search forward from current position */
                    204: #define        SRCH_BACK       0002    /* Search backward from current position */
                    205: #define        SRCH_FIND_ALL   0010    /* Find and highlight all matches */
                    206: #define        SRCH_NOMATCH    0100    /* Search for non-matching lines */
                    207: #define        SRCH_PAST_EOF   0200    /* Search past end-of-file, into next file */
                    208: #define        SRCH_FIRST_FILE 0400    /* Search starting at the first file */
                    209:
                    210: #define        SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
                    211:                                (((t) & ~SRCH_FORW) | SRCH_BACK) : \
                    212:                                (((t) & ~SRCH_BACK) | SRCH_FORW))
                    213:
                    214: /* */
                    215: #define        NO_MCA          0
                    216: #define        MCA_DONE        1
                    217: #define        MCA_MORE        2
                    218:
                    219: #define        CC_OK           0       /* Char was accepted & processed */
                    220: #define        CC_QUIT         1       /* Char was a request to abort current cmd */
                    221: #define        CC_ERROR        2       /* Char could not be accepted due to error */
                    222: #define        CC_PASS         3       /* Char was rejected (internal) */
                    223:
                    224: /* Special chars used to tell put_line() to do something special */
                    225: #define        AT_NORMAL       (0)
                    226: #define        AT_UNDERLINE    (1)
                    227: #define        AT_BOLD         (2)
                    228: #define        AT_BLINK        (3)
                    229: #define        AT_INVIS        (4)
                    230: #define        AT_STANDOUT     (5)
                    231:
                    232: #define        CONTROL(c)      ((c)&037)
                    233: #define        ESC             CONTROL('[')
                    234:
                    235: #define        SIGNAL(sig,func)        signal(sig,func)
                    236:
                    237: #define        S_INTERRUPT     01
                    238: #define        S_STOP          02
                    239: #define S_WINCH                04
                    240: #define        ABORT_SIGS()    (sigs & (S_INTERRUPT|S_STOP))
                    241:
                    242: #define        QUIT_OK         0
                    243: #define        QUIT_ERROR      1
                    244: #define        QUIT_SAVED_STATUS (-1)
                    245:
                    246: /* filestate flags */
                    247: #define        CH_CANSEEK      001
                    248: #define        CH_KEEPOPEN     002
                    249: #define        CH_POPENED      004
                    250:
                    251: #define        ch_zero()       ((POSITION)0)
                    252:
                    253: #include "funcs.h"