1 /* $OpenBSD: private.h,v 1.14 2002/04/04 19:12:09 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.52"; 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_STAT_H 71 #define HAVE_SYS_STAT_H 1 72 #endif /* !defined HAVE_SYS_STAT_H */ 73 74 #ifndef HAVE_SYS_WAIT_H 75 #define HAVE_SYS_WAIT_H 1 76 #endif /* !defined HAVE_SYS_WAIT_H */ 77 78 #ifndef HAVE_UNISTD_H 79 #define HAVE_UNISTD_H 1 80 #endif /* !defined HAVE_UNISTD_H */ 81 82 #ifndef HAVE_UTMPX_H 83 #define HAVE_UTMPX_H 0 84 #endif /* !defined HAVE_UTMPX_H */ 85 86 #if 0 87 #ifndef LOCALE_HOME 88 #define LOCALE_HOME "/usr/share/locale" 89 #endif /* !defined LOCALE_HOME */ 90 #endif 91 92 #if HAVE_INCOMPATIBLE_CTIME_R 93 #define asctime_r _incompatible_asctime_r 94 #define ctime_r _incompatible_ctime_r 95 #endif /* HAVE_INCOMPATIBLE_CTIME_R */ 96 97 /* 98 ** Nested includes 99 */ 100 101 #include "sys/types.h" /* for time_t */ 102 #include "stdio.h" 103 #include "errno.h" 104 #include "string.h" 105 #include "limits.h" /* for CHAR_BIT */ 106 #include "time.h" 107 #include "stdlib.h" 108 109 #if HAVE_GETTEXT - 0 110 #include "libintl.h" 111 #endif /* HAVE_GETTEXT - 0 */ 112 113 #if HAVE_SYS_WAIT_H - 0 114 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ 115 #endif /* HAVE_SYS_WAIT_H - 0 */ 116 117 #ifndef WIFEXITED 118 #define WIFEXITED(status) (((status) & 0xff) == 0) 119 #endif /* !defined WIFEXITED */ 120 #ifndef WEXITSTATUS 121 #define WEXITSTATUS(status) (((status) >> 8) & 0xff) 122 #endif /* !defined WEXITSTATUS */ 123 124 #if HAVE_UNISTD_H - 0 125 #include "unistd.h" /* for F_OK and R_OK */ 126 #endif /* HAVE_UNISTD_H - 0 */ 127 128 #if !(HAVE_UNISTD_H - 0) 129 #ifndef F_OK 130 #define F_OK 0 131 #endif /* !defined F_OK */ 132 #ifndef R_OK 133 #define R_OK 4 134 #endif /* !defined R_OK */ 135 #endif /* !(HAVE_UNISTD_H - 0) */ 136 137 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 138 #define is_digit(c) ((unsigned)(c) - '0' <= 9) 139 140 /* 141 ** Workarounds for compilers/systems. 142 */ 143 144 /* 145 ** SunOS 4.1.1 cc lacks prototypes. 146 */ 147 148 #ifndef P 149 #ifdef __STDC__ 150 #define P(x) x 151 #endif /* defined __STDC__ */ 152 #ifndef __STDC__ 153 #define P(x) () 154 #endif /* !defined __STDC__ */ 155 #endif /* !defined P */ 156 157 /* 158 ** SunOS 4.1.1 headers lack EXIT_SUCCESS. 159 */ 160 161 #ifndef EXIT_SUCCESS 162 #define EXIT_SUCCESS 0 163 #endif /* !defined EXIT_SUCCESS */ 164 165 /* 166 ** SunOS 4.1.1 headers lack EXIT_FAILURE. 167 */ 168 169 #ifndef EXIT_FAILURE 170 #define EXIT_FAILURE 1 171 #endif /* !defined EXIT_FAILURE */ 172 173 /* 174 ** SunOS 4.1.1 headers lack FILENAME_MAX. 175 */ 176 177 #ifndef FILENAME_MAX 178 179 #ifndef MAXPATHLEN 180 #ifdef unix 181 #include "sys/param.h" 182 #endif /* defined unix */ 183 #endif /* !defined MAXPATHLEN */ 184 185 #ifdef MAXPATHLEN 186 #define FILENAME_MAX MAXPATHLEN 187 #endif /* defined MAXPATHLEN */ 188 #ifndef MAXPATHLEN 189 #define FILENAME_MAX 1024 /* Pure guesswork */ 190 #endif /* !defined MAXPATHLEN */ 191 192 #endif /* !defined FILENAME_MAX */ 193 194 /* 195 ** SunOS 4.1.1 libraries lack remove. 196 */ 197 198 #ifndef remove 199 extern int unlink P((const char * filename)); 200 #define remove unlink 201 #endif /* !defined remove */ 202 203 #if 0 204 /* 205 ** Some ancient errno.h implementations don't declare errno. 206 ** But some newer errno.h implementations define it as a macro. 207 ** Fix the former without affecting the latter. 208 */ 209 #ifndef errno 210 extern int errno; 211 #endif /* !defined errno */ 212 #endif 213 214 /* 215 ** Private function declarations. 216 */ 217 char * icalloc P((int nelem, int elsize)); 218 char * icatalloc P((char * old, const char * new)); 219 char * icpyalloc P((const char * string)); 220 char * imalloc P((int n)); 221 void * irealloc P((void * pointer, int size)); 222 void icfree P((char * pointer)); 223 void ifree P((char * pointer)); 224 char * scheck P((const char *string, const char *format)); 225 226 227 /* 228 ** Finally, some convenience items. 229 */ 230 231 #ifndef TRUE 232 #define TRUE 1 233 #endif /* !defined TRUE */ 234 235 #ifndef FALSE 236 #define FALSE 0 237 #endif /* !defined FALSE */ 238 239 #ifndef TYPE_BIT 240 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) 241 #endif /* !defined TYPE_BIT */ 242 243 #ifndef TYPE_SIGNED 244 #define TYPE_SIGNED(type) (((type) -1) < 0) 245 #endif /* !defined TYPE_SIGNED */ 246 247 #ifndef INT_STRLEN_MAXIMUM 248 /* 249 ** 302 / 1000 is log10(2.0) rounded up. 250 ** Subtract one for the sign bit if the type is signed; 251 ** add one for integer division truncation; 252 ** add one more for a minus sign if the type is signed. 253 */ 254 #define INT_STRLEN_MAXIMUM(type) \ 255 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) 256 #endif /* !defined INT_STRLEN_MAXIMUM */ 257 258 /* 259 ** INITIALIZE(x) 260 */ 261 262 #ifndef GNUC_or_lint 263 #ifdef lint 264 #define GNUC_or_lint 265 #endif /* defined lint */ 266 #ifndef lint 267 #ifdef __GNUC__ 268 #define GNUC_or_lint 269 #endif /* defined __GNUC__ */ 270 #endif /* !defined lint */ 271 #endif /* !defined GNUC_or_lint */ 272 273 #ifndef INITIALIZE 274 #ifdef GNUC_or_lint 275 #define INITIALIZE(x) ((x) = 0) 276 #endif /* defined GNUC_or_lint */ 277 #ifndef GNUC_or_lint 278 #define INITIALIZE(x) 279 #endif /* !defined GNUC_or_lint */ 280 #endif /* !defined INITIALIZE */ 281 282 /* 283 ** For the benefit of GNU folk... 284 ** `_(MSGID)' uses the current locale's message library string for MSGID. 285 ** The default is to use gettext if available, and use MSGID otherwise. 286 */ 287 288 #ifndef _ 289 #if HAVE_GETTEXT - 0 290 #define _(msgid) gettext(msgid) 291 #else /* !(HAVE_GETTEXT - 0) */ 292 #define _(msgid) msgid 293 #endif /* !(HAVE_GETTEXT - 0) */ 294 #endif /* !defined _ */ 295 296 #ifndef TZ_DOMAIN 297 #define TZ_DOMAIN "tz" 298 #endif /* !defined TZ_DOMAIN */ 299 300 #if HAVE_INCOMPATIBLE_CTIME_R 301 #undef asctime_r 302 #undef ctime_r 303 char *asctime_r P((struct tm const *, char *)); 304 char *ctime_r P((time_t const *, char *)); 305 #endif /* HAVE_INCOMPATIBLE_CTIME_R */ 306 307 /* 308 ** UNIX was a registered trademark of UNIX System Laboratories in 1993. 309 */ 310 311 #endif /* !defined PRIVATE_H */ 312