142994Swollman#ifndef PRIVATE_H 242994Swollman 342994Swollman#define PRIVATE_H 442994Swollman 542994Swollman/* 642994Swollman** This file is in the public domain, so clarified as of 7192625Sedwin** 1996-06-05 by Arthur David Olson. 842994Swollman*/ 942994Swollman 1042994Swollman/* 1142997Swollman * FreeBSD modifications: separate libc's privates from zic's. 1242997Swollman * This makes it easier when we need to update one but not the other. 1342997Swollman * I have removed all of the ifdef spaghetti which is not relevant to 1442997Swollman * zic from this file. 1542997Swollman * 1650479Speter * $FreeBSD$ 1742997Swollman */ 1842997Swollman 1942997Swollman/* 2042994Swollman** This header is for use ONLY with the time conversion code. 2142994Swollman** There is no guarantee that it will remain unchanged, 2242994Swollman** or that it will remain at all. 2342994Swollman** Do NOT copy it to any system include directory. 2442994Swollman** Thank you! 2542994Swollman*/ 2642994Swollman 2742994Swollman/* 2842994Swollman** ID 2942994Swollman*/ 3042994Swollman 3142994Swollman#ifndef lint 3242994Swollman#ifndef NOID 33192625Sedwinstatic const char privatehid[] = "@(#)private.h 8.6"; 3442994Swollman#endif /* !defined NOID */ 3542994Swollman#endif /* !defined lint */ 3642994Swollman 37207590Semaste#define GRANDPARENTED "Local time zone must be set--use tzsetup" 38192625Sedwin 3942994Swollman/* 4042994Swollman** Defaults for preprocessor symbols. 4142994Swollman** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. 4242994Swollman*/ 4342994Swollman 4442994Swollman#ifndef HAVE_GETTEXT 4542994Swollman#define HAVE_GETTEXT 0 4642994Swollman#endif /* !defined HAVE_GETTEXT */ 4742994Swollman 4842994Swollman#ifndef HAVE_SYMLINK 4942994Swollman#define HAVE_SYMLINK 1 5042994Swollman#endif /* !defined HAVE_SYMLINK */ 5142994Swollman 52130819Sstefanf#ifndef HAVE_SYS_STAT_H 53130819Sstefanf#define HAVE_SYS_STAT_H 1 54130819Sstefanf#endif /* !defined HAVE_SYS_STAT_H */ 55130819Sstefanf 56130819Sstefanf#ifndef HAVE_SYS_WAIT_H 57130819Sstefanf#define HAVE_SYS_WAIT_H 1 58130819Sstefanf#endif /* !defined HAVE_SYS_WAIT_H */ 59130819Sstefanf 6042994Swollman#ifndef HAVE_UNISTD_H 6142994Swollman#define HAVE_UNISTD_H 1 6242994Swollman#endif /* !defined HAVE_UNISTD_H */ 6342994Swollman 6442994Swollman/* 6542994Swollman** Nested includes 6642994Swollman*/ 6742994Swollman 6842994Swollman#include "sys/types.h" /* for time_t */ 6942994Swollman#include "stdio.h" 7042994Swollman#include "errno.h" 7142994Swollman#include "string.h" 72192625Sedwin#include "limits.h" /* for CHAR_BIT et al. */ 7342994Swollman#include "time.h" 7442994Swollman#include "stdlib.h" 7542994Swollman 76192625Sedwin#if HAVE_GETTEXT 7742994Swollman#include "libintl.h" 78192625Sedwin#endif /* HAVE_GETTEXT */ 7942994Swollman 80192625Sedwin#if HAVE_SYS_WAIT_H 81130819Sstefanf#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ 82192625Sedwin#endif /* HAVE_SYS_WAIT_H */ 83130819Sstefanf 84192625Sedwin#if HAVE_UNISTD_H 85192625Sedwin#include "unistd.h" /* for F_OK and R_OK, and other POSIX goodness */ 86192625Sedwin#endif /* HAVE_UNISTD_H */ 8742994Swollman 8842994Swollman#ifndef F_OK 8942994Swollman#define F_OK 0 9042994Swollman#endif /* !defined F_OK */ 9142994Swollman#ifndef R_OK 9242994Swollman#define R_OK 4 9342994Swollman#endif /* !defined R_OK */ 9442994Swollman 95192625Sedwin/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 9642994Swollman#define is_digit(c) ((unsigned)(c) - '0' <= 9) 9742994Swollman 98192625Sedwin/* 99192625Sedwin** Define HAVE_STDINT_H's default value here, rather than at the 100192625Sedwin** start, since __GLIBC__'s value depends on previously-included 101192625Sedwin** files. 102192625Sedwin** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.) 103192625Sedwin*/ 104192625Sedwin#ifndef HAVE_STDINT_H 105192625Sedwin#define HAVE_STDINT_H \ 106192625Sedwin (199901 <= __STDC_VERSION__ || \ 107192625Sedwin 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__))) 108192625Sedwin#endif /* !defined HAVE_STDINT_H */ 10942994Swollman 110192625Sedwin#if HAVE_STDINT_H 111192625Sedwin#include "stdint.h" 112192625Sedwin#endif /* !HAVE_STDINT_H */ 113192625Sedwin 114192625Sedwin#ifndef INT_FAST64_MAX 115192625Sedwin/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ 116192625Sedwin#if defined LLONG_MAX || defined __LONG_LONG_MAX__ 117192625Sedwintypedef long long int_fast64_t; 118192625Sedwin#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ 119192625Sedwin#if (LONG_MAX >> 31) < 0xffffffff 120192625SedwinPlease use a compiler that supports a 64-bit integer type (or wider); 121192625Sedwinyou may need to compile with "-DHAVE_STDINT_H". 122192625Sedwin#endif /* (LONG_MAX >> 31) < 0xffffffff */ 123192625Sedwintypedef long int_fast64_t; 124192625Sedwin#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ 125192625Sedwin#endif /* !defined INT_FAST64_MAX */ 126192625Sedwin 127192625Sedwin#ifndef INT32_MAX 128192625Sedwin#define INT32_MAX 0x7fffffff 129192625Sedwin#endif /* !defined INT32_MAX */ 130192625Sedwin#ifndef INT32_MIN 131192625Sedwin#define INT32_MIN (-1 - INT32_MAX) 132192625Sedwin#endif /* !defined INT32_MIN */ 133192625Sedwin 13442994Swollman/* 135192625Sedwin** Workarounds for compilers/systems. 136192625Sedwin */ 137192625Sedwin 138192625Sedwin/* 139192625Sedwin** Some time.h implementations don't declare asctime_r. 140192625Sedwin** Others might define it as a macro. 141192625Sedwin** Fix the former without affecting the latter. 142192625Sedwin */ 143192625Sedwin#ifndef asctime_r 144192625Sedwinextern char * asctime_r(struct tm const *, char *); 145192625Sedwin#endif 146192625Sedwin 147192625Sedwin 148192625Sedwin 149192625Sedwin/* 15042994Swollman** Private function declarations. 15142994Swollman*/ 152192625Sedwinchar * icalloc (int nelem, int elsize); 153192625Sedwinchar * icatalloc (char * old, const char * new); 154192625Sedwinchar * icpyalloc (const char * string); 155192625Sedwinchar * imalloc (int n); 156192625Sedwinvoid * irealloc (void * pointer, int size); 157192625Sedwinvoid icfree (char * pointer); 158192625Sedwinvoid ifree (char * pointer); 159192625Sedwinconst char * scheck (const char *string, const char *format); 16042994Swollman 16142994Swollman/* 16242994Swollman** Finally, some convenience items. 16342994Swollman*/ 16442994Swollman 16542994Swollman#ifndef TRUE 16642994Swollman#define TRUE 1 16742994Swollman#endif /* !defined TRUE */ 16842994Swollman 16942994Swollman#ifndef FALSE 17042994Swollman#define FALSE 0 17142994Swollman#endif /* !defined FALSE */ 17242994Swollman 17342994Swollman#ifndef TYPE_BIT 17442994Swollman#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) 17542994Swollman#endif /* !defined TYPE_BIT */ 17642994Swollman 17742994Swollman#ifndef TYPE_SIGNED 17842994Swollman#define TYPE_SIGNED(type) (((type) -1) < 0) 17942994Swollman#endif /* !defined TYPE_SIGNED */ 18042994Swollman 181192625Sedwin/* 182192625Sedwin** Since the definition of TYPE_INTEGRAL contains floating point numbers, 183192625Sedwin** it cannot be used in preprocessor directives. 184192625Sedwin*/ 185192625Sedwin 186192625Sedwin#ifndef TYPE_INTEGRAL 187192625Sedwin#define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5) 188192625Sedwin#endif /* !defined TYPE_INTEGRAL */ 189192625Sedwin 19042994Swollman#ifndef INT_STRLEN_MAXIMUM 19142994Swollman/* 19242994Swollman** 302 / 1000 is log10(2.0) rounded up. 19342994Swollman** Subtract one for the sign bit if the type is signed; 19442994Swollman** add one for integer division truncation; 19542994Swollman** add one more for a minus sign if the type is signed. 19642994Swollman*/ 19742994Swollman#define INT_STRLEN_MAXIMUM(type) \ 198192625Sedwin ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \ 199192625Sedwin 1 + TYPE_SIGNED(type)) 20042994Swollman#endif /* !defined INT_STRLEN_MAXIMUM */ 20142994Swollman 20242994Swollman/* 20342994Swollman** INITIALIZE(x) 20442994Swollman*/ 20542994Swollman 20642994Swollman#ifndef GNUC_or_lint 20742994Swollman#ifdef lint 20842994Swollman#define GNUC_or_lint 20942994Swollman#endif /* defined lint */ 21042994Swollman#ifndef lint 21142994Swollman#ifdef __GNUC__ 21242994Swollman#define GNUC_or_lint 21342994Swollman#endif /* defined __GNUC__ */ 21442994Swollman#endif /* !defined lint */ 21542994Swollman#endif /* !defined GNUC_or_lint */ 21642994Swollman 21742994Swollman#ifndef INITIALIZE 21842994Swollman#ifdef GNUC_or_lint 21942994Swollman#define INITIALIZE(x) ((x) = 0) 22042994Swollman#endif /* defined GNUC_or_lint */ 22142994Swollman#ifndef GNUC_or_lint 22242994Swollman#define INITIALIZE(x) 22342994Swollman#endif /* !defined GNUC_or_lint */ 22442994Swollman#endif /* !defined INITIALIZE */ 22542994Swollman 22642994Swollman/* 22742994Swollman** For the benefit of GNU folk... 22842994Swollman** `_(MSGID)' uses the current locale's message library string for MSGID. 22942994Swollman** The default is to use gettext if available, and use MSGID otherwise. 23042994Swollman*/ 23142994Swollman 23242994Swollman#ifndef _ 233192625Sedwin#if HAVE_GETTEXT 23442994Swollman#define _(msgid) gettext(msgid) 235192625Sedwin#else /* !HAVE_GETTEXT */ 23642994Swollman#define _(msgid) msgid 237192625Sedwin#endif /* !HAVE_GETTEXT */ 23842994Swollman#endif /* !defined _ */ 23942994Swollman 24042994Swollman#ifndef TZ_DOMAIN 24142994Swollman#define TZ_DOMAIN "tz" 24242994Swollman#endif /* !defined TZ_DOMAIN */ 24342994Swollman 24442994Swollman/* 245130819Sstefanf** UNIX was a registered trademark of The Open Group in 2003. 24642994Swollman*/ 24742994Swollman 248192625Sedwin#ifndef YEARSPERREPEAT 249192625Sedwin#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ 250192625Sedwin#endif /* !defined YEARSPERREPEAT */ 251192625Sedwin 252192625Sedwin/* 253192625Sedwin** The Gregorian year averages 365.2425 days, which is 31556952 seconds. 254192625Sedwin*/ 255192625Sedwin 256192625Sedwin#ifndef AVGSECSPERYEAR 257192625Sedwin#define AVGSECSPERYEAR 31556952L 258192625Sedwin#endif /* !defined AVGSECSPERYEAR */ 259192625Sedwin 260192625Sedwin#ifndef SECSPERREPEAT 261192625Sedwin#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR) 262192625Sedwin#endif /* !defined SECSPERREPEAT */ 263192625Sedwin 264192625Sedwin#ifndef SECSPERREPEAT_BITS 265192625Sedwin#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */ 266192625Sedwin#endif /* !defined SECSPERREPEAT_BITS */ 267192625Sedwin 268192625Sedwin /* 269192625Sedwin ** UNIX was a registered trademark of The Open Group in 2003. 270192625Sedwin */ 271192625Sedwin 27242994Swollman#endif /* !defined PRIVATE_H */ 273