1 /****************************************************************************
2 * Copyright (c) 1998-2017,2019 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey 1997-on *
31 ****************************************************************************/
33 * $Id: progs.priv.h,v 1.47 2019/12/14 23:53:12 tom Exp $
37 * Header file for curses utility programs
41 #define PROGS_PRIV_H 1
43 #include <ncurses_cfg.h>
46 #define MODULE_ID(id) static const char Ident[] = id;
48 #define MODULE_ID(id) /*nothing */
54 #include <sys/types.h>
60 #if HAVE_SYS_BSDTYPES_H
61 #include <sys/bsdtypes.h> /* needed for ISC */
66 #elif HAVE_SYS_PARAM_H
67 # include <sys/param.h>
72 # define NAMLEN(dirent) strlen((dirent)->d_name)
73 # if defined(_FILE_OFFSET_BITS) && defined(HAVE_STRUCT_DIRENT64)
74 # if !defined(_LP64) && (_FILE_OFFSET_BITS == 64)
75 # define DIRENT struct dirent64
77 # define DIRENT struct dirent
80 # define DIRENT struct dirent
83 # define DIRENT struct direct
84 # define NAMLEN(dirent) (dirent)->d_namlen
86 # include <sys/ndir.h>
97 # include <inttypes.h>
113 #elif !defined(HAVE_GETOPT_HEADER)
114 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
115 * variables doesn't hurt.
119 #endif /* HAVE_GETOPT_H */
121 #define NCURSES_INTERNALS 1
122 #define NCURSES_OPAQUE 0
125 #include <term_entry.h>
126 #include <nc_termios.h>
128 #include <nc_tparm.h>
130 #include <nc_string.h>
131 #include <nc_alloc.h>
136 #define ExitProgram(code) exit_terminfo(code)
138 #define ExitProgram(code) _nc_free_tic(code)
142 #define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
144 /* error-returns for tput */
146 #define ErrTermType 3
148 #define ErrSystem(n) (4 + (n))
150 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
151 #define IGNORE_RC(func) errno = (int) func
153 #define IGNORE_RC(func) (void) func
154 #endif /* gcc workarounds */
156 /* usually in <unistd.h> */
157 #ifndef STDOUT_FILENO
158 #define STDOUT_FILENO 1
161 #ifndef STDERR_FILENO
162 #define STDERR_FILENO 2
166 #define EXIT_SUCCESS 0
170 #define EXIT_FAILURE 1
174 #define R_OK 4 /* Test for readable. */
178 #define W_OK 2 /* Test for writable. */
182 #define X_OK 1 /* Test for executable. */
186 #define F_OK 0 /* Test for existence. */
189 /* usually in <unistd.h> */
190 #ifndef STDOUT_FILENO
191 #define STDOUT_FILENO 1
194 #ifndef STDERR_FILENO
195 #define STDERR_FILENO 2
198 /* may be in limits.h, included from various places */
200 # if defined(_POSIX_PATH_MAX)
201 # define PATH_MAX _POSIX_PATH_MAX
202 # elif defined(MAXPATHLEN)
203 # define PATH_MAX MAXPATHLEN
205 # define PATH_MAX 255 /* the Posix minimum pathsize */
209 /* We use isascii only to guard against use of 7-bit ctype tables in the
210 * isprint test in infocmp.
214 # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
215 # define isascii(c) (UChar(c) <= 127)
217 # define isascii(c) 1 /* not really ascii anyway */
221 #define UChar(c) ((unsigned char)(c))
223 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
225 #define NCURSES_EXT_NUMBERS (NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR)
227 #if NCURSES_EXT_NUMBERS
229 #define _nc_free_termtype2(t) _nc_free_termtype(t)
230 #define _nc_read_entry2(n,f,t) _nc_read_entry(n,f,t)
233 #endif /* PROGS_PRIV_H */