2
* Copyright (C) 1984-2000 Mark Nudelman
4
* You may distribute under the terms of either the GNU General Public
5
* License or the Less License, as specified in the README file.
7
* For more information about less, or for information on how to
8
* contact the author, see the README file.
13
* Standard include file for "less".
17
* Defines for MSDOS_COMPILER.
19
#define MSOFTC 1 /* Microsoft C */
20
#define BORLANDC 2 /* Borland C */
21
#define WIN32C 3 /* Windows (Borland C or Microsoft C) */
22
#define DJGPPC 4 /* DJGPP C */
25
* Include the file of compile-time options.
26
* The <> make cc search for it in -I., not srcdir.
32
* Kludge for Sequent Dynix systems that have sigsetmask, but
33
* it's not compatible with the way less calls it.
34
* {{ Do other systems need this? }}
36
#undef HAVE_SIGSETMASK
43
#define VOID_POINTER void *
45
#define VOID_POINTER char *
49
#define constant const
54
#define public /* PUBLIC FUNCTION */
56
/* Library function declarations */
59
#include <sys/types.h>
86
#if MSDOS_COMPILER==WIN32C || OS2
89
#if MSDOS_COMPILER==DJGPPC
91
#include <sys/exceptn.h>
99
VOID_POINTER calloc();
104
* Simple lowercase test which can be used during option processing
105
* (before options are parsed which might tell us what charset to use).
107
#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
108
#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
109
#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A')
110
#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a')
112
#if !HAVE_UPPER_LOWER
113
#define isupper(c) SIMPLE_IS_UPPER(c)
114
#define islower(c) SIMPLE_IS_LOWER(c)
115
#define toupper(c) SIMPLE_TO_UPPER(c)
116
#define tolower(c) SIMPLE_TO_LOWER(c)
136
#define memcpy(to,from,len) bcopy((from),(to),(len))
140
#define BAD_LSEEK ((off_t)-1)
147
* Upper bound on the string length of an integer converted to string.
148
* 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
149
* add 1 for integer division truncation; add 1 more for a minus sign.
151
#define INT_STRLEN_BOUND(t) ((sizeof(t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1)
154
* Special types and constants.
156
typedef off_t POSITION;
158
#define NULL_POSITION ((POSITION)(-1))
163
#if MSDOS_COMPILER || OS2
164
#define OPEN_READ (O_RDONLY|O_BINARY)
167
#define OPEN_READ (S_IREAD)
170
#define OPEN_READ (O_RDONLY)
172
#define OPEN_READ (0)
177
#if defined(O_WRONLY) && defined(O_APPEND)
178
#define OPEN_APPEND (O_APPEND|O_WRONLY)
181
#define OPEN_APPEND (S_IWRITE)
183
#define OPEN_APPEND (1)
188
* Set a file descriptor to binary mode.
190
#if MSDOS_COMPILER==MSOFTC
191
#define SET_BINARY(f) _setmode(f, _O_BINARY);
193
#if MSDOS_COMPILER || OS2
194
#define SET_BINARY(f) setmode(f, O_BINARY)
196
#define SET_BINARY(f)
201
* Does the shell treat "?" as a metacharacter?
203
#if MSDOS_COMPILER || OS2 || _OSK
204
#define SHELL_META_QUEST 0
206
#define SHELL_META_QUEST 1
209
#define SPACES_IN_FILENAMES 1
212
* An IFILE represents an input file.
214
#define IFILE VOID_POINTER
215
#define NULL_IFILE ((IFILE)NULL)
218
* The structure used to represent a "screen position".
219
* This consists of a file position, and a screen line number.
220
* The meaning is that the line starting at the given file
221
* position is displayed on the ln-th line of the screen.
222
* (Screen lines before ln are empty.)
236
#define NULL_PARG ((PARG *)NULL)
246
#define READ_INTR (-2)
248
/* How quiet should we be? */
249
#define NOT_QUIET 0 /* Ring bell at eof and for errors */
250
#define LITTLE_QUIET 1 /* Ring bell only for errors */
251
#define VERY_QUIET 2 /* Never ring bell */
253
/* How should we prompt? */
254
#define PR_SHORT 0 /* Prompt with colon */
255
#define PR_MEDIUM 1 /* Prompt with message */
256
#define PR_LONG 2 /* Prompt with longer message */
258
/* How should we handle backspaces? */
259
#define BS_SPECIAL 0 /* Do special things for underlining and bold */
260
#define BS_NORMAL 1 /* \b treated as normal char; actually output */
261
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
263
/* How should we search? */
264
#define SRCH_FORW 000001 /* Search forward from current position */
265
#define SRCH_BACK 000002 /* Search backward from current position */
266
#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */
267
#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */
268
#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */
269
#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */
270
#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */
271
#define SRCH_NO_REGEX 001000 /* Don't use regular expressions */
273
#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
274
(((t) & ~SRCH_FORW) | SRCH_BACK) : \
275
(((t) & ~SRCH_BACK) | SRCH_FORW))
282
#define CC_OK 0 /* Char was accepted & processed */
283
#define CC_QUIT 1 /* Char was a request to abort current cmd */
284
#define CC_ERROR 2 /* Char could not be accepted due to error */
285
#define CC_PASS 3 /* Char was rejected (internal) */
287
#define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */
289
/* Special chars used to tell put_line() to do something special */
290
#define AT_NORMAL (0)
291
#define AT_UNDERLINE (1)
295
#define AT_STANDOUT (5)
298
#define IS_EBCDIC_HOST 1
303
* Long definition for EBCDIC.
304
* Since the argument is usually a constant, this macro normally compiles
307
#define CONTROL(c) ( \
308
(c)=='[' ? '\047' : \
309
(c)=='a' ? '\001' : \
310
(c)=='b' ? '\002' : \
311
(c)=='c' ? '\003' : \
312
(c)=='d' ? '\067' : \
313
(c)=='e' ? '\055' : \
314
(c)=='f' ? '\056' : \
315
(c)=='g' ? '\057' : \
316
(c)=='h' ? '\026' : \
317
(c)=='i' ? '\005' : \
318
(c)=='j' ? '\025' : \
319
(c)=='k' ? '\013' : \
320
(c)=='l' ? '\014' : \
321
(c)=='m' ? '\015' : \
322
(c)=='n' ? '\016' : \
323
(c)=='o' ? '\017' : \
324
(c)=='p' ? '\020' : \
325
(c)=='q' ? '\021' : \
326
(c)=='r' ? '\022' : \
327
(c)=='s' ? '\023' : \
328
(c)=='t' ? '\074' : \
329
(c)=='u' ? '\075' : \
330
(c)=='v' ? '\062' : \
331
(c)=='w' ? '\046' : \
332
(c)=='x' ? '\030' : \
333
(c)=='y' ? '\031' : \
334
(c)=='z' ? '\077' : \
335
(c)=='A' ? '\001' : \
336
(c)=='B' ? '\002' : \
337
(c)=='C' ? '\003' : \
338
(c)=='D' ? '\067' : \
339
(c)=='E' ? '\055' : \
340
(c)=='F' ? '\056' : \
341
(c)=='G' ? '\057' : \
342
(c)=='H' ? '\026' : \
343
(c)=='I' ? '\005' : \
344
(c)=='J' ? '\025' : \
345
(c)=='K' ? '\013' : \
346
(c)=='L' ? '\014' : \
347
(c)=='M' ? '\015' : \
348
(c)=='N' ? '\016' : \
349
(c)=='O' ? '\017' : \
350
(c)=='P' ? '\020' : \
351
(c)=='Q' ? '\021' : \
352
(c)=='R' ? '\022' : \
353
(c)=='S' ? '\023' : \
354
(c)=='T' ? '\074' : \
355
(c)=='U' ? '\075' : \
356
(c)=='V' ? '\062' : \
357
(c)=='W' ? '\046' : \
358
(c)=='X' ? '\030' : \
359
(c)=='Y' ? '\031' : \
360
(c)=='Z' ? '\077' : \
361
(c)=='|' ? '\031' : \
362
(c)=='\\' ? '\034' : \
363
(c)=='^' ? '\036' : \
366
#define CONTROL(c) ((c)&037)
367
#endif /* IS_EBCDIC_HOST */
369
#define ESC CONTROL('[')
372
#define LSIGNAL(sig,func) os9_signal(sig,func)
374
#define LSIGNAL(sig,func) signal(sig,func)
380
#undef HAVE_SIGPROCMASK
387
#define sigemptyset(mp) *(mp) = 0
391
#define S_INTERRUPT 01
394
#define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP))
398
#define QUIT_SAVED_STATUS (-1)
400
/* filestate flags */
401
#define CH_CANSEEK 001
402
#define CH_KEEPOPEN 002
403
#define CH_POPENED 004
404
#define CH_HELPFILE 010
406
#define ch_zero() ((POSITION)0)
408
#define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@"