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