1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/tzcode/private.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,298 @@ 1.4 +#ifndef PRIVATE_H 1.5 + 1.6 +#define PRIVATE_H 1.7 + 1.8 +/* 1.9 +** This file is in the public domain, so clarified as of 1.10 +** 1996-06-05 by Arthur David Olson. 1.11 +*/ 1.12 + 1.13 +/* 1.14 +** This header is for use ONLY with the time conversion code. 1.15 +** There is no guarantee that it will remain unchanged, 1.16 +** or that it will remain at all. 1.17 +** Do NOT copy it to any system include directory. 1.18 +** Thank you! 1.19 +*/ 1.20 + 1.21 +/* 1.22 +** ID 1.23 +*/ 1.24 + 1.25 +#ifndef lint 1.26 +#ifndef NOID 1.27 +static char privatehid[] = "@(#)private.h 8.6"; 1.28 +#endif /* !defined NOID */ 1.29 +#endif /* !defined lint */ 1.30 + 1.31 +#define GRANDPARENTED "Local time zone must be set--see zic manual page" 1.32 + 1.33 +/* 1.34 +** Defaults for preprocessor symbols. 1.35 +** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. 1.36 +*/ 1.37 + 1.38 +#ifndef HAVE_ADJTIME 1.39 +#define HAVE_ADJTIME 1 1.40 +#endif /* !defined HAVE_ADJTIME */ 1.41 + 1.42 +#ifndef HAVE_GETTEXT 1.43 +#define HAVE_GETTEXT 0 1.44 +#endif /* !defined HAVE_GETTEXT */ 1.45 + 1.46 +#ifndef HAVE_INCOMPATIBLE_CTIME_R 1.47 +#define HAVE_INCOMPATIBLE_CTIME_R 0 1.48 +#endif /* !defined INCOMPATIBLE_CTIME_R */ 1.49 + 1.50 +#ifndef HAVE_SETTIMEOFDAY 1.51 +#define HAVE_SETTIMEOFDAY 3 1.52 +#endif /* !defined HAVE_SETTIMEOFDAY */ 1.53 + 1.54 +#ifndef HAVE_SYMLINK 1.55 +#define HAVE_SYMLINK 1 1.56 +#endif /* !defined HAVE_SYMLINK */ 1.57 + 1.58 +#ifndef HAVE_SYS_STAT_H 1.59 +#define HAVE_SYS_STAT_H 1 1.60 +#endif /* !defined HAVE_SYS_STAT_H */ 1.61 + 1.62 +#ifndef HAVE_SYS_WAIT_H 1.63 +#define HAVE_SYS_WAIT_H 1 1.64 +#endif /* !defined HAVE_SYS_WAIT_H */ 1.65 + 1.66 +#ifndef HAVE_UNISTD_H 1.67 +#define HAVE_UNISTD_H 1 1.68 +#endif /* !defined HAVE_UNISTD_H */ 1.69 + 1.70 +#ifndef HAVE_UTMPX_H 1.71 +#define HAVE_UTMPX_H 0 1.72 +#endif /* !defined HAVE_UTMPX_H */ 1.73 + 1.74 +#ifndef LOCALE_HOME 1.75 +#define LOCALE_HOME "/usr/lib/locale" 1.76 +#endif /* !defined LOCALE_HOME */ 1.77 + 1.78 +#if HAVE_INCOMPATIBLE_CTIME_R 1.79 +#define asctime_r _incompatible_asctime_r 1.80 +#define ctime_r _incompatible_ctime_r 1.81 +#endif /* HAVE_INCOMPATIBLE_CTIME_R */ 1.82 + 1.83 +/* 1.84 +** Nested includes 1.85 +*/ 1.86 + 1.87 +#include "sys/types.h" /* for time_t */ 1.88 +#include "stdio.h" 1.89 +#include "errno.h" 1.90 +#include "string.h" 1.91 +#include "limits.h" /* for CHAR_BIT et al. */ 1.92 +#include "time.h" 1.93 +#include "stdlib.h" 1.94 + 1.95 +#if HAVE_GETTEXT 1.96 +#include "libintl.h" 1.97 +#endif /* HAVE_GETTEXT */ 1.98 + 1.99 +#if HAVE_SYS_WAIT_H 1.100 +#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ 1.101 +#endif /* HAVE_SYS_WAIT_H */ 1.102 + 1.103 +#ifndef WIFEXITED 1.104 +#define WIFEXITED(status) (((status) & 0xff) == 0) 1.105 +#endif /* !defined WIFEXITED */ 1.106 +#ifndef WEXITSTATUS 1.107 +#define WEXITSTATUS(status) (((status) >> 8) & 0xff) 1.108 +#endif /* !defined WEXITSTATUS */ 1.109 + 1.110 +#if HAVE_UNISTD_H 1.111 +#include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */ 1.112 +#endif /* HAVE_UNISTD_H */ 1.113 + 1.114 +#ifndef F_OK 1.115 +#define F_OK 0 1.116 +#endif /* !defined F_OK */ 1.117 +#ifndef R_OK 1.118 +#define R_OK 4 1.119 +#endif /* !defined R_OK */ 1.120 + 1.121 +/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 1.122 +#define is_digit(c) ((unsigned)(c) - '0' <= 9) 1.123 + 1.124 +/* 1.125 +** Define HAVE_STDINT_H's default value here, rather than at the 1.126 +** start, since __GLIBC__'s value depends on previously-included 1.127 +** files. 1.128 +** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.) 1.129 +*/ 1.130 +#ifndef HAVE_STDINT_H 1.131 +#define HAVE_STDINT_H \ 1.132 + (199901 <= __STDC_VERSION__ || \ 1.133 + 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__))) 1.134 +#endif /* !defined HAVE_STDINT_H */ 1.135 + 1.136 +#if HAVE_STDINT_H 1.137 +#include "stdint.h" 1.138 +#endif /* !HAVE_STDINT_H */ 1.139 + 1.140 +#ifndef INT_FAST64_MAX 1.141 +/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */ 1.142 +#if defined LLONG_MAX || defined __LONG_LONG_MAX__ 1.143 +typedef long long int_fast64_t; 1.144 +#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ 1.145 +#if (LONG_MAX >> 31) < 0xffffffff 1.146 +Please use a compiler that supports a 64-bit integer type (or wider); 1.147 +you may need to compile with "-DHAVE_STDINT_H". 1.148 +#endif /* (LONG_MAX >> 31) < 0xffffffff */ 1.149 +typedef long int_fast64_t; 1.150 +#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */ 1.151 +#endif /* !defined INT_FAST64_MAX */ 1.152 + 1.153 +#ifndef INT32_MAX 1.154 +#define INT32_MAX 0x7fffffff 1.155 +#endif /* !defined INT32_MAX */ 1.156 +#ifndef INT32_MIN 1.157 +#define INT32_MIN (-1 - INT32_MAX) 1.158 +#endif /* !defined INT32_MIN */ 1.159 + 1.160 +/* 1.161 +** Workarounds for compilers/systems. 1.162 +*/ 1.163 + 1.164 +/* 1.165 +** Some time.h implementations don't declare asctime_r. 1.166 +** Others might define it as a macro. 1.167 +** Fix the former without affecting the latter. 1.168 +*/ 1.169 + 1.170 +#ifndef asctime_r 1.171 +extern char * asctime_r(struct tm const *, char *); 1.172 +#endif 1.173 + 1.174 +/* 1.175 +** Private function declarations. 1.176 +*/ 1.177 + 1.178 +char * icalloc(int nelem, int elsize); 1.179 +char * icatalloc(char * old, const char * new); 1.180 +char * icpyalloc(const char * string); 1.181 +char * imalloc(int n); 1.182 +void * irealloc(void * pointer, int size); 1.183 +void icfree(char * pointer); 1.184 +void ifree(char * pointer); 1.185 +const char * scheck(const char * string, const char * format); 1.186 + 1.187 +/* 1.188 +** Finally, some convenience items. 1.189 +*/ 1.190 + 1.191 +#ifndef TRUE 1.192 +#define TRUE 1 1.193 +#endif /* !defined TRUE */ 1.194 + 1.195 +#ifndef FALSE 1.196 +#define FALSE 0 1.197 +#endif /* !defined FALSE */ 1.198 + 1.199 +#ifndef TYPE_BIT 1.200 +#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) 1.201 +#endif /* !defined TYPE_BIT */ 1.202 + 1.203 +#ifndef TYPE_SIGNED 1.204 +#define TYPE_SIGNED(type) (((type) -1) < 0) 1.205 +#endif /* !defined TYPE_SIGNED */ 1.206 + 1.207 +/* 1.208 +** Since the definition of TYPE_INTEGRAL contains floating point numbers, 1.209 +** it cannot be used in preprocessor directives. 1.210 +*/ 1.211 + 1.212 +#ifndef TYPE_INTEGRAL 1.213 +#define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5) 1.214 +#endif /* !defined TYPE_INTEGRAL */ 1.215 + 1.216 +#ifndef INT_STRLEN_MAXIMUM 1.217 +/* 1.218 +** 302 / 1000 is log10(2.0) rounded up. 1.219 +** Subtract one for the sign bit if the type is signed; 1.220 +** add one for integer division truncation; 1.221 +** add one more for a minus sign if the type is signed. 1.222 +*/ 1.223 +#define INT_STRLEN_MAXIMUM(type) \ 1.224 + ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \ 1.225 + 1 + TYPE_SIGNED(type)) 1.226 +#endif /* !defined INT_STRLEN_MAXIMUM */ 1.227 + 1.228 +/* 1.229 +** INITIALIZE(x) 1.230 +*/ 1.231 + 1.232 +#ifndef GNUC_or_lint 1.233 +#ifdef lint 1.234 +#define GNUC_or_lint 1.235 +#endif /* defined lint */ 1.236 +#ifndef lint 1.237 +#ifdef __GNUC__ 1.238 +#define GNUC_or_lint 1.239 +#endif /* defined __GNUC__ */ 1.240 +#endif /* !defined lint */ 1.241 +#endif /* !defined GNUC_or_lint */ 1.242 + 1.243 +#ifndef INITIALIZE 1.244 +#ifdef GNUC_or_lint 1.245 +#define INITIALIZE(x) ((x) = 0) 1.246 +#endif /* defined GNUC_or_lint */ 1.247 +#ifndef GNUC_or_lint 1.248 +#define INITIALIZE(x) 1.249 +#endif /* !defined GNUC_or_lint */ 1.250 +#endif /* !defined INITIALIZE */ 1.251 + 1.252 +/* 1.253 +** For the benefit of GNU folk... 1.254 +** `_(MSGID)' uses the current locale's message library string for MSGID. 1.255 +** The default is to use gettext if available, and use MSGID otherwise. 1.256 +*/ 1.257 + 1.258 +#ifndef _ 1.259 +#if HAVE_GETTEXT 1.260 +#define _(msgid) gettext(msgid) 1.261 +#else /* !HAVE_GETTEXT */ 1.262 +#define _(msgid) msgid 1.263 +#endif /* !HAVE_GETTEXT */ 1.264 +#endif /* !defined _ */ 1.265 + 1.266 +#ifndef TZ_DOMAIN 1.267 +#define TZ_DOMAIN "tz" 1.268 +#endif /* !defined TZ_DOMAIN */ 1.269 + 1.270 +#if HAVE_INCOMPATIBLE_CTIME_R 1.271 +#undef asctime_r 1.272 +#undef ctime_r 1.273 +char *asctime_r(struct tm const *, char *); 1.274 +char *ctime_r(time_t const *, char *); 1.275 +#endif /* HAVE_INCOMPATIBLE_CTIME_R */ 1.276 + 1.277 +#ifndef YEARSPERREPEAT 1.278 +#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ 1.279 +#endif /* !defined YEARSPERREPEAT */ 1.280 + 1.281 +/* 1.282 +** The Gregorian year averages 365.2425 days, which is 31556952 seconds. 1.283 +*/ 1.284 + 1.285 +#ifndef AVGSECSPERYEAR 1.286 +#define AVGSECSPERYEAR 31556952L 1.287 +#endif /* !defined AVGSECSPERYEAR */ 1.288 + 1.289 +#ifndef SECSPERREPEAT 1.290 +#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR) 1.291 +#endif /* !defined SECSPERREPEAT */ 1.292 + 1.293 +#ifndef SECSPERREPEAT_BITS 1.294 +#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */ 1.295 +#endif /* !defined SECSPERREPEAT_BITS */ 1.296 + 1.297 +/* 1.298 +** UNIX was a registered trademark of The Open Group in 2003. 1.299 +*/ 1.300 + 1.301 +#endif /* !defined PRIVATE_H */