1 /**************************************************************************** 2 * Copyright 2019-2020,2021 Thomas E. Dickey * 3 * Copyright 1998-2015,2017 Free Software Foundation, Inc. * 4 * * 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: * 12 * * 13 * The above copyright notice and this permission notice shall be included * 14 * in all copies or substantial portions of the Software. * 15 * * 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. * 23 * * 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 * 27 * authorization. * 28 ****************************************************************************/ 29 30 /**************************************************************************** 31 * Author: Thomas E. Dickey 1997-on * 32 ****************************************************************************/ 33 /* 34 * $Id: progs.priv.h,v 1.53 2021/06/26 20:43:19 tom Exp $ 35 * 36 * progs.priv.h 37 * 38 * Header file for curses utility programs 39 */ 40 41 #ifndef PROGS_PRIV_H 42 #define PROGS_PRIV_H 1 43 44 #include <ncurses_cfg.h> 45 46 #if USE_RCS_IDS 47 #define MODULE_ID(id) static const char Ident[] = id; 48 #else 49 #define MODULE_ID(id) /*nothing */ 50 #endif 51 52 #include <stdlib.h> 53 #include <ctype.h> 54 #include <string.h> 55 #include <sys/types.h> 56 57 #if HAVE_UNISTD_H 58 #include <unistd.h> 59 #endif 60 61 #if HAVE_LIMITS_H 62 # include <limits.h> 63 #elif HAVE_SYS_PARAM_H 64 # include <sys/param.h> 65 #endif 66 67 #if HAVE_DIRENT_H 68 # include <dirent.h> 69 # define NAMLEN(dirent) strlen((dirent)->d_name) 70 # if defined(_FILE_OFFSET_BITS) && defined(HAVE_STRUCT_DIRENT64) 71 # if !defined(_LP64) && (_FILE_OFFSET_BITS == 64) 72 # define DIRENT struct dirent64 73 # else 74 # define DIRENT struct dirent 75 # endif 76 # else 77 # define DIRENT struct dirent 78 # endif 79 #else 80 # define DIRENT struct direct 81 # define NAMLEN(dirent) (dirent)->d_namlen 82 # if HAVE_SYS_NDIR_H 83 # include <sys/ndir.h> 84 # endif 85 # if HAVE_SYS_DIR_H 86 # include <sys/dir.h> 87 # endif 88 # if HAVE_NDIR_H 89 # include <ndir.h> 90 # endif 91 #endif 92 93 #if HAVE_INTTYPES_H 94 # include <inttypes.h> 95 #else 96 # if HAVE_STDINT_H 97 # include <stdint.h> 98 # endif 99 #endif 100 101 #include <assert.h> 102 #include <errno.h> 103 104 #if DECL_ERRNO 105 extern int errno; 106 #endif 107 108 #if HAVE_GETOPT_H 109 #include <getopt.h> 110 #elif !defined(HAVE_GETOPT_HEADER) 111 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its 112 * variables doesn't hurt. 113 */ 114 extern char *optarg; 115 extern int optind; 116 #endif /* HAVE_GETOPT_H */ 117 118 #undef _NC_WINDOWS 119 #if (defined(_WIN32) || defined(_WIN64)) 120 #define _NC_WINDOWS 1 121 #endif 122 123 #define NCURSES_INTERNALS 1 124 #define NCURSES_OPAQUE 0 125 126 #include <curses.h> 127 128 #if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT)) 129 #undef KEY_EVENT /* reduce compiler-warnings with Visual C++ */ 130 #endif 131 132 #include <term_entry.h> 133 #include <nc_termios.h> 134 #include <tic.h> 135 #include <nc_tparm.h> 136 137 #include <nc_string.h> 138 #include <nc_alloc.h> 139 #include <nc_access.h> 140 141 #if HAVE_NC_FREEALL 142 #undef ExitProgram 143 #ifdef USE_LIBTINFO 144 #define ExitProgram(code) exit_terminfo(code) 145 #else 146 #define ExitProgram(code) _nc_free_tic(code) 147 #endif 148 #endif 149 150 #define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0)) 151 152 /* error-returns for tput */ 153 #define ErrUsage 2 154 #define ErrTermType 3 155 #define ErrCapName 4 156 #define ErrSystem(n) (4 + (n)) 157 158 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE) 159 #define IGNORE_RC(func) errno = (int) func 160 #else 161 #define IGNORE_RC(func) (void) func 162 #endif /* gcc workarounds */ 163 164 /* usually in <unistd.h> */ 165 #ifndef STDIN_FILENO 166 #define STDIN_FILENO 0 167 #endif 168 169 #ifndef STDOUT_FILENO 170 #define STDOUT_FILENO 1 171 #endif 172 173 #ifndef STDERR_FILENO 174 #define STDERR_FILENO 2 175 #endif 176 177 #ifndef EXIT_SUCCESS 178 #define EXIT_SUCCESS 0 179 #endif 180 181 #ifndef EXIT_FAILURE 182 #define EXIT_FAILURE 1 183 #endif 184 185 #ifndef R_OK 186 #define R_OK 4 /* Test for readable. */ 187 #endif 188 189 #ifndef W_OK 190 #define W_OK 2 /* Test for writable. */ 191 #endif 192 193 #ifndef X_OK 194 #define X_OK 1 /* Test for executable. */ 195 #endif 196 197 #ifndef F_OK 198 #define F_OK 0 /* Test for existence. */ 199 #endif 200 201 /* usually in <unistd.h> */ 202 #ifndef STDOUT_FILENO 203 #define STDOUT_FILENO 1 204 #endif 205 206 #ifndef STDERR_FILENO 207 #define STDERR_FILENO 2 208 #endif 209 210 /* may be in limits.h, included from various places */ 211 #ifndef PATH_MAX 212 # if defined(_POSIX_PATH_MAX) 213 # define PATH_MAX _POSIX_PATH_MAX 214 # elif defined(MAXPATHLEN) 215 # define PATH_MAX MAXPATHLEN 216 # else 217 # define PATH_MAX 255 /* the Posix minimum pathsize */ 218 # endif 219 #endif 220 221 /* We use isascii only to guard against use of 7-bit ctype tables in the 222 * isprint test in infocmp. 223 */ 224 #if !HAVE_ISASCII 225 # undef isascii 226 # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127) 227 # define isascii(c) (UChar(c) <= 127) 228 # else 229 # define isascii(c) 1 /* not really ascii anyway */ 230 # endif 231 #endif 232 233 #define UChar(c) ((unsigned char)(c)) 234 235 #define SIZEOF(v) (sizeof(v)/sizeof(v[0])) 236 237 #define NCURSES_EXT_NUMBERS (NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR) 238 239 #if NCURSES_EXT_NUMBERS 240 #else 241 #define _nc_free_termtype2(t) _nc_free_termtype(t) 242 #define _nc_read_entry2(n,f,t) _nc_read_entry(n,f,t) 243 #endif 244 245 #endif /* PROGS_PRIV_H */ 246