1 /*! 2 @file private.h 3 @brief This file is from the tz distribution at ftp://elsie.nci.nih.gov/pub/ 4 */ 5 #ifndef PRIVATE_H 6 7 #define PRIVATE_H 8 9 /* 10 ** This file is in the public domain, so clarified as of 11 ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). 12 */ 13 14 /* 15 ** This header is for use ONLY with the time conversion code. 16 ** There is no guarantee that it will remain unchanged, 17 ** or that it will remain at all. 18 ** Do NOT copy it to any system include directory. 19 ** Thank you! 20 */ 21 22 /* 23 ** ID 24 */ 25 26 #ifndef lint 27 #ifndef NOID 28 static char privatehid[] = "@(#)private.h 7.53"; 29 #endif /* !defined NOID */ 30 #endif /* !defined lint */ 31 32 /* ahu: moved required preprocessor symbols to config.h */ 33 34 /* ahu: disable warnings */ 35 #ifdef _MSC_VER 36 // disable warning 'uses old-style declarator' C4131 37 #pragma warning (disable: 4131) 38 #endif 39 40 /* 41 ** Nested includes 42 */ 43 44 #include "sys/types.h" /* for time_t */ 45 #include "stdio.h" 46 #include "errno.h" 47 #include "string.h" 48 #include "limits.h" /* for CHAR_BIT */ 49 #include "time.h" 50 #include "stdlib.h" 51 52 /* ahu: added io.h for MSVC */ 53 #ifdef _MSC_VER 54 # include "io.h" 55 #endif 56 57 /* ahu: deleted include libintl.h */ 58 59 /* ahu: deleted include sys/wait.h and WIFEXITED, WEXITSTATUS macros */ 60 61 #if EXV_HAVE_UNISTD_H - 0 62 #include "unistd.h" /* for F_OK and R_OK */ 63 #endif /* EXV_HAVE_UNISTD_H - 0 */ 64 65 #if !(EXV_HAVE_UNISTD_H - 0) 66 #ifndef F_OK 67 #define F_OK 0 68 #endif /* !defined F_OK */ 69 #ifndef R_OK 70 #define R_OK 4 71 #endif /* !defined R_OK */ 72 #endif /* !(EXV_HAVE_UNISTD_H - 0) */ 73 74 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 75 #define is_digit(c) ((unsigned)(c) - '0' <= 9) 76 77 /* 78 ** Workarounds for compilers/systems. 79 */ 80 81 /* 82 ** SunOS 4.1.1 cc lacks prototypes. 83 */ 84 85 #ifndef P 86 #ifdef __STDC__ 87 #define P(x) x 88 #endif /* defined __STDC__ */ 89 #ifndef __STDC__ 90 #define P(x) () 91 #endif /* !defined __STDC__ */ 92 #endif /* !defined P */ 93 94 /* 95 ** SunOS 4.1.1 headers lack EXIT_SUCCESS. 96 */ 97 98 #ifndef EXIT_SUCCESS 99 #define EXIT_SUCCESS 0 100 #endif /* !defined EXIT_SUCCESS */ 101 102 /* 103 ** SunOS 4.1.1 headers lack EXIT_FAILURE. 104 */ 105 106 #ifndef EXIT_FAILURE 107 #define EXIT_FAILURE 1 108 #endif /* !defined EXIT_FAILURE */ 109 110 /* 111 ** SunOS 4.1.1 headers lack FILENAME_MAX. 112 */ 113 114 #ifndef FILENAME_MAX 115 116 #ifndef MAXPATHLEN 117 #ifdef unix 118 #include "sys/param.h" 119 #endif /* defined unix */ 120 #endif /* !defined MAXPATHLEN */ 121 122 #ifdef MAXPATHLEN 123 #define FILENAME_MAX MAXPATHLEN 124 #endif /* defined MAXPATHLEN */ 125 #ifndef MAXPATHLEN 126 #define FILENAME_MAX 1024 /* Pure guesswork */ 127 #endif /* !defined MAXPATHLEN */ 128 129 #endif /* !defined FILENAME_MAX */ 130 131 /* ahu: deleted unlink declaration and remove define */ 132 133 /* ahu: deleted errno declaration */ 134 135 /* ahu: deleted private function declarations */ 136 137 /* 138 ** Finally, some convenience items. 139 */ 140 141 #ifndef TRUE 142 #define TRUE 1 143 #endif /* !defined TRUE */ 144 145 #ifndef FALSE 146 #define FALSE 0 147 #endif /* !defined FALSE */ 148 149 #ifndef TYPE_BIT 150 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) 151 #endif /* !defined TYPE_BIT */ 152 153 #ifndef TYPE_SIGNED 154 #define TYPE_SIGNED(type) (((type) -1) < 0) 155 #endif /* !defined TYPE_SIGNED */ 156 157 #ifndef INT_STRLEN_MAXIMUM 158 /* 159 ** 302 / 1000 is log10(2.0) rounded up. 160 ** Subtract one for the sign bit if the type is signed; 161 ** add one for integer division truncation; 162 ** add one more for a minus sign if the type is signed. 163 */ 164 #define INT_STRLEN_MAXIMUM(type) \ 165 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) 166 #endif /* !defined INT_STRLEN_MAXIMUM */ 167 168 /* 169 ** INITIALIZE(x) 170 */ 171 172 #ifndef GNUC_or_lint 173 #ifdef lint 174 #define GNUC_or_lint 175 #endif /* defined lint */ 176 #ifndef lint 177 #ifdef __GNUC__ 178 #define GNUC_or_lint 179 #endif /* defined __GNUC__ */ 180 #endif /* !defined lint */ 181 #endif /* !defined GNUC_or_lint */ 182 183 #ifndef INITIALIZE 184 #ifdef GNUC_or_lint 185 #define INITIALIZE(x) ((x) = 0) 186 #endif /* defined GNUC_or_lint */ 187 #ifndef GNUC_or_lint 188 #define INITIALIZE(x) 189 #endif /* !defined GNUC_or_lint */ 190 #endif /* !defined INITIALIZE */ 191 192 /* ahu: deleted definition of _(msgid) macro */ 193 194 #ifndef TZ_DOMAIN 195 #define TZ_DOMAIN "tz" 196 #endif /* !defined TZ_DOMAIN */ 197 198 #if HAVE_INCOMPATIBLE_CTIME_R 199 #undef asctime_r 200 #undef ctime_r 201 char *asctime_r P((struct tm const *, char *)); 202 char *ctime_r P((time_t const *, char *)); 203 #endif /* HAVE_INCOMPATIBLE_CTIME_R */ 204 205 /* 206 ** UNIX was a registered trademark of The Open Group in 2003. 207 */ 208 209 #endif /* !defined PRIVATE_H */ 210