1 /**************************************************************************** 2 * Copyright (c) 1998 Free Software Foundation, Inc. * 3 * * 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: * 11 * * 12 * The above copyright notice and this permission notice shall be included * 13 * in all copies or substantial portions of the Software. * 14 * * 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. * 22 * * 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 * 26 * authorization. * 27 ****************************************************************************/ 28 29 /**************************************************************************** 30 * Author: Thomas E. Dickey <dickey@clark.net> 1997,1998 * 31 ****************************************************************************/ 32 /* 33 * $Id: progs.priv.h,v 1.19 1999/02/23 11:10:32 tom Exp $ 34 * 35 * progs.priv.h 36 * 37 * Header file for curses utility programs 38 */ 39 40 #include <ncurses_cfg.h> 41 42 #ifdef USE_RCS_IDS 43 #define MODULE_ID(id) static const char Ident[] = id; 44 #else 45 #define MODULE_ID(id) /*nothing*/ 46 #endif 47 48 #include <stdlib.h> 49 #include <ctype.h> 50 #include <string.h> 51 #include <sys/types.h> 52 53 #if HAVE_UNISTD_H 54 #include <unistd.h> 55 #else 56 # if HAVE_LIBC_H 57 # include <libc.h> 58 # endif 59 #endif 60 61 #if HAVE_SYS_BSDTYPES_H 62 #include <sys/bsdtypes.h> /* needed for ISC */ 63 #endif 64 65 #if HAVE_LIMITS_H 66 # include <limits.h> 67 #elif HAVE_SYS_PARAM_H 68 # include <sys/param.h> 69 #endif 70 71 #if HAVE_DIRENT_H 72 # include <dirent.h> 73 # define NAMLEN(dirent) strlen((dirent)->d_name) 74 #else 75 # define dirent direct 76 # define NAMLEN(dirent) (dirent)->d_namlen 77 # if HAVE_SYS_NDIR_H 78 # include <sys/ndir.h> 79 # endif 80 # if HAVE_SYS_DIR_H 81 # include <sys/dir.h> 82 # endif 83 # if HAVE_NDIR_H 84 # include <ndir.h> 85 # endif 86 #endif 87 88 #include <errno.h> 89 90 #if DECL_ERRNO 91 extern int errno; 92 #endif 93 94 #if HAVE_GETOPT_H 95 #include <getopt.h> 96 #else 97 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its 98 * variables doesn't hurt. 99 */ 100 extern char *optarg; 101 extern int optind; 102 #endif /* HAVE_GETOPT_H */ 103 104 #include <curses.h> 105 #include <term_entry.h> 106 #include <tic.h> 107 #include <nc_alloc.h> 108 109 /* usually in <unistd.h> */ 110 #ifndef STDOUT_FILENO 111 #define STDOUT_FILENO 1 112 #endif 113 114 #ifndef STDERR_FILENO 115 #define STDERR_FILENO 2 116 #endif 117 118 #ifndef EXIT_SUCCESS 119 #define EXIT_SUCCESS 0 120 #endif 121 122 #ifndef EXIT_FAILURE 123 #define EXIT_FAILURE 1 124 #endif 125 126 #ifndef F_OK 127 #define F_OK 0 /* Test for existence. */ 128 #endif 129 130 /* usually in <unistd.h> */ 131 #ifndef STDOUT_FILENO 132 #define STDOUT_FILENO 1 133 #endif 134 135 #ifndef STDERR_FILENO 136 #define STDERR_FILENO 2 137 #endif 138 139 /* may be in limits.h, included from various places */ 140 #ifndef PATH_MAX 141 # if defined(_POSIX_PATH_MAX) 142 # define PATH_MAX _POSIX_PATH_MAX 143 # elif defined(MAXPATHLEN) 144 # define PATH_MAX MAXPATHLEN 145 # else 146 # define PATH_MAX 255 /* the Posix minimum pathsize */ 147 # endif 148 #endif 149 150 /* We use isascii only to guard against use of 7-bit ctype tables in the 151 * isprint test in infocmp. 152 */ 153 #ifndef HAVE_ISASCII 154 # undef isascii 155 # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127) 156 # define isascii(c) (((c) & 0xff) <= 127) 157 # else 158 # define isascii(c) 1 /* not really ascii anyway */ 159 # endif 160 #endif 161