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