Wed Oct 28 11:51:08 2009

Asterisk developer's documentation


tzfile.h

Go to the documentation of this file.
00001 #ifndef TZFILE_H
00002 
00003 #define TZFILE_H
00004 
00005 /*
00006 ** This file is in the public domain, so clarified as of
00007 ** 1996-06-05 by Arthur David Olson.
00008 */
00009 
00010 /*
00011 ** This header is for use ONLY with the time conversion code.
00012 ** There is no guarantee that it will remain unchanged,
00013 ** or that it will remain at all.
00014 ** Do NOT copy it to any system include directory.
00015 ** Thank you!
00016 */
00017 
00018 /*
00019 ** ID
00020 */
00021 
00022 #ifndef lint
00023 #ifndef NOID
00024 static char __attribute__((unused)) tzfilehid[] = "@(#)tzfile.h   8.1";
00025 #endif /* !defined NOID */
00026 #endif /* !defined lint */
00027 
00028 /*
00029 ** Information about time zone files.
00030 */
00031 
00032 #ifndef TZDIR
00033 #ifdef SOLARIS
00034 #define TZDIR  "/usr/share/lib/zoneinfo"
00035 #else
00036 #define TZDIR  "/usr/share/zoneinfo"
00037 #endif /* defined SOLARIS */
00038 #endif /* !defined TZDIR */
00039 
00040 #ifndef TZDEFAULT
00041 #define TZDEFAULT "localtime"
00042 #endif /* !defined TZDEFAULT */
00043 
00044 #ifndef TZDEFRULES
00045 #define TZDEFRULES   "posixrules"
00046 #endif /* !defined TZDEFRULES */
00047 
00048 /*
00049 ** Each file begins with. . .
00050 */
00051 
00052 #define  TZ_MAGIC "TZif"
00053 
00054 struct tzhead {
00055    char  tzh_magic[4];     /* TZ_MAGIC */
00056    char  tzh_version[1];      /* '\0' or '2' as of 2005 */
00057    char  tzh_reserved[15]; /* reserved--must be zero */
00058    char  tzh_ttisgmtcnt[4];   /* coded number of trans. time flags */
00059    char  tzh_ttisstdcnt[4];   /* coded number of trans. time flags */
00060    char  tzh_leapcnt[4];      /* coded number of leap seconds */
00061    char  tzh_timecnt[4];      /* coded number of transition times */
00062    char  tzh_typecnt[4];      /* coded number of local time types */
00063    char  tzh_charcnt[4];      /* coded number of abbr. chars */
00064 };
00065 
00066 /*
00067 ** . . .followed by. . .
00068 **
00069 ** tzh_timecnt (char [4])s    coded transition times a la time(2)
00070 ** tzh_timecnt (unsigned char)s  types of local time starting at above
00071 ** tzh_typecnt repetitions of
00072 **    one (char [4])    coded UTC offset in seconds
00073 **    one (unsigned char)  used to set tm_isdst
00074 **    one (unsigned char)  that's an abbreviation list index
00075 ** tzh_charcnt (char)s     '\0'-terminated zone abbreviations
00076 ** tzh_leapcnt repetitions of
00077 **    one (char [4])    coded leap second transition times
00078 **    one (char [4])    total correction after above
00079 ** tzh_ttisstdcnt (char)s     indexed by type; if TRUE, transition
00080 **             time is standard time, if FALSE,
00081 **             transition time is wall clock time
00082 **             if absent, transition times are
00083 **             assumed to be wall clock time
00084 ** tzh_ttisgmtcnt (char)s     indexed by type; if TRUE, transition
00085 **             time is UTC, if FALSE,
00086 **             transition time is local time
00087 **             if absent, transition times are
00088 **             assumed to be local time
00089 */
00090 
00091 /*
00092 ** If tzh_version is '2' or greater, the above is followed by a second instance
00093 ** of tzhead and a second instance of the data in which each coded transition
00094 ** time uses 8 rather than 4 chars,
00095 ** then a POSIX-TZ-environment-variable-style string for use in handling
00096 ** instants after the last transition time stored in the file
00097 ** (with nothing between the newlines if there is no POSIX representation for
00098 ** such instants).
00099 */
00100 
00101 /*
00102 ** In the current implementation, "tzset()" refuses to deal with files that
00103 ** exceed any of the limits below.
00104 */
00105 
00106 #ifndef TZ_MAX_TIMES
00107 #define TZ_MAX_TIMES 1200
00108 #endif /* !defined TZ_MAX_TIMES */
00109 
00110 #ifndef TZ_MAX_TYPES
00111 #ifndef NOSOLAR
00112 #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
00113 #endif /* !defined NOSOLAR */
00114 #ifdef NOSOLAR
00115 /*
00116 ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
00117 ** as noted by Earl Chew.
00118 */
00119 #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
00120 #endif /* !defined NOSOLAR */
00121 #endif /* !defined TZ_MAX_TYPES */
00122 
00123 #ifndef TZ_MAX_CHARS
00124 #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
00125             /* (limited by what unsigned chars can hold) */
00126 #endif /* !defined TZ_MAX_CHARS */
00127 
00128 #ifndef TZ_MAX_LEAPS
00129 #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
00130 #endif /* !defined TZ_MAX_LEAPS */
00131 
00132 #define SECSPERMIN   60
00133 #define MINSPERHOUR  60
00134 #define HOURSPERDAY  24
00135 #define DAYSPERWEEK  7
00136 #define DAYSPERNYEAR 365
00137 #define DAYSPERLYEAR 366
00138 #define SECSPERHOUR  (SECSPERMIN * MINSPERHOUR)
00139 #define SECSPERDAY   ((long) SECSPERHOUR * HOURSPERDAY)
00140 #define MONSPERYEAR  12
00141 
00142 #define TM_SUNDAY 0
00143 #define TM_MONDAY 1
00144 #define TM_TUESDAY   2
00145 #define TM_WEDNESDAY 3
00146 #define TM_THURSDAY  4
00147 #define TM_FRIDAY 5
00148 #define TM_SATURDAY  6
00149 
00150 #define TM_JANUARY   0
00151 #define TM_FEBRUARY  1
00152 #define TM_MARCH  2
00153 #define TM_APRIL  3
00154 #define TM_MAY    4
00155 #define TM_JUNE      5
00156 #define TM_JULY      6
00157 #define TM_AUGUST 7
00158 #define TM_SEPTEMBER 8
00159 #define TM_OCTOBER   9
00160 #define TM_NOVEMBER  10
00161 #define TM_DECEMBER  11
00162 
00163 #define TM_YEAR_BASE 1900
00164 
00165 #define EPOCH_YEAR   1970
00166 #define EPOCH_WDAY   TM_THURSDAY
00167 
00168 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
00169 
00170 /*
00171 ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
00172 ** isleap(y) == isleap(y % 400)
00173 ** and so
00174 ** isleap(a + b) == isleap((a + b) % 400)
00175 ** or
00176 ** isleap(a + b) == isleap(a % 400 + b % 400)
00177 ** This is true even if % means modulo rather than Fortran remainder
00178 ** (which is allowed by C89 but not C99).
00179 ** We use this to avoid addition overflow problems.
00180 */
00181 
00182 #define isleap_sum(a, b)   isleap((a) % 400 + (b) % 400)
00183 
00184 #endif /* !defined TZFILE_H */

Generated on Wed Oct 28 11:51:08 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6