zdump.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1986-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* zdump 7.24
* Taken from elsie.nci.nih.gov to replace the existing Solaris zdump,
* which was based on an earlier version of the elsie code.
*
* For zdump 7.24, the following changes were made to the elsie code:
* locale/textdomain/messages to match existing Solaris style.
* Solaris verbose mode is documented to display the current time first.
* cstyle cleaned code.
* removed old locale/textdomain code.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* static char elsieid[] = "@(#)zdump.c 7.28"; */
/*
* This code has been made independent of the rest of the time
* conversion package to increase confidence in the verification it provides.
* You can use this code to help in verifying other implementations.
*/
#include "stdio.h" /* for stdout, stderr, perror */
#include "string.h" /* for strcpy */
#include "time.h" /* for struct tm */
#include "stdlib.h" /* for exit, malloc, atoi */
#include "locale.h" /* for setlocale, textdomain */
#include "libintl.h"
#include "tzfile.h" /* for defines */
#ifndef MAX_STRING_LENGTH
#define MAX_STRING_LENGTH 1024
#endif /* !defined MAX_STRING_LENGTH */
#ifndef TRUE
#define TRUE 1
#endif /* !defined TRUE */
#ifndef FALSE
#define FALSE 0
#endif /* !defined FALSE */
#ifndef INITIALIZE
#ifdef lint
#define INITIALIZE(x) ((x) = 0)
#endif /* defined lint */
#ifndef lint
#define INITIALIZE(x)
#endif /* !defined lint */
#endif /* !defined INITIALIZE */
extern char ** environ;
static char * progname;
static void usage(char *);
int
int argc;
char * argv[];
{
register int i;
register int c;
register int vflag;
register char * cutoff;
register int cutyear;
register long cuttime;
char ** fakeenv;
time_t t;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
vflag = 0;
if (c == 'v')
vflag = 1;
if (c != EOF ||
/* NOTREACHED */
}
int y;
cuttime = 0;
for (y = EPOCH_YEAR; y < cutyear; ++y)
}
longest = 0;
continue;
{
register int from;
register int to;
continue;
sizeof (*fakeenv)));
(void) exit(EXIT_FAILURE);
}
to = 0;
}
static char buf[MAX_STRING_LENGTH];
if (!vflag) {
continue;
}
#if defined(sun)
/*
* We show the current time first, probably because we froze
* the behavior of zdump some time ago and then it got
* changed.
*/
#endif
/*
* Get lowest value of t.
*/
t = hibit;
if (t > 0) /* time_t is unsigned */
t = 0;
t += SECSPERHOUR * HOURSPERDAY;
for (;;) {
break;
break;
if (newt <= t)
break;
(sizeof (buf)) - 1);
}
t = newt;
}
/*
* Get highest value of t.
*/
t = ~((time_t) 0);
if (t < 0) /* time_t is signed */
t &= ~hibit;
#if defined(sun)
t -= SECSPERHOUR * HOURSPERDAY;
#else /* !defined(sun) */
t -= SECSPERHOUR * HOURSPERDAY;
t += SECSPERHOUR * HOURSPERDAY;
#endif /* !defined(sun) */
}
"%s: Error writing standard output "), argv[0]);
}
return (EXIT_SUCCESS);
}
static time_t
char * name;
{
time_t t;
static char loab[MAX_STRING_LENGTH];
if (t <= lot)
++t;
else if (t >= hit)
--t;
lot = t;
} else hit = t;
}
return (hit);
}
/*
* Thanks to Paul Eggert (eggert@twinsun.com) for logic used in delta.
*/
static long
{
long result;
int tmy;
result = 0;
result *= HOURSPERDAY;
result *= MINSPERHOUR;
result *= SECSPERMIN;
return (result);
}
static void
char * zone;
time_t t;
int v;
{
if (v)
if (v) {
}
(void) printf("\n");
}
static char *
{
register char * result;
static char nada;
return (&nada);
}
static void
{
"%s: [ -v ] [ -c cutoffyear ] [ zonename ... ]\n"), progname);
(void) exit(EXIT_FAILURE);
/* NOTREACHED */
}