.gitignore: properly spell cscope, add empty vim swap files
[dragonfly.git] / usr.sbin / zic / private.h
bloba33ea12cea4cbd7a27a5112676797f6f748d1df0
1 /*
2 * @(#)private.h 8.6
3 * $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $
4 * $DragonFly: src/usr.sbin/zic/private.h,v 1.4 2008/10/19 20:15:58 swildner Exp $
5 */
7 #ifndef PRIVATE_H
9 #define PRIVATE_H
11 ** This file is in the public domain, so clarified as of
12 ** 1996-06-05 by Arthur David Olson.
15 /* Stuff moved from Makefile.inc to reduce clutter */
16 #ifndef TM_GMTOFF
17 #define TM_GMTOFF tm_gmtoff
18 #define TM_ZONE tm_zone
19 #define TZDIR "/usr/share/zoneinfo"
20 #endif /* ndef TM_GMTOFF */
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!
30 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
33 ** Nested includes
36 #include "sys/types.h" /* for time_t */
37 #include "stdio.h"
38 #include "errno.h"
39 #include "string.h"
40 #include "limits.h" /* for CHAR_BIT et al. */
41 #include "time.h"
42 #include "stdlib.h"
44 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
46 #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
48 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
49 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
51 #include "stdint.h"
54 ** Private function declarations.
57 char * icalloc(int nelem, int elsize);
58 char * icatalloc(char * old, const char * new);
59 char * icpyalloc(const char * string);
60 char * imalloc(int n);
61 void * irealloc(void * pointer, int size);
62 void icfree(char * pointer);
63 void ifree(char * pointer);
64 const char * scheck(const char * string, const char * format);
67 ** Finally, some convenience items.
70 #ifndef TRUE
71 #define TRUE 1
72 #endif /* !defined TRUE */
74 #ifndef FALSE
75 #define FALSE 0
76 #endif /* !defined FALSE */
78 #ifndef TYPE_BIT
79 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
80 #endif /* !defined TYPE_BIT */
82 #ifndef TYPE_SIGNED
83 #define TYPE_SIGNED(type) (((type) -1) < 0)
84 #endif /* !defined TYPE_SIGNED */
87 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
88 ** it cannot be used in preprocessor directives.
91 #ifndef TYPE_INTEGRAL
92 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
93 #endif /* !defined TYPE_INTEGRAL */
95 #ifndef INT_STRLEN_MAXIMUM
97 ** 302 / 1000 is log10(2.0) rounded up.
98 ** Subtract one for the sign bit if the type is signed;
99 ** add one for integer division truncation;
100 ** add one more for a minus sign if the type is signed.
102 #define INT_STRLEN_MAXIMUM(type) \
103 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
104 1 + TYPE_SIGNED(type))
105 #endif /* !defined INT_STRLEN_MAXIMUM */
108 ** INITIALIZE(x)
111 #ifndef GNUC_or_lint
112 #ifdef lint
113 #define GNUC_or_lint
114 #endif /* defined lint */
115 #ifndef lint
116 #ifdef __GNUC__
117 #define GNUC_or_lint
118 #endif /* defined __GNUC__ */
119 #endif /* !defined lint */
120 #endif /* !defined GNUC_or_lint */
122 #ifndef INITIALIZE
123 #ifdef GNUC_or_lint
124 #define INITIALIZE(x) ((x) = 0)
125 #endif /* defined GNUC_or_lint */
126 #ifndef GNUC_or_lint
127 #define INITIALIZE(x)
128 #endif /* !defined GNUC_or_lint */
129 #endif /* !defined INITIALIZE */
132 ** For the benefit of GNU folk...
133 ** `_(MSGID)' uses the current locale's message library string for MSGID.
134 ** The default is to use gettext if available, and use MSGID otherwise.
137 #ifndef _
138 #define _(msgid) msgid
139 #endif /* !defined _ */
141 #ifndef TZ_DOMAIN
142 #define TZ_DOMAIN "tz"
143 #endif /* !defined TZ_DOMAIN */
145 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
148 ** UNIX was a registered trademark of The Open Group in 2003.
151 #endif /* !defined PRIVATE_H */