1 | /****************************************************************************
|
---|
2 | * Copyright (c) 1998-2001,2005 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 1997-on *
|
---|
31 | ****************************************************************************/
|
---|
32 | /*
|
---|
33 | * $Id: progs.priv.h,v 1.29 2005/08/06 20:05: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 | #if 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 | #endif
|
---|
56 |
|
---|
57 | #if HAVE_SYS_BSDTYPES_H
|
---|
58 | #include <sys/bsdtypes.h> /* needed for ISC */
|
---|
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 | #include <errno.h>
|
---|
94 |
|
---|
95 | #if DECL_ERRNO
|
---|
96 | extern int errno;
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | #if HAVE_GETOPT_H
|
---|
100 | #include <getopt.h>
|
---|
101 | #else
|
---|
102 | /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
|
---|
103 | * variables doesn't hurt.
|
---|
104 | */
|
---|
105 | extern char *optarg;
|
---|
106 | extern int optind;
|
---|
107 | #endif /* HAVE_GETOPT_H */
|
---|
108 |
|
---|
109 | #include <curses.h>
|
---|
110 | #include <term_entry.h>
|
---|
111 | #include <tic.h>
|
---|
112 | #include <nc_alloc.h>
|
---|
113 |
|
---|
114 | /* usually in <unistd.h> */
|
---|
115 | #ifndef STDOUT_FILENO
|
---|
116 | #define STDOUT_FILENO 1
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | #ifndef STDERR_FILENO
|
---|
120 | #define STDERR_FILENO 2
|
---|
121 | #endif
|
---|
122 |
|
---|
123 | #ifndef EXIT_SUCCESS
|
---|
124 | #define EXIT_SUCCESS 0
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | #ifndef EXIT_FAILURE
|
---|
128 | #define EXIT_FAILURE 1
|
---|
129 | #endif
|
---|
130 |
|
---|
131 | #ifndef R_OK
|
---|
132 | #define R_OK 4 /* Test for readable. */
|
---|
133 | #endif
|
---|
134 |
|
---|
135 | #ifndef W_OK
|
---|
136 | #define W_OK 2 /* Test for writable. */
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | #ifndef X_OK
|
---|
140 | #define X_OK 1 /* Test for executable. */
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | #ifndef F_OK
|
---|
144 | #define F_OK 0 /* Test for existence. */
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | /* usually in <unistd.h> */
|
---|
148 | #ifndef STDOUT_FILENO
|
---|
149 | #define STDOUT_FILENO 1
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | #ifndef STDERR_FILENO
|
---|
153 | #define STDERR_FILENO 2
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | /* may be in limits.h, included from various places */
|
---|
157 | #ifndef PATH_MAX
|
---|
158 | # if defined(_POSIX_PATH_MAX)
|
---|
159 | # define PATH_MAX _POSIX_PATH_MAX
|
---|
160 | # elif defined(MAXPATHLEN)
|
---|
161 | # define PATH_MAX MAXPATHLEN
|
---|
162 | # else
|
---|
163 | # define PATH_MAX 255 /* the Posix minimum pathsize */
|
---|
164 | # endif
|
---|
165 | #endif
|
---|
166 |
|
---|
167 | /* We use isascii only to guard against use of 7-bit ctype tables in the
|
---|
168 | * isprint test in infocmp.
|
---|
169 | */
|
---|
170 | #if !HAVE_ISASCII
|
---|
171 | # undef isascii
|
---|
172 | # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
|
---|
173 | # define isascii(c) (UChar(c) <= 127)
|
---|
174 | # else
|
---|
175 | # define isascii(c) 1 /* not really ascii anyway */
|
---|
176 | # endif
|
---|
177 | #endif
|
---|
178 |
|
---|
179 | #define UChar(c) ((unsigned char)(c))
|
---|
180 |
|
---|
181 | #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
|
---|