Fix bug in as-of mount date specification.
[dragonfly.git] / usr.sbin / zic / private.h
blob783795dc377556fd68a81c4024b4db246bc6fcc1
1 #ifndef PRIVATE_H
3 #define PRIVATE_H
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 */
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.
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.3 2004/02/29 16:55:28 joerg Exp $
19 * @(#)private.h 7.48
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!
31 ** ID
35 ** Defaults for preprocessor symbols.
36 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
39 #ifndef HAVE_GETTEXT
40 #define HAVE_GETTEXT 0
41 #endif /* !defined HAVE_GETTEXT */
43 #ifndef HAVE_STRERROR
44 #define HAVE_STRERROR 1
45 #endif /* !defined HAVE_STRERROR */
47 #ifndef HAVE_SYMLINK
48 #define HAVE_SYMLINK 1
49 #endif /* !defined HAVE_SYMLINK */
51 #ifndef HAVE_UNISTD_H
52 #define HAVE_UNISTD_H 1
53 #endif /* !defined HAVE_UNISTD_H */
56 ** Nested includes
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"
67 #if HAVE_GETTEXT - 0
68 #include "libintl.h"
69 #endif /* HAVE_GETTEXT - 0 */
71 #if HAVE_UNISTD_H - 0
72 #include "unistd.h" /* for F_OK and R_OK */
73 #endif /* HAVE_UNISTD_H - 0 */
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) */
84 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
85 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
88 ** Private function declarations.
90 char *icalloc(int nelem, int elsize);
91 char *icatalloc(char *old, const char *new);
92 char *icpyalloc(const char *string);
93 char *imalloc(int n);
94 void *irealloc(void * pointer, int size);
95 void icfree(char * pointer);
96 void ifree(char * pointer);
97 char *scheck(const char *string, const char *format);
100 ** Finally, some convenience items.
103 #ifndef TRUE
104 #define TRUE 1
105 #endif /* !defined TRUE */
107 #ifndef FALSE
108 #define FALSE 0
109 #endif /* !defined FALSE */
111 #ifndef TYPE_BIT
112 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
113 #endif /* !defined TYPE_BIT */
115 #ifndef TYPE_SIGNED
116 #define TYPE_SIGNED(type) (((type) -1) < 0)
117 #endif /* !defined TYPE_SIGNED */
119 #ifndef INT_STRLEN_MAXIMUM
121 ** 302 / 1000 is log10(2.0) rounded up.
122 ** Subtract one for the sign bit if the type is signed;
123 ** add one for integer division truncation;
124 ** add one more for a minus sign if the type is signed.
126 #define INT_STRLEN_MAXIMUM(type) \
127 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
128 #endif /* !defined INT_STRLEN_MAXIMUM */
131 ** INITIALIZE(x)
134 #ifndef GNUC_or_lint
135 #ifdef lint
136 #define GNUC_or_lint
137 #endif /* defined lint */
138 #ifndef lint
139 #ifdef __GNUC__
140 #define GNUC_or_lint
141 #endif /* defined __GNUC__ */
142 #endif /* !defined lint */
143 #endif /* !defined GNUC_or_lint */
145 #ifndef INITIALIZE
146 #ifdef GNUC_or_lint
147 #define INITIALIZE(x) ((x) = 0)
148 #endif /* defined GNUC_or_lint */
149 #ifndef GNUC_or_lint
150 #define INITIALIZE(x)
151 #endif /* !defined GNUC_or_lint */
152 #endif /* !defined INITIALIZE */
155 ** For the benefit of GNU folk...
156 ** `_(MSGID)' uses the current locale's message library string for MSGID.
157 ** The default is to use gettext if available, and use MSGID otherwise.
160 #ifndef _
161 #if HAVE_GETTEXT - 0
162 #define _(msgid) gettext(msgid)
163 #else /* !(HAVE_GETTEXT - 0) */
164 #define _(msgid) msgid
165 #endif /* !(HAVE_GETTEXT - 0) */
166 #endif /* !defined _ */
168 #ifndef TZ_DOMAIN
169 #define TZ_DOMAIN "tz"
170 #endif /* !defined TZ_DOMAIN */
173 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
176 #endif /* !defined PRIVATE_H */