1 #ifndef PRIVATE_H 2 3 #define PRIVATE_H 4 5 /* 6 ** This header is for use ONLY with the time conversion code. 7 ** There is no guarantee that it will remain unchanged, 8 ** or that it will remain at all. 9 ** Do NOT copy it to any system include directory. 10 ** Thank you! 11 */ 12 13 /* 14 ** ID 15 */ 16 17 #ifndef lint 18 #ifndef NOID 19 static char privatehid[] = "@(#)private.h 7.35"; 20 #endif /* !defined NOID */ 21 #endif /* !defined lint */ 22 23 /* 24 ** Defaults for preprocessor symbols. 25 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. 26 */ 27 28 #ifndef HAVE_ADJTIME 29 #define HAVE_ADJTIME 1 30 #endif /* !defined HAVE_ADJTIME */ 31 32 #ifndef HAVE_SETTIMEOFDAY 33 #define HAVE_SETTIMEOFDAY 3 34 #endif /* !defined HAVE_SETTIMEOFDAY */ 35 36 #ifndef HAVE_UNISTD_H 37 #define HAVE_UNISTD_H 1 38 #endif /* !defined HAVE_UNISTD_H */ 39 40 #ifndef LOCALE_HOME 41 #define LOCALE_HOME "/usr/lib/locale" 42 #endif /* !defined LOCALE_HOME */ 43 44 /* 45 ** Nested includes 46 */ 47 48 #include "sys/types.h" /* for time_t */ 49 #include "stdio.h" 50 #include "errno.h" 51 #include "string.h" 52 #include "limits.h" /* for CHAR_BIT */ 53 #include "time.h" 54 #include "stdlib.h" 55 56 #if HAVE_UNISTD_H - 0 57 #include "unistd.h" /* for F_OK and R_OK */ 58 #endif /* HAVE_UNISTD_H - 0 */ 59 60 #if !(HAVE_UNISTD_H - 0) 61 #ifndef F_OK 62 #define F_OK 0 63 #endif /* !defined F_OK */ 64 #ifndef R_OK 65 #define R_OK 4 66 #endif /* !defined R_OK */ 67 #endif /* !(HAVE_UNISTD_H - 0) */ 68 69 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 70 #define is_digit(c) ((unsigned)(c) - '0' <= 9) 71 72 /* 73 ** Workarounds for compilers/systems. 74 */ 75 76 /* 77 ** SunOS 4.1.1 cc lacks const. 78 */ 79 80 #ifndef const 81 #ifndef __STDC__ 82 #define const 83 #endif /* !defined __STDC__ */ 84 #endif /* !defined const */ 85 86 /* 87 ** SunOS 4.1.1 cc lacks prototypes. 88 */ 89 90 #ifndef P 91 #ifdef __STDC__ 92 #define P(x) x 93 #endif /* defined __STDC__ */ 94 #ifndef __STDC__ 95 #define P(x) () 96 #endif /* !defined __STDC__ */ 97 #endif /* !defined P */ 98 99 /* 100 ** SunOS 4.1.1 headers lack EXIT_SUCCESS. 101 */ 102 103 #ifndef EXIT_SUCCESS 104 #define EXIT_SUCCESS 0 105 #endif /* !defined EXIT_SUCCESS */ 106 107 /* 108 ** SunOS 4.1.1 headers lack EXIT_FAILURE. 109 */ 110 111 #ifndef EXIT_FAILURE 112 #define EXIT_FAILURE 1 113 #endif /* !defined EXIT_FAILURE */ 114 115 /* 116 ** SunOS 4.1.1 headers lack FILENAME_MAX. 117 */ 118 119 #ifndef FILENAME_MAX 120 121 #ifndef MAXPATHLEN 122 #ifdef unix 123 #include "sys/param.h" 124 #endif /* defined unix */ 125 #endif /* !defined MAXPATHLEN */ 126 127 #ifdef MAXPATHLEN 128 #define FILENAME_MAX MAXPATHLEN 129 #endif /* defined MAXPATHLEN */ 130 #ifndef MAXPATHLEN 131 #define FILENAME_MAX 1024 /* Pure guesswork */ 132 #endif /* !defined MAXPATHLEN */ 133 134 #endif /* !defined FILENAME_MAX */ 135 136 /* 137 ** SunOS 4.1.1 libraries lack remove. 138 */ 139 140 #ifndef remove 141 extern int unlink P((const char * filename)); 142 #define remove unlink 143 #endif /* !defined remove */ 144 145 /* 146 ** Finally, some convenience items. 147 */ 148 149 #ifndef TRUE 150 #define TRUE 1 151 #endif /* !defined TRUE */ 152 153 #ifndef FALSE 154 #define FALSE 0 155 #endif /* !defined FALSE */ 156 157 #ifndef INT_STRLEN_MAXIMUM 158 /* 159 ** 302 / 1000 is log10(2.0) rounded up. 160 ** If type is signed: 161 ** subtract one for the sign bit; 162 ** add one for integer division truncation; 163 ** add one more for a minus sign. 164 ** If type is unsigned: 165 ** do not subtract one since there is no sign bit; 166 ** add one for integer division truncation; 167 ** do not add one more for a minus sign. 168 */ 169 #define INT_STRLEN_MAXIMUM(type) \ 170 ((((type) -1) < 0) ? \ 171 ((sizeof(type) * CHAR_BIT - 1) * 302 / 1000 + 2) : \ 172 ((sizeof(type) * CHAR_BIT) * 302 / 1000 + 1)) 173 #endif /* !defined INT_STRLEN_MAXIMUM */ 174 175 /* 176 ** INITIALIZE(x) 177 */ 178 179 #ifndef GNUC_or_lint 180 #ifdef lint 181 #define GNUC_or_lint 182 #endif /* defined lint */ 183 #ifndef lint 184 #ifdef __GNUC__ 185 #define GNUC_or_lint 186 #endif /* defined __GNUC__ */ 187 #endif /* !defined lint */ 188 #endif /* !defined GNUC_or_lint */ 189 190 #ifndef INITIALIZE 191 #ifdef GNUC_or_lint 192 #define INITIALIZE(x) ((x) = 0) 193 #endif /* defined GNUC_or_lint */ 194 #ifndef GNUC_or_lint 195 #define INITIALIZE(x) 196 #endif /* !defined GNUC_or_lint */ 197 #endif /* !defined INITIALIZE */ 198 199 /* 200 ** UNIX was a registered trademark of UNIX System Laboratories in 1993. 201 */ 202 203 #endif /* !defined PRIVATE_H */ 204