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