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