3 * Copyright (C) 1984-2002 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;
158 typedef off_t LINENUM;
159 #define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
161 #define NULL_POSITION ((POSITION)(-1))
166 #if MSDOS_COMPILER || OS2
167 #define OPEN_READ (O_RDONLY|O_BINARY)
170 #define OPEN_READ (S_IREAD)
173 #define OPEN_READ (O_RDONLY)
175 #define OPEN_READ (0)
180 #if defined(O_WRONLY) && defined(O_APPEND)
181 #define OPEN_APPEND (O_APPEND|O_WRONLY)
184 #define OPEN_APPEND (S_IWRITE)
186 #define OPEN_APPEND (1)
191 * Set a file descriptor to binary mode.
193 #if MSDOS_COMPILER==MSOFTC
194 #define SET_BINARY(f) _setmode(f, _O_BINARY);
196 #if MSDOS_COMPILER || OS2
197 #define SET_BINARY(f) setmode(f, O_BINARY)
199 #define SET_BINARY(f)
204 * Does the shell treat "?" as a metacharacter?
206 #if MSDOS_COMPILER || OS2 || _OSK
207 #define SHELL_META_QUEST 0
209 #define SHELL_META_QUEST 1
212 #define SPACES_IN_FILENAMES 1
215 * An IFILE represents an input file.
217 #define IFILE VOID_POINTER
218 #define NULL_IFILE ((IFILE)NULL)
221 * The structure used to represent a "screen position".
222 * This consists of a file position, and a screen line number.
223 * The meaning is that the line starting at the given file
224 * position is displayed on the ln-th line of the screen.
225 * (Screen lines before ln are empty.)
240 #define NULL_PARG ((PARG *)NULL)
250 #define READ_INTR (-2)
252 /* How quiet should we be? */
253 #define NOT_QUIET 0 /* Ring bell at eof and for errors */
254 #define LITTLE_QUIET 1 /* Ring bell only for errors */
255 #define VERY_QUIET 2 /* Never ring bell */
257 /* How should we prompt? */
258 #define PR_SHORT 0 /* Prompt with colon */
259 #define PR_MEDIUM 1 /* Prompt with message */
260 #define PR_LONG 2 /* Prompt with longer message */
262 /* How should we handle backspaces? */
263 #define BS_SPECIAL 0 /* Do special things for underlining and bold */
264 #define BS_NORMAL 1 /* \b treated as normal char; actually output */
265 #define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
267 /* How should we search? */
268 #define SRCH_FORW 000001 /* Search forward from current position */
269 #define SRCH_BACK 000002 /* Search backward from current position */
270 #define SRCH_NO_MOVE 000004 /* Highlight, but don't move */
271 #define SRCH_FIND_ALL 000010 /* Find and highlight all matches */
272 #define SRCH_NO_MATCH 000100 /* Search for non-matching lines */
273 #define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */
274 #define SRCH_FIRST_FILE 000400 /* Search starting at the first file */
275 #define SRCH_NO_REGEX 001000 /* Don't use regular expressions */
277 #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
278 (((t) & ~SRCH_FORW) | SRCH_BACK) : \
279 (((t) & ~SRCH_BACK) | SRCH_FORW))
286 #define CC_OK 0 /* Char was accepted & processed */
287 #define CC_QUIT 1 /* Char was a request to abort current cmd */
288 #define CC_ERROR 2 /* Char could not be accepted due to error */
289 #define CC_PASS 3 /* Char was rejected (internal) */
291 #define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */
293 /* Special chars used to tell put_line() to do something special */
294 #define AT_NORMAL (0)
295 #define AT_UNDERLINE (1)
299 #define AT_STANDOUT (5)
302 #define IS_EBCDIC_HOST 1
307 * Long definition for EBCDIC.
308 * Since the argument is usually a constant, this macro normally compiles
311 #define CONTROL(c) ( \
312 (c)=='[' ? '\047' : \
313 (c)=='a' ? '\001' : \
314 (c)=='b' ? '\002' : \
315 (c)=='c' ? '\003' : \
316 (c)=='d' ? '\067' : \
317 (c)=='e' ? '\055' : \
318 (c)=='f' ? '\056' : \
319 (c)=='g' ? '\057' : \
320 (c)=='h' ? '\026' : \
321 (c)=='i' ? '\005' : \
322 (c)=='j' ? '\025' : \
323 (c)=='k' ? '\013' : \
324 (c)=='l' ? '\014' : \
325 (c)=='m' ? '\015' : \
326 (c)=='n' ? '\016' : \
327 (c)=='o' ? '\017' : \
328 (c)=='p' ? '\020' : \
329 (c)=='q' ? '\021' : \
330 (c)=='r' ? '\022' : \
331 (c)=='s' ? '\023' : \
332 (c)=='t' ? '\074' : \
333 (c)=='u' ? '\075' : \
334 (c)=='v' ? '\062' : \
335 (c)=='w' ? '\046' : \
336 (c)=='x' ? '\030' : \
337 (c)=='y' ? '\031' : \
338 (c)=='z' ? '\077' : \
339 (c)=='A' ? '\001' : \
340 (c)=='B' ? '\002' : \
341 (c)=='C' ? '\003' : \
342 (c)=='D' ? '\067' : \
343 (c)=='E' ? '\055' : \
344 (c)=='F' ? '\056' : \
345 (c)=='G' ? '\057' : \
346 (c)=='H' ? '\026' : \
347 (c)=='I' ? '\005' : \
348 (c)=='J' ? '\025' : \
349 (c)=='K' ? '\013' : \
350 (c)=='L' ? '\014' : \
351 (c)=='M' ? '\015' : \
352 (c)=='N' ? '\016' : \
353 (c)=='O' ? '\017' : \
354 (c)=='P' ? '\020' : \
355 (c)=='Q' ? '\021' : \
356 (c)=='R' ? '\022' : \
357 (c)=='S' ? '\023' : \
358 (c)=='T' ? '\074' : \
359 (c)=='U' ? '\075' : \
360 (c)=='V' ? '\062' : \
361 (c)=='W' ? '\046' : \
362 (c)=='X' ? '\030' : \
363 (c)=='Y' ? '\031' : \
364 (c)=='Z' ? '\077' : \
365 (c)=='|' ? '\031' : \
366 (c)=='\\' ? '\034' : \
367 (c)=='^' ? '\036' : \
370 #define CONTROL(c) ((c)&037)
371 #endif /* IS_EBCDIC_HOST */
373 #define ESC CONTROL('[')
376 #define LSIGNAL(sig,func) os9_signal(sig,func)
378 #define LSIGNAL(sig,func) signal(sig,func)
384 #undef HAVE_SIGPROCMASK
391 #define sigemptyset(mp) *(mp) = 0
395 #define S_INTERRUPT 01
398 #define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP))
402 #define QUIT_SAVED_STATUS (-1)
404 /* filestate flags */
405 #define CH_CANSEEK 001
406 #define CH_KEEPOPEN 002
407 #define CH_POPENED 004
408 #define CH_HELPFILE 010
410 #define ch_zero() ((POSITION)0)
412 #define FAKE_HELPFILE "@/\\less/\\help/\\file/\\@"
416 /* Functions not included in funcs.h */