1 /****************************************************************************
2 * Copyright 2019,2020 Thomas E. Dickey *
3 * Copyright 1998-2015,2017 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Thomas E. Dickey 1997-on *
32 ****************************************************************************/
34 * $Id: progs.priv.h,v 1.49 2020/02/29 20:57:36 tom Exp $
38 * Header file for curses utility programs
42 #define PROGS_PRIV_H 1
44 #include <ncurses_cfg.h>
47 #define MODULE_ID(id) static const char Ident[] = id;
49 #define MODULE_ID(id) /*nothing */
55 #include <sys/types.h>
61 #if HAVE_SYS_BSDTYPES_H
62 #include <sys/bsdtypes.h> /* needed for ISC */
67 #elif HAVE_SYS_PARAM_H
68 # include <sys/param.h>
73 # define NAMLEN(dirent) strlen((dirent)->d_name)
74 # if defined(_FILE_OFFSET_BITS) && defined(HAVE_STRUCT_DIRENT64)
75 # if !defined(_LP64) && (_FILE_OFFSET_BITS == 64)
76 # define DIRENT struct dirent64
78 # define DIRENT struct dirent
81 # define DIRENT struct dirent
84 # define DIRENT struct direct
85 # define NAMLEN(dirent) (dirent)->d_namlen
87 # include <sys/ndir.h>
98 # include <inttypes.h>
114 #elif !defined(HAVE_GETOPT_HEADER)
115 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
116 * variables doesn't hurt.
120 #endif /* HAVE_GETOPT_H */
122 #define NCURSES_INTERNALS 1
123 #define NCURSES_OPAQUE 0
126 #include <term_entry.h>
127 #include <nc_termios.h>
129 #include <nc_tparm.h>
131 #include <nc_string.h>
132 #include <nc_alloc.h>
137 #define ExitProgram(code) exit_terminfo(code)
139 #define ExitProgram(code) _nc_free_tic(code)
143 #define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
145 /* error-returns for tput */
147 #define ErrTermType 3
149 #define ErrSystem(n) (4 + (n))
151 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
152 #define IGNORE_RC(func) errno = (int) func
154 #define IGNORE_RC(func) (void) func
155 #endif /* gcc workarounds */
157 /* usually in <unistd.h> */
159 #define STDIN_FILENO 0
162 #ifndef STDOUT_FILENO
163 #define STDOUT_FILENO 1
166 #ifndef STDERR_FILENO
167 #define STDERR_FILENO 2
171 #define EXIT_SUCCESS 0
175 #define EXIT_FAILURE 1
179 #define R_OK 4 /* Test for readable. */
183 #define W_OK 2 /* Test for writable. */
187 #define X_OK 1 /* Test for executable. */
191 #define F_OK 0 /* Test for existence. */
194 /* usually in <unistd.h> */
195 #ifndef STDOUT_FILENO
196 #define STDOUT_FILENO 1
199 #ifndef STDERR_FILENO
200 #define STDERR_FILENO 2
203 /* may be in limits.h, included from various places */
205 # if defined(_POSIX_PATH_MAX)
206 # define PATH_MAX _POSIX_PATH_MAX
207 # elif defined(MAXPATHLEN)
208 # define PATH_MAX MAXPATHLEN
210 # define PATH_MAX 255 /* the Posix minimum pathsize */
214 /* We use isascii only to guard against use of 7-bit ctype tables in the
215 * isprint test in infocmp.
219 # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
220 # define isascii(c) (UChar(c) <= 127)
222 # define isascii(c) 1 /* not really ascii anyway */
226 #define UChar(c) ((unsigned char)(c))
228 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
230 #define NCURSES_EXT_NUMBERS (NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR)
232 #if NCURSES_EXT_NUMBERS
234 #define _nc_free_termtype2(t) _nc_free_termtype(t)
235 #define _nc_read_entry2(n,f,t) _nc_read_entry(n,f,t)
238 #endif /* PROGS_PRIV_H */