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