TZ-Lib  $VERSION$
zdump.c File Reference
#include "version.h"
#include "private.h"
#include "stdio.h"
#include "string.h"
#include "sys/types.h"
#include "time.h"
#include "stdlib.h"
#include "limits.h"
#include <errno.h>

Macros

#define __EXTENSIONS__   1
 
#define _GNU_SOURCE   1
 
#define ATTRIBUTE_PURE   /* empty */
 
#define bool   int
 
#define DAYSPERNYEAR   365
 
#define DIVISOR   10
 
#define EPOCH_YEAR   1970
 
#define EXIT_FAILURE   1
 
#define EXIT_SUCCESS   0
 
#define false   0
 
#define HAVE_LOCALTIME_R   1
 
#define HAVE_LOCALTIME_RZ   0
 
#define HAVE_TZSET   1
 
#define HOURSPERDAY   24
 
#define is_digit(c)   ((unsigned)(c) - '0' <= 9)
 
#define isleap(y)   (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
 
#define isleap_sum(a, b)   isleap((a) % 400 + (b) % 400)
 
#define localtime_r   zdump_localtime_r
 
#define localtime_rz   zdump_localtime_rz
 
#define MAX_STRING_LENGTH   1024
 
#define MINSPERHOUR   60
 
#define my_localtime_rz   localtime_rz
 
#define SECSPER400YEARS
 
#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
 
#define SECSPERHOUR   (SECSPERMIN * MINSPERHOUR)
 
#define SECSPERLYEAR   (SECSPERNYEAR + SECSPERDAY)
 
#define SECSPERMIN   60
 
#define SECSPERNYEAR   (SECSPERDAY * DAYSPERNYEAR)
 
#define timezone_t   char **
 
#define TM_YEAR_BASE   1900
 
#define true   1
 
#define tzalloc   zdump_tzalloc
 
#define tzfree   zdump_tzfree
 
#define USE_LOCALTIME_RZ   false
 
#define USE_LTZ   1
 
#define ZDUMP_HI_YEAR   2500
 
#define ZDUMP_LO_YEAR   (-500)
 

Enumerations

enum  
 
enum  { atime_shift = CHAR_BIT * sizeof (time_t) - 2 }
 

Functions

static char const * abbr (struct tm const *)
 
static void abbrok (const char *const abbrp, const char *const zone)
 
static int adjusted_yday (struct tm const *a, struct tm const *b)
 
static void close_file (FILE *stream)
 
static intmax_t delta (struct tm *, struct tm *)
 
static void dumptime (register const struct tm *timeptr)
 
static int format_local_time (char *buf, size_t size, struct tm const *tm)
 
static size_t format_quoted_string (char *buf, size_t size, char const *p)
 
static int format_utc_offset (char *buf, size_t size, struct tm const *tm, time_t t)
 
static long gmtoff (struct tm const *a, time_t *t, struct tm const *b)
 
static void gmtzinit (void)
 
static time_t hunt (timezone_t tz, char *name, time_t lot, time_t hit)
 
static bool istrftime (char *buf, size_t size, char const *time_fmt, struct tm const *tm, time_t t, char const *ab, char const *zone_name)
 
static struct tmlocaltime_r (time_t *tp, struct tm *tmp)
 
static struct tmlocaltime_rz (timezone_t rz, time_t *tp, struct tm *tmp)
 
int main (int argc, char *argv[])
 
static struct tmmy_gmtime_r (time_t *tp, struct tm *tmp)
 
static char const * saveabbr (char **buf, size_t *bufalloc, struct tm const *tmp)
 
static void show (timezone_t tz, char *zone, time_t t, bool v)
 
static void showtrans (char const *time_fmt, struct tm const *tm, time_t t, char const *ab, char const *zone_name)
 
static size_t sumsize (size_t a, size_t b)
 
static const char * tformat (void)
 
static timezone_t tzalloc (char const *val)
 
static void tzfree (timezone_t env)
 
static void usage (FILE *const stream, const int status)
 
static void * xmalloc (size_t size)
 
static time_t yeartot (intmax_t y)
 

Variables

static time_t const absolute_max_time
 
static time_t const absolute_min_time
 
char ** environ
 
static bool errout
 
static timezone_t gmtz
 
static int longest
 
static char * progname
 
static bool warned
 

Macro Definition Documentation

#define __EXTENSIONS__   1
#define _GNU_SOURCE   1
#define ATTRIBUTE_PURE   /* empty */
#define bool   int
#define DAYSPERNYEAR   365
#define DIVISOR   10

Referenced by dumptime().

#define EPOCH_YEAR   1970

Referenced by yeartot().

#define EXIT_SUCCESS   0

Referenced by errensure(), main(), and usage().

#define false   0
#define HAVE_LOCALTIME_R   1
#define HAVE_LOCALTIME_RZ   0

Referenced by saveabbr().

#define HAVE_TZSET   1
#define HOURSPERDAY   24
#define is_digit (   c)    ((unsigned)(c) - '0' <= 9)

Referenced by abbrok().

#define isleap (   y)    (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))

Referenced by yeartot().

#define isleap_sum (   a,
 
)    isleap((a) % 400 + (b) % 400)

Referenced by adjusted_yday().

#define localtime_r   zdump_localtime_r

Referenced by localtime_rz().

#define localtime_rz   zdump_localtime_rz

Referenced by main(), and my_gmtime_r().

#define MAX_STRING_LENGTH   1024
#define MINSPERHOUR   60
#define my_localtime_rz   localtime_rz

Referenced by hunt(), main(), and show().

#define SECSPER400YEARS
Value:
(SECSPERNYEAR * (intmax_t) (300 + 3) \
+ SECSPERLYEAR * (intmax_t) (100 - 3))
#define SECSPERNYEAR
Definition: zdump.c:210
#define SECSPERLYEAR
Definition: zdump.c:211
long intmax_t
Definition: private.h:243

Referenced by yeartot().

#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)

Referenced by main().

#define SECSPERHOUR   (SECSPERMIN * MINSPERHOUR)
#define SECSPERLYEAR   (SECSPERNYEAR + SECSPERDAY)

Referenced by yeartot().

#define SECSPERMIN   60
#define SECSPERNYEAR   (SECSPERDAY * DAYSPERNYEAR)

Referenced by yeartot().

#define timezone_t   char **
#define TM_YEAR_BASE   1900

Referenced by adjusted_yday(), and dumptime().

#define true   1
#define tzalloc   zdump_tzalloc

Referenced by gmtzinit(), and main().

#define tzfree   zdump_tzfree

Referenced by main().

#define USE_LOCALTIME_RZ   false

Referenced by gmtzinit(), and my_gmtime_r().

#define USE_LTZ   1
#define ZDUMP_HI_YEAR   2500

Referenced by main().

#define ZDUMP_LO_YEAR   (-500)

Referenced by main().

Enumeration Type Documentation

anonymous enum
anonymous enum
Enumerator
atime_shift 

Function Documentation

static char const * abbr ( struct tm const *  tmp)
static
static void abbrok ( const char *const  abbrp,
const char *const  zone 
)
static

References _, is_alpha(), and is_digit.

Referenced by show().

static int adjusted_yday ( struct tm const *  a,
struct tm const *  b 
)
static

References isleap_sum, and TM_YEAR_BASE.

Referenced by gmtoff().

static void close_file ( FILE *  stream)
static

References _, and EXIT_FAILURE.

Referenced by main(), and usage().

static intmax_t delta ( struct tm newp,
struct tm oldp 
)
static

Referenced by hunt(), and main().

static void dumptime ( register const struct tm timeptr)
static

References DIVISOR, and TM_YEAR_BASE.

Referenced by show().

static int format_local_time ( char *  buf,
size_t  size,
struct tm const *  tm 
)
static

Referenced by istrftime().

static size_t format_quoted_string ( char *  buf,
size_t  size,
char const *  p 
)
static

Referenced by istrftime().

static int format_utc_offset ( char *  buf,
size_t  size,
struct tm const *  tm,
time_t  t 
)
static

References abbr(), and gmtoff().

Referenced by istrftime().

static long gmtoff ( struct tm const *  a,
time_t *  t,
struct tm const *  b 
)
static
static void gmtzinit ( void  )
static

References EXIT_FAILURE, tzalloc, and USE_LOCALTIME_RZ.

Referenced by main().

static time_t hunt ( timezone_t  tz,
char *  name,
time_t  lot,
time_t  hit 
)
static

References abbr(), delta(), my_localtime_rz, saveabbr(), and tm.

Referenced by main().

static bool istrftime ( char *  buf,
size_t  size,
char const *  time_fmt,
struct tm const *  tm,
time_t  t,
char const *  ab,
char const *  zone_name 
)
static
static struct tm* localtime_r ( time_t *  tp,
struct tm tmp 
)
static

References localtime(), and tm.

static struct tm* localtime_rz ( timezone_t  rz,
time_t *  tp,
struct tm tmp 
)
static

References localtime_r.

static struct tm* my_gmtime_r ( time_t *  tp,
struct tm tmp 
)
static

References gmtime_r(), localtime_rz, and USE_LOCALTIME_RZ.

Referenced by gmtoff(), and show().

static char const* saveabbr ( char **  buf,
size_t *  bufalloc,
struct tm const *  tmp 
)
static

References abbr(), HAVE_LOCALTIME_RZ, sumsize(), and xmalloc().

Referenced by hunt(), and main().

static void show ( timezone_t  tz,
char *  zone,
time_t  t,
bool  v 
)
static
static void showtrans ( char const *  time_fmt,
struct tm const *  tm,
time_t  t,
char const *  ab,
char const *  zone_name 
)
static

References istrftime(), sumsize(), tformat(), and xmalloc().

Referenced by main().

static size_t sumsize ( size_t  a,
size_t  b 
)
static

References EXIT_FAILURE.

Referenced by saveabbr(), showtrans(), and tzalloc().

static const char* tformat ( void  )
static

References PRIdMAX, and PRIuMAX.

Referenced by show(), and showtrans().

static timezone_t tzalloc ( char const *  val)
static

References environ, sumsize(), tzset(), and xmalloc().

static void tzfree ( timezone_t  env)
static

References environ.

static void usage ( FILE *const  stream,
const int  status 
)
static

References _, close_file(), EXIT_SUCCESS, and REPORT_BUGS_TO.

Referenced by main().

static void* xmalloc ( size_t  size)
static

References EXIT_FAILURE.

Referenced by istrftime(), saveabbr(), showtrans(), and tzalloc().

static time_t yeartot ( intmax_t  y)
static

Variable Documentation

time_t const absolute_max_time
static
Initial value:
=
((time_t) -1 < 0
? (((time_t) 1 << atime_shift) - 1 + ((time_t) 1 << atime_shift))
: -1)
Definition: zdump.c:272

Referenced by main(), and yeartot().

time_t const absolute_min_time
static
Initial value:
=
((time_t) -1 < 0
? (- ((time_t) ~ (time_t) 0 < 0)
- (((time_t) 1 << atime_shift) - 1 + ((time_t) 1 << atime_shift)))
: 0)
Definition: zdump.c:272

Referenced by main(), and yeartot().

char** environ

Referenced by tzalloc(), and tzfree().

bool errout
static
timezone_t gmtz
static
int longest
static
char* progname
static
bool warned
static