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