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

1.1       etheisen    1: /*
1.9       shadchin    2:  * Copyright (C) 1984-2012  Mark Nudelman
1.13      nicm        3:  * Modified for use with illumos by Garrett D'Amore.
                      4:  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
1.1       etheisen    5:  *
1.4       millert     6:  * You may distribute under the terms of either the GNU General Public
                      7:  * License or the Less License, as specified in the README file.
1.1       etheisen    8:  *
1.9       shadchin    9:  * For more information, see the README file.
1.1       etheisen   10:  */
                     11:
                     12: /*
1.10      nicm       13:  * Standard include file for "less".
1.4       millert    14:  */
                     15:
1.23      mmcc       16: #include "defines.h"
1.1       etheisen   17:
1.26      mmcc       18: #include <sys/types.h>
1.1       etheisen   19:
1.26      mmcc       20: #include <ctype.h>
1.1       etheisen   21: #include <fcntl.h>
1.4       millert    22: #include <limits.h>
1.26      mmcc       23: #include <signal.h>
                     24: #include <stdio.h>
1.1       etheisen   25: #include <stdlib.h>
                     26: #include <string.h>
1.26      mmcc       27: #include <unistd.h>
                     28: #include <wctype.h>
1.7       shadchin   29:
1.4       millert    30: /*
                     31:  * Simple lowercase test which can be used during option processing
                     32:  * (before options are parsed which might tell us what charset to use).
                     33:  */
1.7       shadchin   34:
                     35: #undef IS_SPACE
                     36: #undef IS_DIGIT
                     37:
1.10      nicm       38: #define        IS_SPACE(c)     isspace((unsigned char)(c))
                     39: #define        IS_DIGIT(c)     isdigit((unsigned char)(c))
1.7       shadchin   40:
1.1       etheisen   41: #ifndef TRUE
                     42: #define        TRUE            1
                     43: #endif
                     44: #ifndef FALSE
                     45: #define        FALSE           0
                     46: #endif
                     47:
                     48: #define        OPT_OFF         0
                     49: #define        OPT_ON          1
                     50: #define        OPT_ONPLUS      2
                     51:
1.4       millert    52: /*
1.1       etheisen   53:  * Special types and constants.
                     54:  */
1.7       shadchin   55: typedef unsigned long LWCHAR;
1.10      nicm       56: #define        MIN_LINENUM_WIDTH  7    /* Min printing width of a line number */
                     57: #define        MAX_UTF_CHAR_LEN   6    /* Max bytes in one UTF-8 char */
1.1       etheisen   58:
1.4       millert    59: #define        SHELL_META_QUEST 1
1.1       etheisen   60:
                     61: /*
                     62:  * An IFILE represents an input file.
                     63:  */
1.10      nicm       64: #define        IFILE           void *
1.1       etheisen   65:
                     66: /*
                     67:  * The structure used to represent a "screen position".
                     68:  * This consists of a file position, and a screen line number.
                     69:  * The meaning is that the line starting at the given file
                     70:  * position is displayed on the ln-th line of the screen.
                     71:  * (Screen lines before ln are empty.)
                     72:  */
1.10      nicm       73: struct scrpos {
                     74:        off_t pos;
1.1       etheisen   75:        int ln;
                     76: };
                     77:
1.15      deraadt    78: typedef union parg {
1.1       etheisen   79:        char *p_string;
                     80:        int p_int;
1.21      mmcc       81:        off_t p_linenum;
1.1       etheisen   82: } PARG;
                     83:
1.15      deraadt    84: struct textlist {
1.1       etheisen   85:        char *string;
                     86:        char *endstring;
                     87: };
                     88:
                     89: #define        EOI             (-1)
                     90:
                     91: #define        READ_INTR       (-2)
                     92:
1.7       shadchin   93: /* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */
1.10      nicm       94: #define        NUM_FRAC_DENOM                  1000000
                     95: #define        NUM_LOG_FRAC_DENOM              6
1.7       shadchin   96:
1.1       etheisen   97: /* How quiet should we be? */
                     98: #define        NOT_QUIET       0       /* Ring bell at eof and for errors */
                     99: #define        LITTLE_QUIET    1       /* Ring bell only for errors */
                    100: #define        VERY_QUIET      2       /* Never ring bell */
                    101:
                    102: /* How should we prompt? */
                    103: #define        PR_SHORT        0       /* Prompt with colon */
                    104: #define        PR_MEDIUM       1       /* Prompt with message */
                    105: #define        PR_LONG         2       /* Prompt with longer message */
                    106:
                    107: /* How should we handle backspaces? */
                    108: #define        BS_SPECIAL      0       /* Do special things for underlining and bold */
                    109: #define        BS_NORMAL       1       /* \b treated as normal char; actually output */
                    110: #define        BS_CONTROL      2       /* \b treated as control char; prints as ^H */
                    111:
                    112: /* How should we search? */
1.10      nicm      113: #define        SRCH_FORW       (1 << 0)  /* Search forward from current position */
                    114: #define        SRCH_BACK       (1 << 1)  /* Search backward from current position */
                    115: #define        SRCH_NO_MOVE    (1 << 2)  /* Highlight, but don't move */
                    116: #define        SRCH_FIND_ALL   (1 << 4)  /* Find and highlight all matches */
                    117: #define        SRCH_NO_MATCH   (1 << 8)  /* Search for non-matching lines */
                    118: #define        SRCH_PAST_EOF   (1 << 9)  /* Search past end-of-file, into next file */
                    119: #define        SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
                    120: #define        SRCH_NO_REGEX   (1 << 12) /* Don't use regular expressions */
                    121: #define        SRCH_FILTER     (1 << 13) /* Search is for '&' (filter) command */
                    122: #define        SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
1.1       etheisen  123:
                    124: #define        SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
                    125:                                (((t) & ~SRCH_FORW) | SRCH_BACK) : \
                    126:                                (((t) & ~SRCH_BACK) | SRCH_FORW))
                    127:
                    128: /* */
                    129: #define        NO_MCA          0
                    130: #define        MCA_DONE        1
                    131: #define        MCA_MORE        2
                    132:
                    133: #define        CC_OK           0       /* Char was accepted & processed */
                    134: #define        CC_QUIT         1       /* Char was a request to abort current cmd */
                    135: #define        CC_ERROR        2       /* Char could not be accepted due to error */
                    136: #define        CC_PASS         3       /* Char was rejected (internal) */
                    137:
1.10      nicm      138: #define        CF_QUIT_ON_ERASE 0001   /* Abort cmd if its entirely erased */
1.4       millert   139:
1.7       shadchin  140: /* Special char bit-flags used to tell put_line() to do something special */
1.1       etheisen  141: #define        AT_NORMAL       (0)
1.7       shadchin  142: #define        AT_UNDERLINE    (1 << 0)
                    143: #define        AT_BOLD         (1 << 1)
                    144: #define        AT_BLINK        (1 << 2)
                    145: #define        AT_STANDOUT     (1 << 3)
                    146: #define        AT_ANSI         (1 << 4)  /* Content-supplied "ANSI" escape sequence */
                    147: #define        AT_BINARY       (1 << 5)  /* LESS*BINFMT representation */
                    148: #define        AT_HILITE       (1 << 6)  /* Internal highlights (e.g., for search) */
1.27      natano    149: #define        AT_INDET        (1 << 7)  /* Indeterminate: either bold or underline */
1.1       etheisen  150:
                    151: #define        CONTROL(c)      ((c)&037)
                    152: #define        ESC             CONTROL('[')
                    153:
                    154: #define        S_INTERRUPT     01
                    155: #define        S_STOP          02
1.10      nicm      156: #define        S_WINCH         04
1.1       etheisen  157: #define        ABORT_SIGS()    (sigs & (S_INTERRUPT|S_STOP))
                    158:
                    159: #define        QUIT_OK         0
                    160: #define        QUIT_ERROR      1
1.7       shadchin  161: #define        QUIT_INTERRUPT  2
1.1       etheisen  162: #define        QUIT_SAVED_STATUS (-1)
                    163:
1.10      nicm      164: #define        FOLLOW_DESC     0
                    165: #define        FOLLOW_NAME     1
1.7       shadchin  166:
1.1       etheisen  167: /* filestate flags */
                    168: #define        CH_CANSEEK      001
                    169: #define        CH_KEEPOPEN     002
                    170: #define        CH_POPENED      004
1.7       shadchin  171: #define        CH_HELPFILE     010
1.11      deraadt   172: #define        CH_NODATA       020     /* Special case for zero length files */
1.9       shadchin  173:
1.1       etheisen  174:
1.10      nicm      175: #define        ch_zero()       (0)
1.9       shadchin  176:
1.10      nicm      177: #define        FAKE_EMPTYFILE  "@/\\less/\\empty/\\file/\\@"
1.7       shadchin  178:
                    179: /* Flags for cvt_text */
                    180: #define        CVT_TO_LC       01      /* Convert upper-case to lower-case */
                    181: #define        CVT_BS          02      /* Do backspace processing */
                    182: #define        CVT_CRLF        04      /* Remove CR after LF */
                    183: #define        CVT_ANSI        010     /* Remove ANSI escape sequences */
1.4       millert   184:
1.1       etheisen  185: #include "funcs.h"
1.4       millert   186:
                    187: /* Functions not included in funcs.h */
1.10      nicm      188: void postoa(off_t, char *, size_t);
                    189: void inttoa(int, char *, size_t);