Annotation of src/usr.bin/less/less.h, Revision 1.3
1.3 ! niklas 1: /* $OpenBSD$ */
! 2:
1.1 etheisen 3: /*
4: * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice in the documentation and/or other materials provided with
14: * the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
17: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
20: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22: * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23: * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26: * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27: */
28:
29:
30: /*
31: * Standard include file for "less".
32: */
33:
34: /*
35: * Include the file of compile-time options.
36: * The <> make cc search for it in -I., not srcdir.
37: */
38: #include <defines.h>
39:
40: #ifdef _SEQUENT_
41: /*
42: * Kludge for Sequent Dynix systems that have sigsetmask, but
43: * it's not compatible with the way less calls it.
44: * {{ Do other systems need this? }}
45: */
46: #undef HAVE_SIGSETMASK
47: #endif
48:
49: /*
50: * Language details.
51: */
52: #if HAVE_VOID
53: #define VOID_POINTER void *
54: #else
55: #define VOID_POINTER char *
56: #define void int
57: #endif
58:
59: #define public /* PUBLIC FUNCTION */
60:
61: /* Library function declarations */
62:
63: #if HAVE_SYS_TYPES_H
64: #include <sys/types.h>
65: #endif
66: #if HAVE_STDIO_H
67: #include <stdio.h>
68: #endif
69: #if HAVE_FCNTL_H
70: #include <fcntl.h>
71: #endif
72: #if HAVE_UNISTD_H
73: #include <unistd.h>
74: #endif
75: #if HAVE_CTYPE_H
76: #include <ctype.h>
77: #endif
78: #if STDC_HEADERS
79: #include <stdlib.h>
80: #include <string.h>
81: #endif
82:
83: #if !STDC_HEADERS
84: char *getenv();
85: off_t lseek();
86: VOID_POINTER calloc();
87: void free();
88: #endif
89:
90: #if !HAVE_UPPER_LOWER
91: #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
92: #define islower(c) ((c) >= 'a' && (c) <= 'z')
93: #define toupper(c) ((c) - 'a' + 'A')
94: #define tolower(c) ((c) - 'A' + 'a')
95: #endif
96:
97: #ifndef NULL
98: #define NULL 0
99: #endif
100:
101: #ifndef TRUE
102: #define TRUE 1
103: #endif
104: #ifndef FALSE
105: #define FALSE 0
106: #endif
107:
108: #define OPT_OFF 0
109: #define OPT_ON 1
110: #define OPT_ONPLUS 2
111:
112: #ifndef HAVE_MEMCPY
113: #ifndef memcpy
114: #define memcpy(to,from,len) bcopy((from),(to),(len))
115: #endif
116: #endif
117:
118: #define BAD_LSEEK ((off_t)-1)
119:
120: /*
121: * Special types and constants.
122: */
1.2 millert 123: typedef off_t POSITION;
1.1 etheisen 124: /*
125: * {{ Warning: if POSITION is changed to other than "long",
126: * you may have to change some of the printfs which use "%ld"
127: * to print a variable of type POSITION. }}
128: */
129:
130: #define NULL_POSITION ((POSITION)(-1))
131:
132: /*
133: * Flags for open()
134: */
135: #if MSOFTC || OS2
136: #define OPEN_READ (O_RDONLY|O_BINARY)
137: #else
138: #define OPEN_READ (0)
139: #endif
140: #if MSOFTC || OS2
141: #define OPEN_APPEND (O_APPEND|O_WRONLY)
142: #else
143: #define OPEN_APPEND (1)
144: #endif
145:
146: #if MSOFTC || OS2
147: #define OPEN_TTYIN() open("CON", O_BINARY|O_RDONLY)
148: #else
149: #define OPEN_TTYIN() open("/dev/tty", 0)
150: #endif
151:
152: /*
153: * An IFILE represents an input file.
154: */
155: #define IFILE VOID_POINTER
156: #define NULL_IFILE ((IFILE)NULL)
157:
158: /*
159: * The structure used to represent a "screen position".
160: * This consists of a file position, and a screen line number.
161: * The meaning is that the line starting at the given file
162: * position is displayed on the ln-th line of the screen.
163: * (Screen lines before ln are empty.)
164: */
165: struct scrpos
166: {
167: POSITION pos;
168: int ln;
169: };
170:
171: typedef union parg
172: {
173: char *p_string;
174: int p_int;
175: } PARG;
176:
177: #define NULL_PARG ((PARG *)NULL)
178:
179: struct textlist
180: {
181: char *string;
182: char *endstring;
183: };
184:
185: #define EOI (-1)
186:
187: #define READ_INTR (-2)
188:
189: /* How quiet should we be? */
190: #define NOT_QUIET 0 /* Ring bell at eof and for errors */
191: #define LITTLE_QUIET 1 /* Ring bell only for errors */
192: #define VERY_QUIET 2 /* Never ring bell */
193:
194: /* How should we prompt? */
195: #define PR_SHORT 0 /* Prompt with colon */
196: #define PR_MEDIUM 1 /* Prompt with message */
197: #define PR_LONG 2 /* Prompt with longer message */
198:
199: /* How should we handle backspaces? */
200: #define BS_SPECIAL 0 /* Do special things for underlining and bold */
201: #define BS_NORMAL 1 /* \b treated as normal char; actually output */
202: #define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
203:
204: /* How should we search? */
205: #define SRCH_FORW 0001 /* Search forward from current position */
206: #define SRCH_BACK 0002 /* Search backward from current position */
207: #define SRCH_FIND_ALL 0010 /* Find and highlight all matches */
208: #define SRCH_NOMATCH 0100 /* Search for non-matching lines */
209: #define SRCH_PAST_EOF 0200 /* Search past end-of-file, into next file */
210: #define SRCH_FIRST_FILE 0400 /* Search starting at the first file */
211:
212: #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
213: (((t) & ~SRCH_FORW) | SRCH_BACK) : \
214: (((t) & ~SRCH_BACK) | SRCH_FORW))
215:
216: /* */
217: #define NO_MCA 0
218: #define MCA_DONE 1
219: #define MCA_MORE 2
220:
221: #define CC_OK 0 /* Char was accepted & processed */
222: #define CC_QUIT 1 /* Char was a request to abort current cmd */
223: #define CC_ERROR 2 /* Char could not be accepted due to error */
224: #define CC_PASS 3 /* Char was rejected (internal) */
225:
226: /* Special chars used to tell put_line() to do something special */
227: #define AT_NORMAL (0)
228: #define AT_UNDERLINE (1)
229: #define AT_BOLD (2)
230: #define AT_BLINK (3)
231: #define AT_INVIS (4)
232: #define AT_STANDOUT (5)
233:
234: #define CONTROL(c) ((c)&037)
235: #define ESC CONTROL('[')
236:
237: #define SIGNAL(sig,func) signal(sig,func)
238:
239: #define S_INTERRUPT 01
240: #define S_STOP 02
241: #define S_WINCH 04
242: #define ABORT_SIGS() (sigs & (S_INTERRUPT|S_STOP))
243:
244: #define QUIT_OK 0
245: #define QUIT_ERROR 1
246: #define QUIT_SAVED_STATUS (-1)
247:
248: /* filestate flags */
249: #define CH_CANSEEK 001
250: #define CH_KEEPOPEN 002
251: #define CH_POPENED 004
252:
253: #define ch_zero() ((POSITION)0)
254:
255: #include "funcs.h"