private.h revision 1.13 1 /* $NetBSD: private.h,v 1.13 1998/10/04 19:27:55 kleink Exp $ */
2
3 #ifndef PRIVATE_H
4 #define PRIVATE_H
5
6 /* NetBSD defaults */
7 #define TM_GMTOFF tm_gmtoff
8 #define TM_ZONE tm_zone
9 #define STD_INSPIRED 1
10 #define HAVE_LONG_DOUBLE 1
11
12 /*
13 ** This file is in the public domain, so clarified as of
14 ** 1996-06-05 by Arthur David Olson (arthur_david_olson (at) nih.gov).
15 */
16
17 /*
18 ** This header is for use ONLY with the time conversion code.
19 ** There is no guarantee that it will remain unchanged,
20 ** or that it will remain at all.
21 ** Do NOT copy it to any system include directory.
22 ** Thank you!
23 */
24
25 /*
26 ** ID
27 */
28
29 #ifndef lint
30 #ifndef NOID
31 #if 0
32 static char privatehid[] = "@(#)private.h 7.48";
33 #endif
34 #endif /* !defined NOID */
35 #endif /* !defined lint */
36
37 /*
38 ** Defaults for preprocessor symbols.
39 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
40 */
41
42 #ifndef HAVE_ADJTIME
43 #define HAVE_ADJTIME 1
44 #endif /* !defined HAVE_ADJTIME */
45
46 #ifndef HAVE_GETTEXT
47 #define HAVE_GETTEXT 0
48 #endif /* !defined HAVE_GETTEXT */
49
50 #ifndef HAVE_SETTIMEOFDAY
51 #define HAVE_SETTIMEOFDAY 3
52 #endif /* !defined HAVE_SETTIMEOFDAY */
53
54 #ifndef HAVE_STRERROR
55 #define HAVE_STRERROR 1
56 #endif /* !defined HAVE_STRERROR */
57
58 #ifndef HAVE_SYMLINK
59 #define HAVE_SYMLINK 1
60 #endif /* !defined HAVE_SYMLINK */
61
62 #ifndef HAVE_UNISTD_H
63 #define HAVE_UNISTD_H 1
64 #endif /* !defined HAVE_UNISTD_H */
65
66 #ifndef HAVE_UTMPX_H
67 #define HAVE_UTMPX_H 0
68 #endif /* !defined HAVE_UTMPX_H */
69
70 #ifndef LOCALE_HOME
71 #define LOCALE_HOME "/usr/lib/locale"
72 #endif /* !defined LOCALE_HOME */
73
74 /*
75 ** Nested includes
76 */
77
78 #include "sys/types.h" /* for time_t */
79 #include "stdio.h"
80 #include "errno.h"
81 #include "string.h"
82 #include "limits.h" /* for CHAR_BIT */
83 #include "time.h"
84 #include "stdlib.h"
85
86 #if HAVE_GETTEXT - 0
87 #include "libintl.h"
88 #endif /* HAVE_GETTEXT - 0 */
89
90 #if HAVE_UNISTD_H - 0
91 #include "unistd.h" /* for F_OK and R_OK */
92 #endif /* HAVE_UNISTD_H - 0 */
93
94 #if !(HAVE_UNISTD_H - 0)
95 #ifndef F_OK
96 #define F_OK 0
97 #endif /* !defined F_OK */
98 #ifndef R_OK
99 #define R_OK 4
100 #endif /* !defined R_OK */
101 #endif /* !(HAVE_UNISTD_H - 0) */
102
103 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
104 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
105
106 /*
107 ** Workarounds for compilers/systems.
108 */
109
110 /*
111 ** SunOS 4.1.1 cc lacks const.
112 */
113
114 #ifndef const
115 #ifndef __STDC__
116 #define const
117 #endif /* !defined __STDC__ */
118 #endif /* !defined const */
119
120 /*
121 ** SunOS 4.1.1 cc lacks prototypes.
122 */
123
124 #ifndef P
125 #ifdef __STDC__
126 #define P(x) x
127 #endif /* defined __STDC__ */
128 #ifndef __STDC__
129 #define P(x) ()
130 #endif /* !defined __STDC__ */
131 #endif /* !defined P */
132
133 /*
134 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
135 */
136
137 #ifndef EXIT_SUCCESS
138 #define EXIT_SUCCESS 0
139 #endif /* !defined EXIT_SUCCESS */
140
141 /*
142 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
143 */
144
145 #ifndef EXIT_FAILURE
146 #define EXIT_FAILURE 1
147 #endif /* !defined EXIT_FAILURE */
148
149 /*
150 ** SunOS 4.1.1 headers lack FILENAME_MAX.
151 */
152
153 #ifndef FILENAME_MAX
154
155 #ifndef MAXPATHLEN
156 #ifdef unix
157 #include "sys/param.h"
158 #endif /* defined unix */
159 #endif /* !defined MAXPATHLEN */
160
161 #ifdef MAXPATHLEN
162 #define FILENAME_MAX MAXPATHLEN
163 #endif /* defined MAXPATHLEN */
164 #ifndef MAXPATHLEN
165 #define FILENAME_MAX 1024 /* Pure guesswork */
166 #endif /* !defined MAXPATHLEN */
167
168 #endif /* !defined FILENAME_MAX */
169
170 /*
171 ** SunOS 4.1.1 libraries lack remove.
172 */
173
174 #ifndef remove
175 extern int unlink P((const char * filename));
176 #define remove unlink
177 #endif /* !defined remove */
178
179 /*
180 ** Some ancient errno.h implementations don't declare errno.
181 ** But some newer errno.h implementations define it as a macro.
182 ** Fix the former without affecting the latter.
183 */
184 #ifndef errno
185 extern int errno;
186 #endif /* !defined errno */
187
188 /*
189 ** Private function declarations.
190 */
191 char * icalloc P((int nelem, int elsize));
192 char * icatalloc P((char * old, const char * new));
193 char * icpyalloc P((const char * string));
194 char * imalloc P((int n));
195 void * irealloc P((void * pointer, int size));
196 void icfree P((char * pointer));
197 void ifree P((char * pointer));
198 char * scheck P((const char *string, const char *format));
199
200
201 /*
202 ** Finally, some convenience items.
203 */
204
205 #ifndef TRUE
206 #define TRUE 1
207 #endif /* !defined TRUE */
208
209 #ifndef FALSE
210 #define FALSE 0
211 #endif /* !defined FALSE */
212
213 #ifndef TYPE_BIT
214 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
215 #endif /* !defined TYPE_BIT */
216
217 #ifndef TYPE_SIGNED
218 #define TYPE_SIGNED(type) (((type) -1) < 0)
219 #endif /* !defined TYPE_SIGNED */
220
221 #ifndef INT_STRLEN_MAXIMUM
222 /*
223 ** 302 / 1000 is log10(2.0) rounded up.
224 ** Subtract one for the sign bit if the type is signed;
225 ** add one for integer division truncation;
226 ** add one more for a minus sign if the type is signed.
227 */
228 #define INT_STRLEN_MAXIMUM(type) \
229 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
230 #endif /* !defined INT_STRLEN_MAXIMUM */
231
232 /*
233 ** INITIALIZE(x)
234 */
235
236 #ifndef GNUC_or_lint
237 #ifdef lint
238 #define GNUC_or_lint
239 #endif /* defined lint */
240 #ifndef lint
241 #ifdef __GNUC__
242 #define GNUC_or_lint
243 #endif /* defined __GNUC__ */
244 #endif /* !defined lint */
245 #endif /* !defined GNUC_or_lint */
246
247 #ifndef INITIALIZE
248 #ifdef GNUC_or_lint
249 #define INITIALIZE(x) ((x) = 0)
250 #endif /* defined GNUC_or_lint */
251 #ifndef GNUC_or_lint
252 #define INITIALIZE(x)
253 #endif /* !defined GNUC_or_lint */
254 #endif /* !defined INITIALIZE */
255
256 /*
257 ** For the benefit of GNU folk...
258 ** `_(MSGID)' uses the current locale's message library string for MSGID.
259 ** The default is to use gettext if available, and use MSGID otherwise.
260 */
261
262 #ifndef _
263 #if HAVE_GETTEXT - 0
264 #define _(msgid) gettext(msgid)
265 #else /* !(HAVE_GETTEXT - 0) */
266 #define _(msgid) msgid
267 #endif /* !(HAVE_GETTEXT - 0) */
268 #endif /* !defined _ */
269
270 #ifndef TZ_DOMAIN
271 #define TZ_DOMAIN "tz"
272 #endif /* !defined TZ_DOMAIN */
273
274 /*
275 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
276 */
277
278 #endif /* !defined PRIVATE_H */
279