Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / zic / 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  * FreeBSD modifications: separate libc's privates from zic's.
12  * This makes it easier when we need to update one but not the other.
13  * I have removed all of the ifdef spaghetti which is not relevant to
14  * zic from this file.
15  *
16  * $FreeBSD: src/usr.sbin/zic/private.h,v 1.3 1999/08/28 01:21:18 peter Exp $
17  */
18
19 /*
20 ** This header is for use ONLY with the time conversion code.
21 ** There is no guarantee that it will remain unchanged,
22 ** or that it will remain at all.
23 ** Do NOT copy it to any system include directory.
24 ** Thank you!
25 */
26
27 /*
28 ** ID
29 */
30
31 #ifndef lint
32 #ifndef NOID
33 static char     privatehid[] = "@(#)private.h   7.48";
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_GETTEXT
43 #define HAVE_GETTEXT            0
44 #endif /* !defined HAVE_GETTEXT */
45
46 #ifndef HAVE_STRERROR
47 #define HAVE_STRERROR           1
48 #endif /* !defined HAVE_STRERROR */
49
50 #ifndef HAVE_SYMLINK
51 #define HAVE_SYMLINK            1
52 #endif /* !defined HAVE_SYMLINK */
53
54 #ifndef HAVE_UNISTD_H
55 #define HAVE_UNISTD_H           1
56 #endif /* !defined HAVE_UNISTD_H */
57
58 /*
59 ** Nested includes
60 */
61
62 #include "sys/types.h"  /* for time_t */
63 #include "stdio.h"
64 #include "errno.h"
65 #include "string.h"
66 #include "limits.h"     /* for CHAR_BIT */
67 #include "time.h"
68 #include "stdlib.h"
69
70 #if HAVE_GETTEXT - 0
71 #include "libintl.h"
72 #endif /* HAVE_GETTEXT - 0 */
73
74 #if HAVE_UNISTD_H - 0
75 #include "unistd.h"     /* for F_OK and R_OK */
76 #endif /* HAVE_UNISTD_H - 0 */
77
78 #if !(HAVE_UNISTD_H - 0)
79 #ifndef F_OK
80 #define F_OK    0
81 #endif /* !defined F_OK */
82 #ifndef R_OK
83 #define R_OK    4
84 #endif /* !defined R_OK */
85 #endif /* !(HAVE_UNISTD_H - 0) */
86
87 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
88 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
89
90 #define P(x) x
91
92 /*
93 ** Private function declarations.
94 */
95 char *  icalloc P((int nelem, int elsize));
96 char *  icatalloc P((char * old, const char * new));
97 char *  icpyalloc P((const char * string));
98 char *  imalloc P((int n));
99 void *  irealloc P((void * pointer, int size));
100 void    icfree P((char * pointer));
101 void    ifree P((char * pointer));
102 char *  scheck P((const char *string, const char *format));
103
104 /*
105 ** Finally, some convenience items.
106 */
107
108 #ifndef TRUE
109 #define TRUE    1
110 #endif /* !defined TRUE */
111
112 #ifndef FALSE
113 #define FALSE   0
114 #endif /* !defined FALSE */
115
116 #ifndef TYPE_BIT
117 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
118 #endif /* !defined TYPE_BIT */
119
120 #ifndef TYPE_SIGNED
121 #define TYPE_SIGNED(type) (((type) -1) < 0)
122 #endif /* !defined TYPE_SIGNED */
123
124 #ifndef INT_STRLEN_MAXIMUM
125 /*
126 ** 302 / 1000 is log10(2.0) rounded up.
127 ** Subtract one for the sign bit if the type is signed;
128 ** add one for integer division truncation;
129 ** add one more for a minus sign if the type is signed.
130 */
131 #define INT_STRLEN_MAXIMUM(type) \
132     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
133 #endif /* !defined INT_STRLEN_MAXIMUM */
134
135 /*
136 ** INITIALIZE(x)
137 */
138
139 #ifndef GNUC_or_lint
140 #ifdef lint
141 #define GNUC_or_lint
142 #endif /* defined lint */
143 #ifndef lint
144 #ifdef __GNUC__
145 #define GNUC_or_lint
146 #endif /* defined __GNUC__ */
147 #endif /* !defined lint */
148 #endif /* !defined GNUC_or_lint */
149
150 #ifndef INITIALIZE
151 #ifdef GNUC_or_lint
152 #define INITIALIZE(x)   ((x) = 0)
153 #endif /* defined GNUC_or_lint */
154 #ifndef GNUC_or_lint
155 #define INITIALIZE(x)
156 #endif /* !defined GNUC_or_lint */
157 #endif /* !defined INITIALIZE */
158
159 /*
160 ** For the benefit of GNU folk...
161 ** `_(MSGID)' uses the current locale's message library string for MSGID.
162 ** The default is to use gettext if available, and use MSGID otherwise.
163 */
164
165 #ifndef _
166 #if HAVE_GETTEXT - 0
167 #define _(msgid) gettext(msgid)
168 #else /* !(HAVE_GETTEXT - 0) */
169 #define _(msgid) msgid
170 #endif /* !(HAVE_GETTEXT - 0) */
171 #endif /* !defined _ */
172
173 #ifndef TZ_DOMAIN
174 #define TZ_DOMAIN "tz"
175 #endif /* !defined TZ_DOMAIN */
176
177 /*
178 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
179 */
180
181 #endif /* !defined PRIVATE_H */