xref: /openbsd-src/usr.bin/tic/progs.priv.h (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: progs.priv.h,v 1.8 2001/01/22 18:02:20 millert Exp $	*/
2 
3 /****************************************************************************
4  * Copyright (c) 1998-2000 Free Software Foundation, Inc.                   *
5  *                                                                          *
6  * Permission is hereby granted, free of charge, to any person obtaining a  *
7  * copy of this software and associated documentation files (the            *
8  * "Software"), to deal in the Software without restriction, including      *
9  * without limitation the rights to use, copy, modify, merge, publish,      *
10  * distribute, distribute with modifications, sublicense, and/or sell       *
11  * copies of the Software, and to permit persons to whom the Software is    *
12  * furnished to do so, subject to the following conditions:                 *
13  *                                                                          *
14  * The above copyright notice and this permission notice shall be included  *
15  * in all copies or substantial portions of the Software.                   *
16  *                                                                          *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24  *                                                                          *
25  * Except as contained in this notice, the name(s) of the above copyright   *
26  * holders shall not be used in advertising or otherwise to promote the     *
27  * sale, use or other dealings in this Software without prior written       *
28  * authorization.                                                           *
29  ****************************************************************************/
30 
31 /****************************************************************************
32  *  Author: Thomas E. Dickey <dickey@clark.net> 1997,1998                   *
33  ****************************************************************************/
34 /*
35  * $From: progs.priv.h,v 1.26 2000/11/05 00:22:05 tom Exp $
36  *
37  *	progs.priv.h
38  *
39  *	Header file for curses utility programs
40  */
41 
42 #include <ncurses_cfg.h>
43 
44 #if USE_RCS_IDS
45 #define MODULE_ID(id) static const char Ident[] = id;
46 #else
47 #define MODULE_ID(id) /*nothing*/
48 #endif
49 
50 #include <stdlib.h>
51 #include <ctype.h>
52 #include <string.h>
53 #include <sys/types.h>
54 
55 #if HAVE_UNISTD_H
56 #include <unistd.h>
57 #else
58 # if HAVE_LIBC_H
59 # include <libc.h>
60 # endif
61 #endif
62 
63 #if HAVE_SYS_BSDTYPES_H
64 #include <sys/bsdtypes.h>	/* needed for ISC */
65 #endif
66 
67 #if HAVE_LIMITS_H
68 # include <limits.h>
69 #elif HAVE_SYS_PARAM_H
70 # include <sys/param.h>
71 #endif
72 
73 #if HAVE_DIRENT_H
74 # include <dirent.h>
75 # define NAMLEN(dirent) strlen((dirent)->d_name)
76 #else
77 # define dirent direct
78 # define NAMLEN(dirent) (dirent)->d_namlen
79 # if HAVE_SYS_NDIR_H
80 #  include <sys/ndir.h>
81 # endif
82 # if HAVE_SYS_DIR_H
83 #  include <sys/dir.h>
84 # endif
85 # if HAVE_NDIR_H
86 #  include <ndir.h>
87 # endif
88 #endif
89 
90 #include <errno.h>
91 
92 #if DECL_ERRNO
93 extern int errno;
94 #endif
95 
96 #if HAVE_GETOPT_H
97 #include <getopt.h>
98 #else
99 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
100  * variables doesn't hurt.
101  */
102 extern char *optarg;
103 extern int optind;
104 #endif /* HAVE_GETOPT_H */
105 
106 #include <curses.h>
107 #include <term_entry.h>
108 #include <tic.h>
109 #include <nc_alloc.h>
110 
111 /* usually in <unistd.h> */
112 #ifndef STDOUT_FILENO
113 #define STDOUT_FILENO 1
114 #endif
115 
116 #ifndef STDERR_FILENO
117 #define STDERR_FILENO 2
118 #endif
119 
120 #ifndef EXIT_SUCCESS
121 #define EXIT_SUCCESS 0
122 #endif
123 
124 #ifndef EXIT_FAILURE
125 #define EXIT_FAILURE 1
126 #endif
127 
128 #ifndef R_OK
129 #define	R_OK	4		/* Test for readable.  */
130 #endif
131 
132 #ifndef W_OK
133 #define	W_OK	2		/* Test for writable.  */
134 #endif
135 
136 #ifndef X_OK
137 #define	X_OK	1		/* Test for executable.  */
138 #endif
139 
140 #ifndef F_OK
141 #define	F_OK	0		/* Test for existence.  */
142 #endif
143 
144 /* usually in <unistd.h> */
145 #ifndef STDOUT_FILENO
146 #define STDOUT_FILENO 1
147 #endif
148 
149 #ifndef STDERR_FILENO
150 #define STDERR_FILENO 2
151 #endif
152 
153 /* may be in limits.h, included from various places */
154 #ifndef PATH_MAX
155 # if defined(_POSIX_PATH_MAX)
156 #  define PATH_MAX _POSIX_PATH_MAX
157 # elif defined(MAXPATHLEN)
158 #  define PATH_MAX MAXPATHLEN
159 # else
160 #  define PATH_MAX 255	/* the Posix minimum pathsize */
161 # endif
162 #endif
163 
164 /* We use isascii only to guard against use of 7-bit ctype tables in the
165  * isprint test in infocmp.
166  */
167 #if !HAVE_ISASCII
168 # undef isascii
169 # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
170 #  define isascii(c) (CharOf(c) <= 127)
171 # else
172 #  define isascii(c) 1	/* not really ascii anyway */
173 # endif
174 #endif
175 
176 #define CharOf(c)    ((unsigned char)(c))
177 
178 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
179