1*84d9c625SLionel Sambuc /* $NetBSD: less.h,v 1.4 2013/09/04 19:44:21 tron Exp $ */ 2f7cf2976SLionel Sambuc 3f7cf2976SLionel Sambuc /* 4*84d9c625SLionel Sambuc * Copyright (C) 1984-2012 Mark Nudelman 5f7cf2976SLionel Sambuc * 6f7cf2976SLionel Sambuc * You may distribute under the terms of either the GNU General Public 7f7cf2976SLionel Sambuc * License or the Less License, as specified in the README file. 8f7cf2976SLionel Sambuc * 9*84d9c625SLionel Sambuc * For more information, see the README file. 10f7cf2976SLionel Sambuc */ 11f7cf2976SLionel Sambuc 12f7cf2976SLionel Sambuc #define NEWBOT 1 13f7cf2976SLionel Sambuc 14f7cf2976SLionel Sambuc /* 15f7cf2976SLionel Sambuc * Standard include file for "less". 16f7cf2976SLionel Sambuc */ 17f7cf2976SLionel Sambuc 18f7cf2976SLionel Sambuc /* 19f7cf2976SLionel Sambuc * Defines for MSDOS_COMPILER. 20f7cf2976SLionel Sambuc */ 21f7cf2976SLionel Sambuc #define MSOFTC 1 /* Microsoft C */ 22f7cf2976SLionel Sambuc #define BORLANDC 2 /* Borland C */ 23f7cf2976SLionel Sambuc #define WIN32C 3 /* Windows (Borland C or Microsoft C) */ 24f7cf2976SLionel Sambuc #define DJGPPC 4 /* DJGPP C */ 25f7cf2976SLionel Sambuc 26f7cf2976SLionel Sambuc /* 27f7cf2976SLionel Sambuc * Include the file of compile-time options. 28f7cf2976SLionel Sambuc * The <> make cc search for it in -I., not srcdir. 29f7cf2976SLionel Sambuc */ 30f7cf2976SLionel Sambuc #include <defines.h> 31f7cf2976SLionel Sambuc 32f7cf2976SLionel Sambuc #ifdef _SEQUENT_ 33f7cf2976SLionel Sambuc /* 34f7cf2976SLionel Sambuc * Kludge for Sequent Dynix systems that have sigsetmask, but 35f7cf2976SLionel Sambuc * it's not compatible with the way less calls it. 36f7cf2976SLionel Sambuc * {{ Do other systems need this? }} 37f7cf2976SLionel Sambuc */ 38f7cf2976SLionel Sambuc #undef HAVE_SIGSETMASK 39f7cf2976SLionel Sambuc #endif 40f7cf2976SLionel Sambuc 41f7cf2976SLionel Sambuc /* 42f7cf2976SLionel Sambuc * Language details. 43f7cf2976SLionel Sambuc */ 44f7cf2976SLionel Sambuc #if HAVE_VOID 45f7cf2976SLionel Sambuc #define VOID_POINTER void * 46f7cf2976SLionel Sambuc #else 47f7cf2976SLionel Sambuc #define VOID_POINTER char * 48f7cf2976SLionel Sambuc #define void int 49f7cf2976SLionel Sambuc #endif 50f7cf2976SLionel Sambuc #if HAVE_CONST 51f7cf2976SLionel Sambuc #define constant const 52f7cf2976SLionel Sambuc #else 53f7cf2976SLionel Sambuc #define constant 54f7cf2976SLionel Sambuc #endif 55f7cf2976SLionel Sambuc 56f7cf2976SLionel Sambuc #define public /* PUBLIC FUNCTION */ 57f7cf2976SLionel Sambuc 58f7cf2976SLionel Sambuc /* Library function declarations */ 59f7cf2976SLionel Sambuc 60f7cf2976SLionel Sambuc #if HAVE_SYS_TYPES_H 61f7cf2976SLionel Sambuc #include <sys/types.h> 62f7cf2976SLionel Sambuc #endif 63f7cf2976SLionel Sambuc #if HAVE_STDIO_H 64f7cf2976SLionel Sambuc #include <stdio.h> 65f7cf2976SLionel Sambuc #endif 66f7cf2976SLionel Sambuc #if HAVE_FCNTL_H 67f7cf2976SLionel Sambuc #include <fcntl.h> 68f7cf2976SLionel Sambuc #endif 69f7cf2976SLionel Sambuc #if HAVE_UNISTD_H 70f7cf2976SLionel Sambuc #include <unistd.h> 71f7cf2976SLionel Sambuc #endif 72f7cf2976SLionel Sambuc #if HAVE_CTYPE_H 73f7cf2976SLionel Sambuc #include <ctype.h> 74f7cf2976SLionel Sambuc #endif 75f7cf2976SLionel Sambuc #if HAVE_WCTYPE_H 76f7cf2976SLionel Sambuc #include <wctype.h> 77f7cf2976SLionel Sambuc #endif 78f7cf2976SLionel Sambuc #if HAVE_LIMITS_H 79f7cf2976SLionel Sambuc #include <limits.h> 80f7cf2976SLionel Sambuc #endif 81f7cf2976SLionel Sambuc #if HAVE_STDLIB_H 82f7cf2976SLionel Sambuc #include <stdlib.h> 83f7cf2976SLionel Sambuc #endif 84f7cf2976SLionel Sambuc #if HAVE_STRING_H 85f7cf2976SLionel Sambuc #include <string.h> 86f7cf2976SLionel Sambuc #endif 87f7cf2976SLionel Sambuc 88f7cf2976SLionel Sambuc /* OS-specific includes */ 89f7cf2976SLionel Sambuc #ifdef _OSK 90f7cf2976SLionel Sambuc #include <modes.h> 91f7cf2976SLionel Sambuc #include <strings.h> 92f7cf2976SLionel Sambuc #endif 93f7cf2976SLionel Sambuc 94f7cf2976SLionel Sambuc #ifdef __TANDEM 95f7cf2976SLionel Sambuc #include <floss.h> 96f7cf2976SLionel Sambuc #endif 97f7cf2976SLionel Sambuc 98f7cf2976SLionel Sambuc #if MSDOS_COMPILER==WIN32C || OS2 99f7cf2976SLionel Sambuc #include <io.h> 100f7cf2976SLionel Sambuc #endif 101f7cf2976SLionel Sambuc 102f7cf2976SLionel Sambuc #if MSDOS_COMPILER==DJGPPC 103f7cf2976SLionel Sambuc #include <io.h> 104f7cf2976SLionel Sambuc #include <sys/exceptn.h> 105f7cf2976SLionel Sambuc #include <conio.h> 106f7cf2976SLionel Sambuc #include <pc.h> 107f7cf2976SLionel Sambuc #endif 108f7cf2976SLionel Sambuc 109f7cf2976SLionel Sambuc #if !HAVE_STDLIB_H 110f7cf2976SLionel Sambuc char *getenv(); 111f7cf2976SLionel Sambuc off_t lseek(); 112f7cf2976SLionel Sambuc VOID_POINTER calloc(); 113f7cf2976SLionel Sambuc void free(); 114f7cf2976SLionel Sambuc #endif 115f7cf2976SLionel Sambuc 116f7cf2976SLionel Sambuc /* 117f7cf2976SLionel Sambuc * Simple lowercase test which can be used during option processing 118f7cf2976SLionel Sambuc * (before options are parsed which might tell us what charset to use). 119f7cf2976SLionel Sambuc */ 120f7cf2976SLionel Sambuc #define ASCII_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') 121f7cf2976SLionel Sambuc #define ASCII_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') 122f7cf2976SLionel Sambuc #define ASCII_TO_UPPER(c) ((c) - 'a' + 'A') 123f7cf2976SLionel Sambuc #define ASCII_TO_LOWER(c) ((c) - 'A' + 'a') 124f7cf2976SLionel Sambuc 125f7cf2976SLionel Sambuc #undef IS_UPPER 126f7cf2976SLionel Sambuc #undef IS_LOWER 127f7cf2976SLionel Sambuc #undef TO_UPPER 128f7cf2976SLionel Sambuc #undef TO_LOWER 129f7cf2976SLionel Sambuc #undef IS_SPACE 130f7cf2976SLionel Sambuc #undef IS_DIGIT 131f7cf2976SLionel Sambuc 132f7cf2976SLionel Sambuc #if HAVE_WCTYPE 133f7cf2976SLionel Sambuc #define IS_UPPER(c) iswupper(c) 134f7cf2976SLionel Sambuc #define IS_LOWER(c) iswlower(c) 135f7cf2976SLionel Sambuc #define TO_UPPER(c) towupper(c) 136f7cf2976SLionel Sambuc #define TO_LOWER(c) towlower(c) 137f7cf2976SLionel Sambuc #else 138f7cf2976SLionel Sambuc #if HAVE_UPPER_LOWER 139f7cf2976SLionel Sambuc #define IS_UPPER(c) isupper((unsigned char) (c)) 140f7cf2976SLionel Sambuc #define IS_LOWER(c) islower((unsigned char) (c)) 141f7cf2976SLionel Sambuc #define TO_UPPER(c) toupper((unsigned char) (c)) 142f7cf2976SLionel Sambuc #define TO_LOWER(c) tolower((unsigned char) (c)) 143f7cf2976SLionel Sambuc #else 144f7cf2976SLionel Sambuc #define IS_UPPER(c) ASCII_IS_UPPER(c) 145f7cf2976SLionel Sambuc #define IS_LOWER(c) ASCII_IS_LOWER(c) 146f7cf2976SLionel Sambuc #define TO_UPPER(c) ASCII_TO_UPPER(c) 147f7cf2976SLionel Sambuc #define TO_LOWER(c) ASCII_TO_LOWER(c) 148f7cf2976SLionel Sambuc #endif 149f7cf2976SLionel Sambuc #endif 150f7cf2976SLionel Sambuc 151f7cf2976SLionel Sambuc #ifdef isspace 152f7cf2976SLionel Sambuc #define IS_SPACE(c) isspace((unsigned char)(c)) 153f7cf2976SLionel Sambuc #else 154f7cf2976SLionel Sambuc #define IS_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f') 155f7cf2976SLionel Sambuc #endif 156f7cf2976SLionel Sambuc 157f7cf2976SLionel Sambuc #ifdef isdigit 158f7cf2976SLionel Sambuc #define IS_DIGIT(c) isdigit((unsigned char)(c)) 159f7cf2976SLionel Sambuc #else 160f7cf2976SLionel Sambuc #define IS_DIGIT(c) ((c) >= '0' && (c) <= '9') 161f7cf2976SLionel Sambuc #endif 162f7cf2976SLionel Sambuc 163f7cf2976SLionel Sambuc #define IS_CSI_START(c) (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI)) 164f7cf2976SLionel Sambuc 165f7cf2976SLionel Sambuc #ifndef NULL 166f7cf2976SLionel Sambuc #define NULL 0 167f7cf2976SLionel Sambuc #endif 168f7cf2976SLionel Sambuc 169f7cf2976SLionel Sambuc #ifndef TRUE 170f7cf2976SLionel Sambuc #define TRUE 1 171f7cf2976SLionel Sambuc #endif 172f7cf2976SLionel Sambuc #ifndef FALSE 173f7cf2976SLionel Sambuc #define FALSE 0 174f7cf2976SLionel Sambuc #endif 175f7cf2976SLionel Sambuc 176f7cf2976SLionel Sambuc #define OPT_OFF 0 177f7cf2976SLionel Sambuc #define OPT_ON 1 178f7cf2976SLionel Sambuc #define OPT_ONPLUS 2 179f7cf2976SLionel Sambuc 180f7cf2976SLionel Sambuc #if !HAVE_MEMCPY 181f7cf2976SLionel Sambuc #ifndef memcpy 182f7cf2976SLionel Sambuc #define memcpy(to,from,len) bcopy((from),(to),(len)) 183f7cf2976SLionel Sambuc #endif 184f7cf2976SLionel Sambuc #endif 185f7cf2976SLionel Sambuc 186f7cf2976SLionel Sambuc #if HAVE_SNPRINTF 187f7cf2976SLionel Sambuc #define SNPRINTF1(str, size, fmt, v1) snprintf((str), (size), (fmt), (v1)) 188f7cf2976SLionel Sambuc #define SNPRINTF2(str, size, fmt, v1, v2) snprintf((str), (size), (fmt), (v1), (v2)) 189f7cf2976SLionel Sambuc #define SNPRINTF3(str, size, fmt, v1, v2, v3) snprintf((str), (size), (fmt), (v1), (v2), (v3)) 190f7cf2976SLionel Sambuc #define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4)) 191f7cf2976SLionel Sambuc #else 192f7cf2976SLionel Sambuc /* Use unsafe sprintf if we don't have snprintf. */ 193f7cf2976SLionel Sambuc #define SNPRINTF1(str, size, fmt, v1) sprintf((str), (fmt), (v1)) 194f7cf2976SLionel Sambuc #define SNPRINTF2(str, size, fmt, v1, v2) sprintf((str), (fmt), (v1), (v2)) 195f7cf2976SLionel Sambuc #define SNPRINTF3(str, size, fmt, v1, v2, v3) sprintf((str), (fmt), (v1), (v2), (v3)) 196f7cf2976SLionel Sambuc #define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4)) 197f7cf2976SLionel Sambuc #endif 198f7cf2976SLionel Sambuc 199f7cf2976SLionel Sambuc #define BAD_LSEEK ((off_t)-1) 200f7cf2976SLionel Sambuc 201f7cf2976SLionel Sambuc #ifndef SEEK_SET 202f7cf2976SLionel Sambuc #define SEEK_SET 0 203f7cf2976SLionel Sambuc #endif 204f7cf2976SLionel Sambuc #ifndef SEEK_END 205f7cf2976SLionel Sambuc #define SEEK_END 2 206f7cf2976SLionel Sambuc #endif 207f7cf2976SLionel Sambuc 208f7cf2976SLionel Sambuc #ifndef CHAR_BIT 209f7cf2976SLionel Sambuc #define CHAR_BIT 8 210f7cf2976SLionel Sambuc #endif 211f7cf2976SLionel Sambuc 212f7cf2976SLionel Sambuc /* 213f7cf2976SLionel Sambuc * Upper bound on the string length of an integer converted to string. 214f7cf2976SLionel Sambuc * 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; 215f7cf2976SLionel Sambuc * add 1 for integer division truncation; add 1 more for a minus sign. 216f7cf2976SLionel Sambuc */ 217f7cf2976SLionel Sambuc #define INT_STRLEN_BOUND(t) ((sizeof(t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1) 218f7cf2976SLionel Sambuc 219f7cf2976SLionel Sambuc /* 220f7cf2976SLionel Sambuc * Special types and constants. 221f7cf2976SLionel Sambuc */ 222f7cf2976SLionel Sambuc typedef unsigned long LWCHAR; 223f7cf2976SLionel Sambuc typedef off_t POSITION; 224f7cf2976SLionel Sambuc typedef off_t LINENUM; 225f7cf2976SLionel Sambuc #define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */ 226f7cf2976SLionel Sambuc #define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */ 227f7cf2976SLionel Sambuc 228f7cf2976SLionel Sambuc #define NULL_POSITION ((POSITION)(-1)) 229f7cf2976SLionel Sambuc 230f7cf2976SLionel Sambuc /* 231f7cf2976SLionel Sambuc * Flags for open() 232f7cf2976SLionel Sambuc */ 233f7cf2976SLionel Sambuc #if MSDOS_COMPILER || OS2 234f7cf2976SLionel Sambuc #define OPEN_READ (O_RDONLY|O_BINARY) 235f7cf2976SLionel Sambuc #else 236f7cf2976SLionel Sambuc #ifdef _OSK 237f7cf2976SLionel Sambuc #define OPEN_READ (S_IREAD) 238f7cf2976SLionel Sambuc #else 239f7cf2976SLionel Sambuc #ifdef O_RDONLY 240f7cf2976SLionel Sambuc #define OPEN_READ (O_RDONLY) 241f7cf2976SLionel Sambuc #else 242f7cf2976SLionel Sambuc #define OPEN_READ (0) 243f7cf2976SLionel Sambuc #endif 244f7cf2976SLionel Sambuc #endif 245f7cf2976SLionel Sambuc #endif 246f7cf2976SLionel Sambuc 247f7cf2976SLionel Sambuc #if defined(O_WRONLY) && defined(O_APPEND) 248f7cf2976SLionel Sambuc #define OPEN_APPEND (O_APPEND|O_WRONLY) 249f7cf2976SLionel Sambuc #else 250f7cf2976SLionel Sambuc #ifdef _OSK 251f7cf2976SLionel Sambuc #define OPEN_APPEND (S_IWRITE) 252f7cf2976SLionel Sambuc #else 253f7cf2976SLionel Sambuc #define OPEN_APPEND (1) 254f7cf2976SLionel Sambuc #endif 255f7cf2976SLionel Sambuc #endif 256f7cf2976SLionel Sambuc 257f7cf2976SLionel Sambuc /* 258f7cf2976SLionel Sambuc * Set a file descriptor to binary mode. 259f7cf2976SLionel Sambuc */ 260f7cf2976SLionel Sambuc #if MSDOS_COMPILER==MSOFTC 261f7cf2976SLionel Sambuc #define SET_BINARY(f) _setmode(f, _O_BINARY); 262f7cf2976SLionel Sambuc #else 263f7cf2976SLionel Sambuc #if MSDOS_COMPILER || OS2 264f7cf2976SLionel Sambuc #define SET_BINARY(f) setmode(f, O_BINARY) 265f7cf2976SLionel Sambuc #else 266f7cf2976SLionel Sambuc #define SET_BINARY(f) 267f7cf2976SLionel Sambuc #endif 268f7cf2976SLionel Sambuc #endif 269f7cf2976SLionel Sambuc 270f7cf2976SLionel Sambuc /* 271f7cf2976SLionel Sambuc * Does the shell treat "?" as a metacharacter? 272f7cf2976SLionel Sambuc */ 273f7cf2976SLionel Sambuc #if MSDOS_COMPILER || OS2 || _OSK 274f7cf2976SLionel Sambuc #define SHELL_META_QUEST 0 275f7cf2976SLionel Sambuc #else 276f7cf2976SLionel Sambuc #define SHELL_META_QUEST 1 277f7cf2976SLionel Sambuc #endif 278f7cf2976SLionel Sambuc 279f7cf2976SLionel Sambuc #define SPACES_IN_FILENAMES 1 280f7cf2976SLionel Sambuc 281f7cf2976SLionel Sambuc /* 282f7cf2976SLionel Sambuc * An IFILE represents an input file. 283f7cf2976SLionel Sambuc */ 284f7cf2976SLionel Sambuc #define IFILE VOID_POINTER 285f7cf2976SLionel Sambuc #define NULL_IFILE ((IFILE)NULL) 286f7cf2976SLionel Sambuc 287f7cf2976SLionel Sambuc /* 288f7cf2976SLionel Sambuc * The structure used to represent a "screen position". 289f7cf2976SLionel Sambuc * This consists of a file position, and a screen line number. 290f7cf2976SLionel Sambuc * The meaning is that the line starting at the given file 291f7cf2976SLionel Sambuc * position is displayed on the ln-th line of the screen. 292f7cf2976SLionel Sambuc * (Screen lines before ln are empty.) 293f7cf2976SLionel Sambuc */ 294f7cf2976SLionel Sambuc struct scrpos 295f7cf2976SLionel Sambuc { 296f7cf2976SLionel Sambuc POSITION pos; 297f7cf2976SLionel Sambuc int ln; 298f7cf2976SLionel Sambuc }; 299f7cf2976SLionel Sambuc 300f7cf2976SLionel Sambuc typedef union parg 301f7cf2976SLionel Sambuc { 302f7cf2976SLionel Sambuc constant char *p_string; 303f7cf2976SLionel Sambuc int p_int; 304f7cf2976SLionel Sambuc LINENUM p_linenum; 305f7cf2976SLionel Sambuc } PARG; 306f7cf2976SLionel Sambuc 307f7cf2976SLionel Sambuc #define NULL_PARG ((PARG *)NULL) 308f7cf2976SLionel Sambuc 309f7cf2976SLionel Sambuc struct textlist 310f7cf2976SLionel Sambuc { 311f7cf2976SLionel Sambuc char *string; 312f7cf2976SLionel Sambuc char *endstring; 313f7cf2976SLionel Sambuc }; 314f7cf2976SLionel Sambuc 315f7cf2976SLionel Sambuc #define EOI (-1) 316f7cf2976SLionel Sambuc 317f7cf2976SLionel Sambuc #define READ_INTR (-2) 318f7cf2976SLionel Sambuc 319f7cf2976SLionel Sambuc /* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */ 320f7cf2976SLionel Sambuc #define NUM_FRAC_DENOM 1000000 321f7cf2976SLionel Sambuc #define NUM_LOG_FRAC_DENOM 6 322f7cf2976SLionel Sambuc 323f7cf2976SLionel Sambuc /* How quiet should we be? */ 324f7cf2976SLionel Sambuc #define NOT_QUIET 0 /* Ring bell at eof and for errors */ 325f7cf2976SLionel Sambuc #define LITTLE_QUIET 1 /* Ring bell only for errors */ 326f7cf2976SLionel Sambuc #define VERY_QUIET 2 /* Never ring bell */ 327f7cf2976SLionel Sambuc 328f7cf2976SLionel Sambuc /* How should we prompt? */ 329f7cf2976SLionel Sambuc #define PR_SHORT 0 /* Prompt with colon */ 330f7cf2976SLionel Sambuc #define PR_MEDIUM 1 /* Prompt with message */ 331f7cf2976SLionel Sambuc #define PR_LONG 2 /* Prompt with longer message */ 332f7cf2976SLionel Sambuc 333f7cf2976SLionel Sambuc /* How should we handle backspaces? */ 334f7cf2976SLionel Sambuc #define BS_SPECIAL 0 /* Do special things for underlining and bold */ 335f7cf2976SLionel Sambuc #define BS_NORMAL 1 /* \b treated as normal char; actually output */ 336f7cf2976SLionel Sambuc #define BS_CONTROL 2 /* \b treated as control char; prints as ^H */ 337f7cf2976SLionel Sambuc 338f7cf2976SLionel Sambuc /* How should we search? */ 339f7cf2976SLionel Sambuc #define SRCH_FORW (1 << 0) /* Search forward from current position */ 340f7cf2976SLionel Sambuc #define SRCH_BACK (1 << 1) /* Search backward from current position */ 341f7cf2976SLionel Sambuc #define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */ 342f7cf2976SLionel Sambuc #define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */ 343f7cf2976SLionel Sambuc #define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */ 344f7cf2976SLionel Sambuc #define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */ 345f7cf2976SLionel Sambuc #define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */ 346f7cf2976SLionel Sambuc #define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */ 347f7cf2976SLionel Sambuc #define SRCH_FILTER (1 << 13) /* Search is for '&' (filter) command */ 348f7cf2976SLionel Sambuc #define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */ 349f7cf2976SLionel Sambuc 350f7cf2976SLionel Sambuc #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \ 351f7cf2976SLionel Sambuc (((t) & ~SRCH_FORW) | SRCH_BACK) : \ 352f7cf2976SLionel Sambuc (((t) & ~SRCH_BACK) | SRCH_FORW)) 353f7cf2976SLionel Sambuc 354f7cf2976SLionel Sambuc /* */ 355f7cf2976SLionel Sambuc #define NO_MCA 0 356f7cf2976SLionel Sambuc #define MCA_DONE 1 357f7cf2976SLionel Sambuc #define MCA_MORE 2 358f7cf2976SLionel Sambuc 359f7cf2976SLionel Sambuc #define CC_OK 0 /* Char was accepted & processed */ 360f7cf2976SLionel Sambuc #define CC_QUIT 1 /* Char was a request to abort current cmd */ 361f7cf2976SLionel Sambuc #define CC_ERROR 2 /* Char could not be accepted due to error */ 362f7cf2976SLionel Sambuc #define CC_PASS 3 /* Char was rejected (internal) */ 363f7cf2976SLionel Sambuc 364f7cf2976SLionel Sambuc #define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */ 365f7cf2976SLionel Sambuc 366f7cf2976SLionel Sambuc /* Special char bit-flags used to tell put_line() to do something special */ 367f7cf2976SLionel Sambuc #define AT_NORMAL (0) 368f7cf2976SLionel Sambuc #define AT_UNDERLINE (1 << 0) 369f7cf2976SLionel Sambuc #define AT_BOLD (1 << 1) 370f7cf2976SLionel Sambuc #define AT_BLINK (1 << 2) 371f7cf2976SLionel Sambuc #define AT_STANDOUT (1 << 3) 372f7cf2976SLionel Sambuc #define AT_ANSI (1 << 4) /* Content-supplied "ANSI" escape sequence */ 373f7cf2976SLionel Sambuc #define AT_BINARY (1 << 5) /* LESS*BINFMT representation */ 374f7cf2976SLionel Sambuc #define AT_HILITE (1 << 6) /* Internal highlights (e.g., for search) */ 375f7cf2976SLionel Sambuc 376f7cf2976SLionel Sambuc #if '0' == 240 377f7cf2976SLionel Sambuc #define IS_EBCDIC_HOST 1 378f7cf2976SLionel Sambuc #endif 379f7cf2976SLionel Sambuc 380f7cf2976SLionel Sambuc #if IS_EBCDIC_HOST 381f7cf2976SLionel Sambuc /* 382f7cf2976SLionel Sambuc * Long definition for EBCDIC. 383f7cf2976SLionel Sambuc * Since the argument is usually a constant, this macro normally compiles 384f7cf2976SLionel Sambuc * into a constant. 385f7cf2976SLionel Sambuc */ 386f7cf2976SLionel Sambuc #define CONTROL(c) ( \ 387f7cf2976SLionel Sambuc (c)=='[' ? '\047' : \ 388f7cf2976SLionel Sambuc (c)=='a' ? '\001' : \ 389f7cf2976SLionel Sambuc (c)=='b' ? '\002' : \ 390f7cf2976SLionel Sambuc (c)=='c' ? '\003' : \ 391f7cf2976SLionel Sambuc (c)=='d' ? '\067' : \ 392f7cf2976SLionel Sambuc (c)=='e' ? '\055' : \ 393f7cf2976SLionel Sambuc (c)=='f' ? '\056' : \ 394f7cf2976SLionel Sambuc (c)=='g' ? '\057' : \ 395f7cf2976SLionel Sambuc (c)=='h' ? '\026' : \ 396f7cf2976SLionel Sambuc (c)=='i' ? '\005' : \ 397f7cf2976SLionel Sambuc (c)=='j' ? '\025' : \ 398f7cf2976SLionel Sambuc (c)=='k' ? '\013' : \ 399f7cf2976SLionel Sambuc (c)=='l' ? '\014' : \ 400f7cf2976SLionel Sambuc (c)=='m' ? '\015' : \ 401f7cf2976SLionel Sambuc (c)=='n' ? '\016' : \ 402f7cf2976SLionel Sambuc (c)=='o' ? '\017' : \ 403f7cf2976SLionel Sambuc (c)=='p' ? '\020' : \ 404f7cf2976SLionel Sambuc (c)=='q' ? '\021' : \ 405f7cf2976SLionel Sambuc (c)=='r' ? '\022' : \ 406f7cf2976SLionel Sambuc (c)=='s' ? '\023' : \ 407f7cf2976SLionel Sambuc (c)=='t' ? '\074' : \ 408f7cf2976SLionel Sambuc (c)=='u' ? '\075' : \ 409f7cf2976SLionel Sambuc (c)=='v' ? '\062' : \ 410f7cf2976SLionel Sambuc (c)=='w' ? '\046' : \ 411f7cf2976SLionel Sambuc (c)=='x' ? '\030' : \ 412f7cf2976SLionel Sambuc (c)=='y' ? '\031' : \ 413f7cf2976SLionel Sambuc (c)=='z' ? '\077' : \ 414f7cf2976SLionel Sambuc (c)=='A' ? '\001' : \ 415f7cf2976SLionel Sambuc (c)=='B' ? '\002' : \ 416f7cf2976SLionel Sambuc (c)=='C' ? '\003' : \ 417f7cf2976SLionel Sambuc (c)=='D' ? '\067' : \ 418f7cf2976SLionel Sambuc (c)=='E' ? '\055' : \ 419f7cf2976SLionel Sambuc (c)=='F' ? '\056' : \ 420f7cf2976SLionel Sambuc (c)=='G' ? '\057' : \ 421f7cf2976SLionel Sambuc (c)=='H' ? '\026' : \ 422f7cf2976SLionel Sambuc (c)=='I' ? '\005' : \ 423f7cf2976SLionel Sambuc (c)=='J' ? '\025' : \ 424f7cf2976SLionel Sambuc (c)=='K' ? '\013' : \ 425f7cf2976SLionel Sambuc (c)=='L' ? '\014' : \ 426f7cf2976SLionel Sambuc (c)=='M' ? '\015' : \ 427f7cf2976SLionel Sambuc (c)=='N' ? '\016' : \ 428f7cf2976SLionel Sambuc (c)=='O' ? '\017' : \ 429f7cf2976SLionel Sambuc (c)=='P' ? '\020' : \ 430f7cf2976SLionel Sambuc (c)=='Q' ? '\021' : \ 431f7cf2976SLionel Sambuc (c)=='R' ? '\022' : \ 432f7cf2976SLionel Sambuc (c)=='S' ? '\023' : \ 433f7cf2976SLionel Sambuc (c)=='T' ? '\074' : \ 434f7cf2976SLionel Sambuc (c)=='U' ? '\075' : \ 435f7cf2976SLionel Sambuc (c)=='V' ? '\062' : \ 436f7cf2976SLionel Sambuc (c)=='W' ? '\046' : \ 437f7cf2976SLionel Sambuc (c)=='X' ? '\030' : \ 438f7cf2976SLionel Sambuc (c)=='Y' ? '\031' : \ 439f7cf2976SLionel Sambuc (c)=='Z' ? '\077' : \ 440f7cf2976SLionel Sambuc (c)=='|' ? '\031' : \ 441f7cf2976SLionel Sambuc (c)=='\\' ? '\034' : \ 442f7cf2976SLionel Sambuc (c)=='^' ? '\036' : \ 443f7cf2976SLionel Sambuc (c)&077) 444f7cf2976SLionel Sambuc #else 445f7cf2976SLionel Sambuc #define CONTROL(c) ((c)&037) 446f7cf2976SLionel Sambuc #endif /* IS_EBCDIC_HOST */ 447f7cf2976SLionel Sambuc 448f7cf2976SLionel Sambuc #define ESC CONTROL('[') 449f7cf2976SLionel Sambuc #define CSI ((unsigned char)'\233') 450f7cf2976SLionel Sambuc 451f7cf2976SLionel Sambuc #if _OSK_MWC32 452f7cf2976SLionel Sambuc #define LSIGNAL(sig,func) os9_signal(sig,func) 453f7cf2976SLionel Sambuc #else 454f7cf2976SLionel Sambuc #define LSIGNAL(sig,func) signal(sig,func) 455f7cf2976SLionel Sambuc #endif 456f7cf2976SLionel Sambuc 457f7cf2976SLionel Sambuc #if HAVE_SIGPROCMASK 458f7cf2976SLionel Sambuc #if HAVE_SIGSET_T 459f7cf2976SLionel Sambuc #else 460f7cf2976SLionel Sambuc #undef HAVE_SIGPROCMASK 461f7cf2976SLionel Sambuc #endif 462f7cf2976SLionel Sambuc #endif 463f7cf2976SLionel Sambuc #if HAVE_SIGPROCMASK 464f7cf2976SLionel Sambuc #if HAVE_SIGEMPTYSET 465f7cf2976SLionel Sambuc #else 466f7cf2976SLionel Sambuc #undef sigemptyset 467f7cf2976SLionel Sambuc #define sigemptyset(mp) *(mp) = 0 468f7cf2976SLionel Sambuc #endif 469f7cf2976SLionel Sambuc #endif 470f7cf2976SLionel Sambuc 471f7cf2976SLionel Sambuc #define S_INTERRUPT 01 472f7cf2976SLionel Sambuc #define S_STOP 02 473f7cf2976SLionel Sambuc #define S_WINCH 04 474f7cf2976SLionel Sambuc #define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP)) 475f7cf2976SLionel Sambuc 476f7cf2976SLionel Sambuc #define QUIT_OK 0 477f7cf2976SLionel Sambuc #define QUIT_ERROR 1 478f7cf2976SLionel Sambuc #define QUIT_INTERRUPT 2 479f7cf2976SLionel Sambuc #define QUIT_SAVED_STATUS (-1) 480f7cf2976SLionel Sambuc 481f7cf2976SLionel Sambuc #define FOLLOW_DESC 0 482f7cf2976SLionel Sambuc #define FOLLOW_NAME 1 483f7cf2976SLionel Sambuc 484f7cf2976SLionel Sambuc /* filestate flags */ 485f7cf2976SLionel Sambuc #define CH_CANSEEK 001 486f7cf2976SLionel Sambuc #define CH_KEEPOPEN 002 487f7cf2976SLionel Sambuc #define CH_POPENED 004 488f7cf2976SLionel Sambuc #define CH_HELPFILE 010 489*84d9c625SLionel Sambuc #define CH_NODATA 020 /* Special case for zero length files */ 490*84d9c625SLionel Sambuc 491f7cf2976SLionel Sambuc 492f7cf2976SLionel Sambuc #define ch_zero() ((POSITION)0) 493f7cf2976SLionel Sambuc 494f7cf2976SLionel Sambuc #define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@" 495*84d9c625SLionel Sambuc #define FAKE_EMPTYFILE "@/\\less/\\empty/\\file/\\@" 496f7cf2976SLionel Sambuc 497f7cf2976SLionel Sambuc /* Flags for cvt_text */ 498f7cf2976SLionel Sambuc #define CVT_TO_LC 01 /* Convert upper-case to lower-case */ 499f7cf2976SLionel Sambuc #define CVT_BS 02 /* Do backspace processing */ 500f7cf2976SLionel Sambuc #define CVT_CRLF 04 /* Remove CR after LF */ 501f7cf2976SLionel Sambuc #define CVT_ANSI 010 /* Remove ANSI escape sequences */ 502f7cf2976SLionel Sambuc 503f7cf2976SLionel Sambuc #include "funcs.h" 504f7cf2976SLionel Sambuc 505f7cf2976SLionel Sambuc /* Functions not included in funcs.h */ 506f7cf2976SLionel Sambuc void postoa(); 507f7cf2976SLionel Sambuc void linenumtoa(); 508f7cf2976SLionel Sambuc void inttoa(); 509