2004-06-18 08:11:31 +02:00
|
|
|
/* Copyright (C) 2004 MySQL AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2004-06-18 08:11:31 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file is based on public domain code from ftp://elsie.ncih.nist.gov/
|
|
|
|
Initial source code is in the public domain, so clarified as of
|
|
|
|
1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Information about time zone files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TZDIR
|
|
|
|
#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
|
|
|
|
#endif /* !defined TZDIR */
|
|
|
|
|
|
|
|
/*
|
|
|
|
Each file begins with. . .
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define TZ_MAGIC "TZif"
|
|
|
|
|
|
|
|
struct tzhead {
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
2007-05-10 11:59:39 +02:00
|
|
|
uchar tzh_magic[4]; /* TZ_MAGIC */
|
|
|
|
uchar tzh_reserved[16]; /* reserved for future use */
|
|
|
|
uchar tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
|
|
|
|
uchar tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
|
|
|
|
uchar tzh_leapcnt[4]; /* coded number of leap seconds */
|
|
|
|
uchar tzh_timecnt[4]; /* coded number of transition times */
|
|
|
|
uchar tzh_typecnt[4]; /* coded number of local time types */
|
|
|
|
uchar tzh_charcnt[4]; /* coded number of abbr. chars */
|
2004-06-18 08:11:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
. . .followed by. . .
|
|
|
|
|
|
|
|
tzh_timecnt (char [4])s coded transition times a la time(2)
|
|
|
|
tzh_timecnt (unsigned char)s types of local time starting at above
|
|
|
|
tzh_typecnt repetitions of
|
|
|
|
one (char [4]) coded UTC offset in seconds
|
|
|
|
one (unsigned char) used to set tm_isdst
|
|
|
|
one (unsigned char) that's an abbreviation list index
|
|
|
|
tzh_charcnt (char)s '\0'-terminated zone abbreviations
|
|
|
|
tzh_leapcnt repetitions of
|
|
|
|
one (char [4]) coded leap second transition times
|
|
|
|
one (char [4]) total correction after above
|
|
|
|
tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
|
|
|
|
time is standard time, if FALSE,
|
|
|
|
transition time is wall clock time
|
|
|
|
if absent, transition times are
|
|
|
|
assumed to be wall clock time
|
|
|
|
tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
|
|
|
|
time is UTC, if FALSE,
|
|
|
|
transition time is local time
|
|
|
|
if absent, transition times are
|
|
|
|
assumed to be local time
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
In the current implementation, we refuse to deal with files that
|
|
|
|
exceed any of the limits below.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TZ_MAX_TIMES
|
|
|
|
/*
|
|
|
|
The TZ_MAX_TIMES value below is enough to handle a bit more than a
|
|
|
|
year's worth of solar time (corrected daily to the nearest second) or
|
|
|
|
138 years of Pacific Presidential Election time
|
|
|
|
(where there are three time zone transitions every fourth year).
|
|
|
|
*/
|
|
|
|
#define TZ_MAX_TIMES 370
|
|
|
|
#endif /* !defined TZ_MAX_TIMES */
|
|
|
|
|
|
|
|
#ifndef TZ_MAX_TYPES
|
|
|
|
#ifdef SOLAR
|
|
|
|
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
Must be at least 14 for Europe/Riga as of Jan 12 1995,
|
|
|
|
as noted by Earl Chew <earl@hpato.aus.hp.com>.
|
|
|
|
*/
|
|
|
|
#define TZ_MAX_TYPES 20 /* Maximum number of local time types */
|
|
|
|
#endif /* defined SOLAR */
|
|
|
|
#endif /* !defined TZ_MAX_TYPES */
|
|
|
|
|
|
|
|
#ifndef TZ_MAX_CHARS
|
|
|
|
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
|
|
|
|
/* (limited by what unsigned chars can hold) */
|
|
|
|
#endif /* !defined TZ_MAX_CHARS */
|
|
|
|
|
|
|
|
#ifndef TZ_MAX_LEAPS
|
|
|
|
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
|
|
|
|
#endif /* !defined TZ_MAX_LEAPS */
|
|
|
|
|
|
|
|
#ifndef TZ_MAX_REV_RANGES
|
|
|
|
#ifdef SOLAR
|
|
|
|
/* Solar (Asia/RiyadhXX) zones need significantly bigger TZ_MAX_REV_RANGES */
|
|
|
|
#define TZ_MAX_REV_RANGES (TZ_MAX_TIMES*2+TZ_MAX_LEAPS*2+2)
|
|
|
|
#else
|
|
|
|
#define TZ_MAX_REV_RANGES (TZ_MAX_TIMES+TZ_MAX_LEAPS+2)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SECS_PER_MIN 60
|
|
|
|
#define MINS_PER_HOUR 60
|
|
|
|
#define HOURS_PER_DAY 24
|
|
|
|
#define DAYS_PER_WEEK 7
|
|
|
|
#define DAYS_PER_NYEAR 365
|
|
|
|
#define DAYS_PER_LYEAR 366
|
|
|
|
#define SECS_PER_HOUR (SECS_PER_MIN * MINS_PER_HOUR)
|
|
|
|
#define SECS_PER_DAY ((long) SECS_PER_HOUR * HOURS_PER_DAY)
|
|
|
|
#define MONS_PER_YEAR 12
|
|
|
|
|
|
|
|
#define TM_YEAR_BASE 1900
|
|
|
|
|
|
|
|
#define EPOCH_YEAR 1970
|
|
|
|
|
|
|
|
/*
|
|
|
|
Accurate only for the past couple of centuries,
|
|
|
|
that will probably do.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|