]> git.saurik.com Git - apple/system_cmds.git/blame - zic.tproj/private.h
system_cmds-433.8.tar.gz
[apple/system_cmds.git] / zic.tproj / private.h
CommitLineData
1815bff5
A
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
2fc1e207
A
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.7 2004/06/20 21:41:11 stefanf Exp $
17 */
1815bff5
A
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
1815bff5
A
31#ifndef lint
32#ifndef NOID
2fc1e207 33static const char privatehid[] = "@(#)private.h 7.53";
1815bff5
A
34#endif /* !defined NOID */
35#endif /* !defined lint */
1815bff5
A
36
37/*
38** Defaults for preprocessor symbols.
39** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
40*/
41
1815bff5
A
42#ifndef HAVE_GETTEXT
43#define HAVE_GETTEXT 0
44#endif /* !defined HAVE_GETTEXT */
45
1815bff5 46#ifndef HAVE_STRERROR
2fc1e207 47#define HAVE_STRERROR 1
1815bff5
A
48#endif /* !defined HAVE_STRERROR */
49
2fc1e207
A
50#ifndef HAVE_SYMLINK
51#define HAVE_SYMLINK 1
52#endif /* !defined HAVE_SYMLINK */
53
54#ifndef HAVE_SYS_STAT_H
55#define HAVE_SYS_STAT_H 1
56#endif /* !defined HAVE_SYS_STAT_H */
57
58#ifndef HAVE_SYS_WAIT_H
59#define HAVE_SYS_WAIT_H 1
60#endif /* !defined HAVE_SYS_WAIT_H */
61
1815bff5
A
62#ifndef HAVE_UNISTD_H
63#define HAVE_UNISTD_H 1
64#endif /* !defined HAVE_UNISTD_H */
65
1815bff5
A
66/*
67** Nested includes
68*/
69
70#include "sys/types.h" /* for time_t */
71#include "stdio.h"
72#include "errno.h"
73#include "string.h"
74#include "limits.h" /* for CHAR_BIT */
75#include "time.h"
76#include "stdlib.h"
77
78#if HAVE_GETTEXT - 0
79#include "libintl.h"
80#endif /* HAVE_GETTEXT - 0 */
81
2fc1e207
A
82#if HAVE_SYS_WAIT_H - 0
83#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
84#endif /* HAVE_SYS_WAIT_H - 0 */
85
1815bff5
A
86#if HAVE_UNISTD_H - 0
87#include "unistd.h" /* for F_OK and R_OK */
88#endif /* HAVE_UNISTD_H - 0 */
89
90#if !(HAVE_UNISTD_H - 0)
91#ifndef F_OK
92#define F_OK 0
93#endif /* !defined F_OK */
94#ifndef R_OK
95#define R_OK 4
96#endif /* !defined R_OK */
97#endif /* !(HAVE_UNISTD_H - 0) */
98
99/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
100#define is_digit(c) ((unsigned)(c) - '0' <= 9)
101
2fc1e207 102#define P(x) x
1815bff5 103
1815bff5 104/*
2fc1e207 105** Private function declarations.
1815bff5 106*/
2fc1e207
A
107char * icalloc P((int nelem, int elsize));
108char * icatalloc P((char * old, const char * new));
109char * icpyalloc P((const char * string));
110char * imalloc P((int n));
111void * irealloc P((void * pointer, int size));
112void icfree P((char * pointer));
113void ifree P((char * pointer));
114char * scheck P((const char *string, const char *format));
1815bff5
A
115
116/*
117** Finally, some convenience items.
118*/
119
120#ifndef TRUE
121#define TRUE 1
122#endif /* !defined TRUE */
123
124#ifndef FALSE
125#define FALSE 0
126#endif /* !defined FALSE */
127
128#ifndef TYPE_BIT
129#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
130#endif /* !defined TYPE_BIT */
131
132#ifndef TYPE_SIGNED
133#define TYPE_SIGNED(type) (((type) -1) < 0)
134#endif /* !defined TYPE_SIGNED */
135
136#ifndef INT_STRLEN_MAXIMUM
137/*
138** 302 / 1000 is log10(2.0) rounded up.
139** Subtract one for the sign bit if the type is signed;
140** add one for integer division truncation;
141** add one more for a minus sign if the type is signed.
142*/
143#define INT_STRLEN_MAXIMUM(type) \
2fc1e207 144 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
1815bff5
A
145#endif /* !defined INT_STRLEN_MAXIMUM */
146
147/*
148** INITIALIZE(x)
149*/
150
151#ifndef GNUC_or_lint
152#ifdef lint
153#define GNUC_or_lint
154#endif /* defined lint */
155#ifndef lint
156#ifdef __GNUC__
157#define GNUC_or_lint
158#endif /* defined __GNUC__ */
159#endif /* !defined lint */
160#endif /* !defined GNUC_or_lint */
161
162#ifndef INITIALIZE
163#ifdef GNUC_or_lint
164#define INITIALIZE(x) ((x) = 0)
165#endif /* defined GNUC_or_lint */
166#ifndef GNUC_or_lint
167#define INITIALIZE(x)
168#endif /* !defined GNUC_or_lint */
169#endif /* !defined INITIALIZE */
170
171/*
172** For the benefit of GNU folk...
173** `_(MSGID)' uses the current locale's message library string for MSGID.
174** The default is to use gettext if available, and use MSGID otherwise.
175*/
176
177#ifndef _
178#if HAVE_GETTEXT - 0
179#define _(msgid) gettext(msgid)
180#else /* !(HAVE_GETTEXT - 0) */
181#define _(msgid) msgid
182#endif /* !(HAVE_GETTEXT - 0) */
183#endif /* !defined _ */
184
185#ifndef TZ_DOMAIN
186#define TZ_DOMAIN "tz"
187#endif /* !defined TZ_DOMAIN */
188
189/*
2fc1e207 190** UNIX was a registered trademark of The Open Group in 2003.
1815bff5
A
191*/
192
193#endif /* !defined PRIVATE_H */