1d9b9f84delphij/*
2bdad060delphij * Copyright (C) 1984-2019  Mark Nudelman
3d9b9f84delphij *
4d9b9f84delphij * You may distribute under the terms of either the GNU General Public
5d9b9f84delphij * License or the Less License, as specified in the README file.
6d9b9f84delphij *
7d9b9f84delphij * For more information, see the README file.
8d9b9f84delphij */
91b28029ps
107672cb6delphij#define NEWBOT 1
111b28029ps
121b28029ps/*
131b28029ps * Standard include file for "less".
141b28029ps */
151b28029ps
161b28029ps/*
171b28029ps * Defines for MSDOS_COMPILER.
181b28029ps */
191b28029ps#define	MSOFTC		1	/* Microsoft C */
201b28029ps#define	BORLANDC	2	/* Borland C */
211b28029ps#define	WIN32C		3	/* Windows (Borland C or Microsoft C) */
221b28029ps#define	DJGPPC		4	/* DJGPP C */
231b28029ps
241b28029ps/*
251b28029ps * Include the file of compile-time options.
261b28029ps * The <> make cc search for it in -I., not srcdir.
271b28029ps */
281b28029ps#include <defines.h>
291b28029ps
301b28029ps#ifdef _SEQUENT_
311b28029ps/*
321b28029ps * Kludge for Sequent Dynix systems that have sigsetmask, but
331b28029ps * it's not compatible with the way less calls it.
341b28029ps * {{ Do other systems need this? }}
351b28029ps */
361b28029ps#undef HAVE_SIGSETMASK
371b28029ps#endif
381b28029ps
391b28029ps/*
401b28029ps * Language details.
411b28029ps */
421c120d2delphij#if HAVE_ANSI_PROTOS
431c120d2delphij#define LESSPARAMS(a) a
441c120d2delphij#else
451c120d2delphij#define LESSPARAMS(a) ()
461c120d2delphij#endif
471b28029ps#if HAVE_VOID
481b28029ps#define	VOID_POINTER	void *
491c120d2delphij#define	VOID_PARAM	void
501b28029ps#else
511b28029ps#define	VOID_POINTER	char *
521c120d2delphij#define	VOID_PARAM
531b28029ps#define	void  int
541b28029ps#endif
551b28029ps#if HAVE_CONST
561b28029ps#define	constant	const
571b28029ps#else
581b28029ps#define	constant
591b28029ps#endif
601b28029ps
611b28029ps#define	public		/* PUBLIC FUNCTION */
621b28029ps
631b28029ps/* Library function declarations */
641b28029ps
651b28029ps#if HAVE_SYS_TYPES_H
661b28029ps#include <sys/types.h>
671b28029ps#endif
681b28029ps#if HAVE_STDIO_H
691b28029ps#include <stdio.h>
701b28029ps#endif
711b28029ps#if HAVE_FCNTL_H
721b28029ps#include <fcntl.h>
731b28029ps#endif
741b28029ps#if HAVE_UNISTD_H
751b28029ps#include <unistd.h>
761b28029ps#endif
771b28029ps#if HAVE_CTYPE_H
781b28029ps#include <ctype.h>
791b28029ps#endif
80e2b0c4adelphij#if HAVE_WCTYPE_H
81e2b0c4adelphij#include <wctype.h>
82e2b0c4adelphij#endif
83c0c85bcps#if HAVE_LIMITS_H
84c0c85bcps#include <limits.h>
85c0c85bcps#endif
861b28029ps#if HAVE_STDLIB_H
871b28029ps#include <stdlib.h>
881b28029ps#endif
891b28029ps#if HAVE_STRING_H
901b28029ps#include <string.h>
911b28029ps#endif
925297f4bdelphij
935297f4bdelphij/* OS-specific includes */
941b28029ps#ifdef _OSK
951b28029ps#include <modes.h>
961b28029ps#include <strings.h>
971b28029ps#endif
985297f4bdelphij
995297f4bdelphij#ifdef __TANDEM
1005297f4bdelphij#include <floss.h>
1015297f4bdelphij#endif
1025297f4bdelphij
103c0c85bcps#if MSDOS_COMPILER==WIN32C || OS2
1041b28029ps#include <io.h>
1051b28029ps#endif
1065297f4bdelphij
1071b28029ps#if MSDOS_COMPILER==DJGPPC
1081b28029ps#include <io.h>
1091b28029ps#include <sys/exceptn.h>
1101b28029ps#include <conio.h>
1111b28029ps#include <pc.h>
1121b28029ps#endif
1131b28029ps
1141b28029ps#if !HAVE_STDLIB_H
1151b28029pschar *getenv();
1161b28029psoff_t lseek();
1171b28029psVOID_POINTER calloc();
1181b28029psvoid free();
1191b28029ps#endif
1201b28029ps
1211b28029ps/*
1221b28029ps * Simple lowercase test which can be used during option processing
1231b28029ps * (before options are parsed which might tell us what charset to use).
1241b28029ps */
1255297f4bdelphij#define ASCII_IS_UPPER(c)	((c) >= 'A' && (c) <= 'Z')
1265297f4bdelphij#define ASCII_IS_LOWER(c)	((c) >= 'a' && (c) <= 'z')
1275297f4bdelphij#define	ASCII_TO_UPPER(c)	((c) - 'a' + 'A')
1285297f4bdelphij#define	ASCII_TO_LOWER(c)	((c) - 'A' + 'a')
1295297f4bdelphij
1305297f4bdelphij#undef IS_UPPER
1315297f4bdelphij#undef IS_LOWER
1325297f4bdelphij#undef TO_UPPER
1335297f4bdelphij#undef TO_LOWER
1345297f4bdelphij#undef IS_SPACE
1355297f4bdelphij#undef IS_DIGIT
1361b28029ps
137e2b0c4adelphij#if HAVE_WCTYPE
138e2b0c4adelphij#define	IS_UPPER(c)	iswupper(c)
139e2b0c4adelphij#define	IS_LOWER(c)	iswlower(c)
140e2b0c4adelphij#define	TO_UPPER(c)	towupper(c)
141e2b0c4adelphij#define	TO_LOWER(c)	towlower(c)
1425297f4bdelphij#else
143e2b0c4adelphij#if HAVE_UPPER_LOWER
1445297f4bdelphij#define	IS_UPPER(c)	isupper((unsigned char) (c))
1455297f4bdelphij#define	IS_LOWER(c)	islower((unsigned char) (c))
1465297f4bdelphij#define	TO_UPPER(c)	toupper((unsigned char) (c))
1475297f4bdelphij#define	TO_LOWER(c)	tolower((unsigned char) (c))
148e2b0c4adelphij#else
149e2b0c4adelphij#define	IS_UPPER(c)	ASCII_IS_UPPER(c)
150e2b0c4adelphij#define	IS_LOWER(c)	ASCII_IS_LOWER(c)
151e2b0c4adelphij#define	TO_UPPER(c)	ASCII_TO_UPPER(c)
152e2b0c4adelphij#define	TO_LOWER(c)	ASCII_TO_LOWER(c)
153e2b0c4adelphij#endif
1545297f4bdelphij#endif
1555297f4bdelphij
1565297f4bdelphij#ifdef isspace
1575297f4bdelphij#define IS_SPACE(c)	isspace((unsigned char)(c))
1585297f4bdelphij#else
1595297f4bdelphij#define IS_SPACE(c)	((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f')
1605297f4bdelphij#endif
1615297f4bdelphij
1625297f4bdelphij#ifdef isdigit
1635297f4bdelphij#define IS_DIGIT(c)	isdigit((unsigned char)(c))
1645297f4bdelphij#else
1655297f4bdelphij#define IS_DIGIT(c)	((c) >= '0' && (c) <= '9')
1661b28029ps#endif
1671b28029ps
16840472e4delphij#define IS_CSI_START(c)	(((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI))
169aa9fcd7delphij
1701b28029ps#ifndef NULL
1711b28029ps#define	NULL	0
1721b28029ps#endif
1731b28029ps
1741b28029ps#ifndef TRUE
1751b28029ps#define	TRUE		1
1761b28029ps#endif
1771b28029ps#ifndef FALSE
1781b28029ps#define	FALSE		0
1791b28029ps#endif
1801b28029ps
1811b28029ps#define	OPT_OFF		0
1821b28029ps#define	OPT_ON		1
1831b28029ps#define	OPT_ONPLUS	2
1841b28029ps
1851b28029ps#if !HAVE_MEMCPY
1861b28029ps#ifndef memcpy
1871b28029ps#define	memcpy(to,from,len)	bcopy((from),(to),(len))
1881b28029ps#endif
1891b28029ps#endif
1901b28029ps
1915297f4bdelphij#if HAVE_SNPRINTF
1925297f4bdelphij#define SNPRINTF1(str, size, fmt, v1)             snprintf((str), (size), (fmt), (v1))
1935297f4bdelphij#define SNPRINTF2(str, size, fmt, v1, v2)         snprintf((str), (size), (fmt), (v1), (v2))
1945297f4bdelphij#define SNPRINTF3(str, size, fmt, v1, v2, v3)     snprintf((str), (size), (fmt), (v1), (v2), (v3))
1955297f4bdelphij#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4))
1965297f4bdelphij#else
1975297f4bdelphij/* Use unsafe sprintf if we don't have snprintf. */
1985297f4bdelphij#define SNPRINTF1(str, size, fmt, v1)             sprintf((str), (fmt), (v1))
1995297f4bdelphij#define SNPRINTF2(str, size, fmt, v1, v2)         sprintf((str), (fmt), (v1), (v2))
2005297f4bdelphij#define SNPRINTF3(str, size, fmt, v1, v2, v3)     sprintf((str), (fmt), (v1), (v2), (v3))
2015297f4bdelphij#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4))
2025297f4bdelphij#endif
2035297f4bdelphij
2041b28029ps#define	BAD_LSEEK	((off_t)-1)
2051b28029ps
206e2b0c4adelphij#ifndef SEEK_SET
207e2b0c4adelphij#define SEEK_SET 0
208e2b0c4adelphij#endif
209e2b0c4adelphij#ifndef SEEK_END
210e2b0c4adelphij#define SEEK_END 2
211e2b0c4adelphij#endif
212e2b0c4adelphij
213c0c85bcps#ifndef CHAR_BIT
214c0c85bcps#define CHAR_BIT 8
215c0c85bcps#endif
216c0c85bcps
217c0c85bcps/*
218c0c85bcps * Upper bound on the string length of an integer converted to string.
219c0c85bcps * 302 / 1000 is ceil (log10 (2.0)).  Subtract 1 for the sign bit;
220c0c85bcps * add 1 for integer division truncation; add 1 more for a minus sign.
221c0c85bcps */
222c0c85bcps#define INT_STRLEN_BOUND(t) ((sizeof(t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1)
223c0c85bcps
2241b28029ps/*
2251b28029ps * Special types and constants.
2261b28029ps */
2275297f4bdelphijtypedef unsigned long LWCHAR;
2285d46577pstypedef off_t		POSITION;
22944c4d55tjrtypedef off_t		LINENUM;
23044c4d55tjr#define MIN_LINENUM_WIDTH  7	/* Min printing width of a line number */
2315297f4bdelphij#define MAX_UTF_CHAR_LEN   6	/* Max bytes in one UTF-8 char */
2321b28029ps
2331b28029ps#define	NULL_POSITION	((POSITION)(-1))
2341b28029ps
2351b28029ps/*
2361b28029ps * Flags for open()
2371b28029ps */
2381b28029ps#if MSDOS_COMPILER || OS2
2391b28029ps#define	OPEN_READ	(O_RDONLY|O_BINARY)
2401b28029ps#else
2411b28029ps#ifdef _OSK
2421b28029ps#define	OPEN_READ	(S_IREAD)
2431b28029ps#else
2441b28029ps#ifdef O_RDONLY
2451b28029ps#define	OPEN_READ	(O_RDONLY)
2461b28029ps#else
2471b28029ps#define	OPEN_READ	(0)
2481b28029ps#endif
2491b28029ps#endif
2501b28029ps#endif
2511b28029ps
2521b28029ps#if defined(O_WRONLY) && defined(O_APPEND)
2531b28029ps#define	OPEN_APPEND	(O_APPEND|O_WRONLY)
2541b28029ps#else
2551b28029ps#ifdef _OSK
2561b28029ps#define OPEN_APPEND	(S_IWRITE)
2571b28029ps#else
2581b28029ps#define	OPEN_APPEND	(1)
2591b28029ps#endif
2601b28029ps#endif
2611b28029ps
2621b28029ps/*
2631b28029ps * Set a file descriptor to binary mode.
2641b28029ps */
2651b28029ps#if MSDOS_COMPILER==MSOFTC
2661b28029ps#define	SET_BINARY(f)	_setmode(f, _O_BINARY);
2671b28029ps#else
268c0c85bcps#if MSDOS_COMPILER || OS2
2691b28029ps#define	SET_BINARY(f)	setmode(f, O_BINARY)
2701b28029ps#else
2711b28029ps#define	SET_BINARY(f)
2721b28029ps#endif
2731b28029ps#endif
2741b28029ps
2751b28029ps/*
2761b28029ps * Does the shell treat "?" as a metacharacter?
2771b28029ps */
2781b28029ps#if MSDOS_COMPILER || OS2 || _OSK
2791b28029ps#define	SHELL_META_QUEST 0
2801b28029ps#else
2811b28029ps#define	SHELL_META_QUEST 1
2821b28029ps#endif
2831b28029ps
2841b28029ps#define	SPACES_IN_FILENAMES 1
2851b28029ps
2861b28029ps/*
2871b28029ps * An IFILE represents an input file.
2881b28029ps */
2891b28029ps#define	IFILE		VOID_POINTER
2901b28029ps#define	NULL_IFILE	((IFILE)NULL)
2911b28029ps
2921b28029ps/*
2931b28029ps * The structure used to represent a "screen position".
2941b28029ps * This consists of a file position, and a screen line number.
2951b28029ps * The meaning is that the line starting at the given file
2961b28029ps * position is displayed on the ln-th line of the screen.
2971b28029ps * (Screen lines before ln are empty.)
2981b28029ps */
2991b28029psstruct scrpos
3001b28029ps{
3011b28029ps	POSITION pos;
3021b28029ps	int ln;
3031b28029ps};
3041b28029ps
3051b28029pstypedef union parg
3061b28029ps{
3071b28029ps	char *p_string;
3081b28029ps	int p_int;
30944c4d55tjr	LINENUM p_linenum;
3101b28029ps} PARG;
3111b28029ps
3121b28029ps#define	NULL_PARG	((PARG *)NULL)
3131b28029ps
3141b28029psstruct textlist
3151b28029ps{
3161b28029ps	char *string;
3171b28029ps	char *endstring;
3181b28029ps};
3191b28029ps
320479faf1delphijstruct wchar_range
321479faf1delphij{
322479faf1delphij	LWCHAR first, last;
323479faf1delphij};
324479faf1delphij
325479faf1delphijstruct wchar_range_table
326479faf1delphij{
327479faf1delphij	struct wchar_range *table;
328479faf1delphij	int count;
329479faf1delphij};
330479faf1delphij
3311b28029ps#define	EOI		(-1)
3321b28029ps
3331b28029ps#define	READ_INTR	(-2)
3341b28029ps
3357672cb6delphij/* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */
3367672cb6delphij#define NUM_FRAC_DENOM			1000000
3377672cb6delphij#define NUM_LOG_FRAC_DENOM		6
3387672cb6delphij
3391b28029ps/* How quiet should we be? */
3401b28029ps#define	NOT_QUIET	0	/* Ring bell at eof and for errors */
3411b28029ps#define	LITTLE_QUIET	1	/* Ring bell only for errors */
3421b28029ps#define	VERY_QUIET	2	/* Never ring bell */
3431b28029ps
3441b28029ps/* How should we prompt? */
3451b28029ps#define	PR_SHORT	0	/* Prompt with colon */
3461b28029ps#define	PR_MEDIUM	1	/* Prompt with message */
3471b28029ps#define	PR_LONG		2	/* Prompt with longer message */
3481b28029ps
3491b28029ps/* How should we handle backspaces? */
3501b28029ps#define	BS_SPECIAL	0	/* Do special things for underlining and bold */
3511b28029ps#define	BS_NORMAL	1	/* \b treated as normal char; actually output */
3521b28029ps#define	BS_CONTROL	2	/* \b treated as control char; prints as ^H */
3531b28029ps
3541b28029ps/* How should we search? */
35540472e4delphij#define	SRCH_FORW       (1 << 0)  /* Search forward from current position */
35640472e4delphij#define	SRCH_BACK       (1 << 1)  /* Search backward from current position */
35740472e4delphij#define SRCH_NO_MOVE    (1 << 2)  /* Highlight, but don't move */
35840472e4delphij#define SRCH_FIND_ALL   (1 << 4)  /* Find and highlight all matches */
35940472e4delphij#define SRCH_NO_MATCH   (1 << 8)  /* Search for non-matching lines */
36040472e4delphij#define SRCH_PAST_EOF   (1 << 9)  /* Search past end-of-file, into next file */
36140472e4delphij#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
36240472e4delphij#define SRCH_NO_REGEX   (1 << 12) /* Don't use regular expressions */
36340472e4delphij#define SRCH_FILTER     (1 << 13) /* Search is for '&' (filter) command */
3646ea5918delphij#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
3651b28029ps
3661b28029ps#define	SRCH_REVERSE(t)	(((t) & SRCH_FORW) ? \
3671b28029ps				(((t) & ~SRCH_FORW) | SRCH_BACK) : \
3681b28029ps				(((t) & ~SRCH_BACK) | SRCH_FORW))
3691b28029ps
3701b28029ps/* */
3711b28029ps#define	NO_MCA		0
3721b28029ps#define	MCA_DONE	1
3731b28029ps#define	MCA_MORE	2
3741b28029ps
3751b28029ps#define	CC_OK		0	/* Char was accepted & processed */
3761b28029ps#define	CC_QUIT		1	/* Char was a request to abort current cmd */
3771b28029ps#define	CC_ERROR	2	/* Char could not be accepted due to error */
3781b28029ps#define	CC_PASS		3	/* Char was rejected (internal) */
3791b28029ps
3801b28029ps#define CF_QUIT_ON_ERASE 0001   /* Abort cmd if its entirely erased */
3811b28029ps
3825297f4bdelphij/* Special char bit-flags used to tell put_line() to do something special */
3831b28029ps#define	AT_NORMAL	(0)
3845297f4bdelphij#define	AT_UNDERLINE	(1 << 0)
3855297f4bdelphij#define	AT_BOLD		(1 << 1)
3865297f4bdelphij#define	AT_BLINK	(1 << 2)
3875297f4bdelphij#define	AT_STANDOUT	(1 << 3)
3885297f4bdelphij#define	AT_ANSI		(1 << 4)  /* Content-supplied "ANSI" escape sequence */
3895297f4bdelphij#define	AT_BINARY	(1 << 5)  /* LESS*BINFMT representation */
3905297f4bdelphij#define	AT_HILITE	(1 << 6)  /* Internal highlights (e.g., for search) */
3911b28029ps
392c0c85bcps#if '0' == 240
393c0c85bcps#define IS_EBCDIC_HOST 1
394c0c85bcps#endif
395c0c85bcps
3961b28029ps#if IS_EBCDIC_HOST
3971b28029ps/*
3981b28029ps * Long definition for EBCDIC.
3991b28029ps * Since the argument is usually a constant, this macro normally compiles
4001b28029ps * into a constant.
4011b28029ps */
4021b28029ps#define CONTROL(c) ( \
4031b28029ps	(c)=='[' ? '\047' : \
4041b28029ps	(c)=='a' ? '\001' : \
4051b28029ps	(c)=='b' ? '\002' : \
4061b28029ps	(c)=='c' ? '\003' : \
4071b28029ps	(c)=='d' ? '\067' : \
4081b28029ps	(c)=='e' ? '\055' : \
4091b28029ps	(c)=='f' ? '\056' : \
4101b28029ps	(c)=='g' ? '\057' : \
4111b28029ps	(c)=='h' ? '\026' : \
4121b28029ps	(c)=='i' ? '\005' : \
4131b28029ps	(c)=='j' ? '\025' : \
4141b28029ps	(c)=='k' ? '\013' : \
4151b28029ps	(c)=='l' ? '\014' : \
4161b28029ps	(c)=='m' ? '\015' : \
4171b28029ps	(c)=='n' ? '\016' : \
4181b28029ps	(c)=='o' ? '\017' : \
4191b28029ps	(c)=='p' ? '\020' : \
4201b28029ps	(c)=='q' ? '\021' : \
4211b28029ps	(c)=='r' ? '\022' : \
4221b28029ps	(c)=='s' ? '\023' : \
4231b28029ps	(c)=='t' ? '\074' : \
4241b28029ps	(c)=='u' ? '\075' : \
4251b28029ps	(c)=='v' ? '\062' : \
4261b28029ps	(c)=='w' ? '\046' : \
4271b28029ps	(c)=='x' ? '\030' : \
4281b28029ps	(c)=='y' ? '\031' : \
4291b28029ps	(c)=='z' ? '\077' : \
4301b28029ps	(c)=='A' ? '\001' : \
4311b28029ps	(c)=='B' ? '\002' : \
4321b28029ps	(c)=='C' ? '\003' : \
4331b28029ps	(c)=='D' ? '\067' : \
4341b28029ps	(c)=='E' ? '\055' : \
4351b28029ps	(c)=='F' ? '\056' : \
4361b28029ps	(c)=='G' ? '\057' : \
4371b28029ps	(c)=='H' ? '\026' : \
4381b28029ps	(c)=='I' ? '\005' : \
4391b28029ps	(c)=='J' ? '\025' : \
4401b28029ps	(c)=='K' ? '\013' : \
4411b28029ps	(c)=='L' ? '\014' : \
4421b28029ps	(c)=='M' ? '\015' : \
4431b28029ps	(c)=='N' ? '\016' : \
4441b28029ps	(c)=='O' ? '\017' : \
4451b28029ps	(c)=='P' ? '\020' : \
4461b28029ps	(c)=='Q' ? '\021' : \
4471b28029ps	(c)=='R' ? '\022' : \
4481b28029ps	(c)=='S' ? '\023' : \
4491b28029ps	(c)=='T' ? '\074' : \
4501b28029ps	(c)=='U' ? '\075' : \
4511b28029ps	(c)=='V' ? '\062' : \
4521b28029ps	(c)=='W' ? '\046' : \
4531b28029ps	(c)=='X' ? '\030' : \
4541b28029ps	(c)=='Y' ? '\031' : \
4551b28029ps	(c)=='Z' ? '\077' : \
4561b28029ps	(c)=='|' ? '\031' : \
4571b28029ps	(c)=='\\' ? '\034' : \
4581b28029ps	(c)=='^' ? '\036' : \
4591b28029ps	(c)&077)
4601b28029ps#else
4611b28029ps#define	CONTROL(c)	((c)&037)
4621b28029ps#endif /* IS_EBCDIC_HOST */
4631b28029ps
4641b28029ps#define	ESC		CONTROL('[')
465bdad060delphij#define	ESCS		"\33"
466aa9fcd7delphij#define	CSI		((unsigned char)'\233')
467479faf1delphij#define	CHAR_END_COMMAND 0x40000000
4681b28029ps
4691b28029ps#if _OSK_MWC32
4701b28029ps#define	LSIGNAL(sig,func)	os9_signal(sig,func)
4711b28029ps#else
4721b28029ps#define	LSIGNAL(sig,func)	signal(sig,func)
4731b28029ps#endif
4741b28029ps
4755d46577ps#if HAVE_SIGPROCMASK
4765d46577ps#if HAVE_SIGSET_T
4775d46577ps#else
4785d46577ps#undef HAVE_SIGPROCMASK
4795d46577ps#endif
4805d46577ps#endif
4815d46577ps#if HAVE_SIGPROCMASK
4825d46577ps#if HAVE_SIGEMPTYSET
4835d46577ps#else
4845d46577ps#undef  sigemptyset
4855d46577ps#define sigemptyset(mp) *(mp) = 0
4865d46577ps#endif
4875d46577ps#endif
4885d46577ps
4891b28029ps#define	S_INTERRUPT	01
4901b28029ps#define	S_STOP		02
4911b28029ps#define S_WINCH		04
4921b28029ps#define	ABORT_SIGS()	(sigs & (S_INTERRUPT|S_STOP))
4931b28029ps
4941b28029ps#define	QUIT_OK		0
4951b28029ps#define	QUIT_ERROR	1
4966ea5918delphij#define	QUIT_INTERRUPT	2
4971b28029ps#define	QUIT_SAVED_STATUS (-1)
4981b28029ps
499e2b0c4adelphij#define FOLLOW_DESC     0
500e2b0c4adelphij#define FOLLOW_NAME     1
501e2b0c4adelphij
5021b28029ps/* filestate flags */
5031b28029ps#define	CH_CANSEEK	001
5041b28029ps#define	CH_KEEPOPEN	002
5051b28029ps#define	CH_POPENED	004
5061b28029ps#define	CH_HELPFILE	010
5079185e49delphij#define	CH_NODATA  	020	/* Special case for zero length files */
5089185e49delphij
5091b28029ps#define	ch_zero()	((POSITION)0)
5101b28029ps
5111b28029ps#define	FAKE_HELPFILE	"@/\\less/\\help/\\file/\\@"
5129185e49delphij#define FAKE_EMPTYFILE	"@/\\less/\\empty/\\file/\\@"
5131b28029ps
514a169eabdelphij/* Flags for cvt_text */
515a169eabdelphij#define	CVT_TO_LC	01	/* Convert upper-case to lower-case */
516a169eabdelphij#define	CVT_BS		02	/* Do backspace processing */
517a169eabdelphij#define	CVT_CRLF	04	/* Remove CR after LF */
518a169eabdelphij#define	CVT_ANSI	010	/* Remove ANSI escape sequences */
519a169eabdelphij
520479faf1delphij#if HAVE_TIME_T
521479faf1delphij#define time_type	time_t
522479faf1delphij#else
523479faf1delphij#define	time_type	long
524479faf1delphij#endif
525479faf1delphij
526bdad060delphij/* X11 mouse reporting definitions */
527bdad060delphij#define X11MOUSE_BUTTON1    0 /* Left button press */
528bdad060delphij#define X11MOUSE_BUTTON2    1 /* Middle button press */
529bdad060delphij#define X11MOUSE_BUTTON3    2 /* Right button press */
530bdad060delphij#define X11MOUSE_BUTTON_REL 3 /* Button release */
531bdad060delphij#define X11MOUSE_WHEEL_UP   0x40 /* Wheel scroll up */
532bdad060delphij#define X11MOUSE_WHEEL_DOWN 0x41 /* Wheel scroll down */
533bdad060delphij#define X11MOUSE_OFFSET     0x20 /* Added to button & pos bytes to create a char */
534bdad060delphij
5351c120d2delphijstruct mlist;
5361c120d2delphijstruct loption;
5371c120d2delphijstruct hilite_tree;
5381c120d2delphij#include "pattern.h"
5391b28029ps#include "funcs.h"
5401b28029ps
54144c4d55tjr/* Functions not included in funcs.h */
54259c153ddelphijvoid postoa LESSPARAMS ((POSITION, char*));
54359c153ddelphijvoid linenumtoa LESSPARAMS ((LINENUM, char*));
54459c153ddelphijvoid inttoa LESSPARAMS ((int, char*));
545bdad060delphijint lstrtoi LESSPARAMS ((char*, char**));
546bdad060delphijPOSITION lstrtopos LESSPARAMS ((char*, char**));
547bdad060delphij#if MSDOS_COMPILER==WIN32C
548bdad060delphijint pclose LESSPARAMS ((FILE*));
549bdad060delphij#endif
550