92 lines
2.8 KiB
C
92 lines
2.8 KiB
C
#ifndef _TIME_STATE_H
|
|
#define _TIME_STATE_H
|
|
|
|
#include "time_header.h"
|
|
#include "time_tzfile.h"
|
|
|
|
#define GMT_CHAR_SIZE 3
|
|
#define TZ_STRLEN_MAX 255
|
|
|
|
#ifndef WILDABBR
|
|
/*
|
|
* Someone might make incorrect use of a time zone abbreviation:
|
|
* 1. They might reference tzname[0] before calling tzset (explicitly
|
|
* or implicitly).
|
|
* 2. They might reference tzname[1] before calling tzset (explicitly
|
|
* or implicitly).
|
|
* 3. They might reference tzname[1] after setting to a time zone
|
|
* in which Daylight Saving Time is never observed.
|
|
* 4. They might reference tzname[0] after setting to a time zone
|
|
* in which Standard Time is never observed.
|
|
* 5. They might reference tm.tm_zone after calling offtime.
|
|
* What's best to do in the above cases is open to debate;
|
|
* for now, we just set things up so that in any of the five cases
|
|
* WILDABBR is used. Another possibility: initialize tzname[0] to the
|
|
* string "tzname[0] used before set", and similarly for the other cases.
|
|
* And another: initialize tzname[0] to "ERA", with an explanation in the
|
|
* manual page of what this "time zone abbreviation" means (doing this so
|
|
* that tzname[0] has the "normal" length of three characters).
|
|
*/
|
|
#define WILDABBR " "
|
|
#define WILDABBR_SIZE 3
|
|
#endif
|
|
|
|
extern const char wildabbr[WILDABBR_SIZE];
|
|
extern const char gmt[GMT_CHAR_SIZE];
|
|
|
|
extern char* tzname[2];
|
|
extern char lcl_TZname[TZ_STRLEN_MAX + 1];
|
|
extern int lcl_is_set;
|
|
|
|
#define SMALLEST(a, b) (((a) < (b)) ? (a) : (b))
|
|
#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#ifdef TZNAME_MAX
|
|
# define MY_TZNAME_MAX TZNAME_MAX
|
|
#endif
|
|
#ifndef TZNAME_MAX
|
|
# define MY_TZNAME_MAX 255
|
|
#endif
|
|
|
|
struct ttinfo { /* time type information */
|
|
int_fast32_t tt_gmtoff; /* UT offset in seconds */
|
|
bool tt_isdst; /* used to set tm_isdst */
|
|
int tt_abbrind; /* abbreviation list index */
|
|
bool tt_ttisstd; /* transition is std time */
|
|
bool tt_ttisgmt; /* transition is UT */
|
|
};
|
|
|
|
struct lsinfo { /* leap second information */
|
|
time_t ls_trans; /* transition time */
|
|
int_fast64_t ls_corr; /* correction to apply */
|
|
};
|
|
|
|
struct state {
|
|
int leapcnt;
|
|
int timecnt;
|
|
int typecnt;
|
|
int charcnt;
|
|
bool goback;
|
|
bool goahead;
|
|
time_t ats[TZ_MAX_TIMES];
|
|
unsigned char types[TZ_MAX_TIMES];
|
|
struct ttinfo ttis[TZ_MAX_TYPES];
|
|
char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, GMT_CHAR_SIZE),
|
|
(2 * (MY_TZNAME_MAX + 1)))];
|
|
struct lsinfo lsis[TZ_MAX_LEAPS];
|
|
int defaulttype; /* for early times or if no transitions */
|
|
};
|
|
|
|
extern struct state *lclptr;
|
|
extern struct state *gmtptr;
|
|
|
|
extern long timezone;
|
|
extern int daylight;
|
|
extern long altzone;
|
|
|
|
extern int errno;
|
|
|
|
int zonechg;
|
|
|
|
#endif
|