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