1 /* $NetBSD: private.h,v 1.20 2002/01/29 12:40:34 kleink Exp $ */ 2 3 #ifndef PRIVATE_H 4 #define PRIVATE_H 5 6 /* NetBSD defaults */ 7 #define TM_GMTOFF tm_gmtoff 8 #define TM_ZONE tm_zone 9 #define STD_INSPIRED 1 10 #define HAVE_LONG_DOUBLE 1 11 12 /* 13 ** This file is in the public domain, so clarified as of 14 ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). 15 */ 16 17 /* 18 ** This header is for use ONLY with the time conversion code. 19 ** There is no guarantee that it will remain unchanged, 20 ** or that it will remain at all. 21 ** Do NOT copy it to any system include directory. 22 ** Thank you! 23 */ 24 25 /* 26 ** ID 27 */ 28 29 #ifndef lint 30 #ifndef NOID 31 #if 0 32 static char privatehid[] = "@(#)private.h 7.52"; 33 #endif 34 #endif /* !defined NOID */ 35 #endif /* !defined lint */ 36 37 /* 38 ** Defaults for preprocessor symbols. 39 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. 40 */ 41 42 #ifndef HAVE_ADJTIME 43 #define HAVE_ADJTIME 1 44 #endif /* !defined HAVE_ADJTIME */ 45 46 #ifndef HAVE_GETTEXT 47 #define HAVE_GETTEXT 0 48 #endif /* !defined HAVE_GETTEXT */ 49 50 #ifndef HAVE_INCOMPATIBLE_CTIME_R 51 #define HAVE_INCOMPATIBLE_CTIME_R 0 52 #endif /* !defined INCOMPATIBLE_CTIME_R */ 53 54 #ifndef HAVE_SETTIMEOFDAY 55 #define HAVE_SETTIMEOFDAY 3 56 #endif /* !defined HAVE_SETTIMEOFDAY */ 57 58 #ifndef HAVE_STRERROR 59 #define HAVE_STRERROR 1 60 #endif /* !defined HAVE_STRERROR */ 61 62 #ifndef HAVE_SYMLINK 63 #define HAVE_SYMLINK 1 64 #endif /* !defined HAVE_SYMLINK */ 65 66 #ifndef HAVE_SYS_STAT_H 67 #define HAVE_SYS_STAT_H 1 68 #endif /* !defined HAVE_SYS_STAT_H */ 69 70 #ifndef HAVE_SYS_WAIT_H 71 #define HAVE_SYS_WAIT_H 1 72 #endif /* !defined HAVE_SYS_WAIT_H */ 73 74 #ifndef HAVE_UNISTD_H 75 #define HAVE_UNISTD_H 1 76 #endif /* !defined HAVE_UNISTD_H */ 77 78 #ifndef HAVE_UTMPX_H 79 #define HAVE_UTMPX_H 0 80 #endif /* !defined HAVE_UTMPX_H */ 81 82 #ifdef LOCALE_HOME 83 #undef LOCALE_HOME /* not to be handled by tzcode itself */ 84 #endif /* defined LOCALE_HOME */ 85 86 #if HAVE_INCOMPATIBLE_CTIME_R 87 #define asctime_r _incompatible_asctime_r 88 #define ctime_r _incompatible_ctime_r 89 #endif /* HAVE_INCOMPATIBLE_CTIME_R */ 90 91 /* 92 ** Nested includes 93 */ 94 95 #include "sys/types.h" /* for time_t */ 96 #include "stdio.h" 97 #include "errno.h" 98 #include "string.h" 99 #include "limits.h" /* for CHAR_BIT */ 100 #include "time.h" 101 #include "stdlib.h" 102 103 #if HAVE_GETTEXT - 0 104 #include "libintl.h" 105 #endif /* HAVE_GETTEXT - 0 */ 106 107 #if HAVE_SYS_WAIT_H - 0 108 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ 109 #endif /* HAVE_SYS_WAIT_H - 0 */ 110 111 #ifndef WIFEXITED 112 #define WIFEXITED(status) (((status) & 0xff) == 0) 113 #endif /* !defined WIFEXITED */ 114 #ifndef WEXITSTATUS 115 #define WEXITSTATUS(status) (((status) >> 8) & 0xff) 116 #endif /* !defined WEXITSTATUS */ 117 118 #if HAVE_UNISTD_H - 0 119 #include "unistd.h" /* for F_OK and R_OK */ 120 #endif /* HAVE_UNISTD_H - 0 */ 121 122 #if !(HAVE_UNISTD_H - 0) 123 #ifndef F_OK 124 #define F_OK 0 125 #endif /* !defined F_OK */ 126 #ifndef R_OK 127 #define R_OK 4 128 #endif /* !defined R_OK */ 129 #endif /* !(HAVE_UNISTD_H - 0) */ 130 131 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 132 #define is_digit(c) ((unsigned)(c) - '0' <= 9) 133 134 /* 135 ** Workarounds for compilers/systems. 136 */ 137 138 /* 139 ** SunOS 4.1.1 cc lacks prototypes. 140 */ 141 142 #ifndef P 143 #ifdef __STDC__ 144 #define P(x) x 145 #endif /* defined __STDC__ */ 146 #ifndef __STDC__ 147 #define P(x) () 148 #endif /* !defined __STDC__ */ 149 #endif /* !defined P */ 150 151 /* 152 ** SunOS 4.1.1 headers lack EXIT_SUCCESS. 153 */ 154 155 #ifndef EXIT_SUCCESS 156 #define EXIT_SUCCESS 0 157 #endif /* !defined EXIT_SUCCESS */ 158 159 /* 160 ** SunOS 4.1.1 headers lack EXIT_FAILURE. 161 */ 162 163 #ifndef EXIT_FAILURE 164 #define EXIT_FAILURE 1 165 #endif /* !defined EXIT_FAILURE */ 166 167 /* 168 ** SunOS 4.1.1 headers lack FILENAME_MAX. 169 */ 170 171 #ifndef FILENAME_MAX 172 173 #ifndef MAXPATHLEN 174 #ifdef unix 175 #include "sys/param.h" 176 #endif /* defined unix */ 177 #endif /* !defined MAXPATHLEN */ 178 179 #ifdef MAXPATHLEN 180 #define FILENAME_MAX MAXPATHLEN 181 #endif /* defined MAXPATHLEN */ 182 #ifndef MAXPATHLEN 183 #define FILENAME_MAX 1024 /* Pure guesswork */ 184 #endif /* !defined MAXPATHLEN */ 185 186 #endif /* !defined FILENAME_MAX */ 187 188 /* 189 ** SunOS 4.1.1 libraries lack remove. 190 */ 191 192 #ifndef __NetBSD__ 193 #ifndef remove 194 extern int unlink P((const char * filename)); 195 #define remove unlink 196 #endif /* !defined remove */ 197 #endif 198 199 /* 200 ** Some ancient errno.h implementations don't declare errno. 201 ** But some newer errno.h implementations define it as a macro. 202 ** Fix the former without affecting the latter. 203 */ 204 #ifndef errno 205 extern int errno; 206 #endif /* !defined errno */ 207 208 /* 209 ** Private function declarations. 210 */ 211 char * icalloc P((int nelem, int elsize)); 212 char * icatalloc P((char * old, const char * new)); 213 char * icpyalloc P((const char * string)); 214 char * imalloc P((int n)); 215 void * irealloc P((void * pointer, int size)); 216 void icfree P((char * pointer)); 217 void ifree P((char * pointer)); 218 char * scheck P((const char *string, const char *format)) 219 __attribute__((__format_arg__(2))); 220 221 222 /* 223 ** Finally, some convenience items. 224 */ 225 226 #ifndef TRUE 227 #define TRUE 1 228 #endif /* !defined TRUE */ 229 230 #ifndef FALSE 231 #define FALSE 0 232 #endif /* !defined FALSE */ 233 234 #ifndef TYPE_BIT 235 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) 236 #endif /* !defined TYPE_BIT */ 237 238 #ifndef TYPE_SIGNED 239 #define TYPE_SIGNED(type) (((type) -1) < 0) 240 #endif /* !defined TYPE_SIGNED */ 241 242 #ifndef INT_STRLEN_MAXIMUM 243 /* 244 ** 302 / 1000 is log10(2.0) rounded up. 245 ** Subtract one for the sign bit if the type is signed; 246 ** add one for integer division truncation; 247 ** add one more for a minus sign if the type is signed. 248 */ 249 #define INT_STRLEN_MAXIMUM(type) \ 250 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) 251 #endif /* !defined INT_STRLEN_MAXIMUM */ 252 253 /* 254 ** INITIALIZE(x) 255 */ 256 257 #ifndef GNUC_or_lint 258 #ifdef lint 259 #define GNUC_or_lint 260 #endif /* defined lint */ 261 #ifndef lint 262 #ifdef __GNUC__ 263 #define GNUC_or_lint 264 #endif /* defined __GNUC__ */ 265 #endif /* !defined lint */ 266 #endif /* !defined GNUC_or_lint */ 267 268 #ifndef INITIALIZE 269 #ifdef GNUC_or_lint 270 #define INITIALIZE(x) ((x) = 0) 271 #endif /* defined GNUC_or_lint */ 272 #ifndef GNUC_or_lint 273 #define INITIALIZE(x) 274 #endif /* !defined GNUC_or_lint */ 275 #endif /* !defined INITIALIZE */ 276 277 /* 278 ** For the benefit of GNU folk... 279 ** `_(MSGID)' uses the current locale's message library string for MSGID. 280 ** The default is to use gettext if available, and use MSGID otherwise. 281 */ 282 283 #ifndef _ 284 #if HAVE_GETTEXT - 0 285 #define _(msgid) gettext(msgid) 286 #else /* !(HAVE_GETTEXT - 0) */ 287 #define _(msgid) msgid 288 #endif /* !(HAVE_GETTEXT - 0) */ 289 #endif /* !defined _ */ 290 291 #ifndef TZ_DOMAIN 292 #define TZ_DOMAIN "tz" 293 #endif /* !defined TZ_DOMAIN */ 294 295 #if HAVE_INCOMPATIBLE_CTIME_R 296 #undef asctime_r 297 #undef ctime_r 298 char *asctime_r P((struct tm const *, char *)); 299 char *ctime_r P((time_t const *, char *)); 300 #endif /* HAVE_INCOMPATIBLE_CTIME_R */ 301 302 /* 303 ** UNIX was a registered trademark of UNIX System Laboratories in 1993. 304 */ 305 306 #endif /* !defined PRIVATE_H */ 307