mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2025-12-08 10:56:52 +00:00
standardization
SCCS-file: localtime.c SCCS-SID: 3.8
This commit is contained in:
committed by
Paul Eggert
parent
94ba00dd81
commit
25717439c8
103
localtime.c
103
localtime.c
@ -12,7 +12,42 @@ static char elsieid[] = "%W%";
|
|||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#ifdef MODERN
|
#if defined __TURBOC__
|
||||||
|
#include "io.h" /* to pick up prototypes for open and such */
|
||||||
|
#include "fcntl.h" /* to pick up O_BINARY and O_RDONLY bits */
|
||||||
|
#endif /* defined __TURBOC__ */
|
||||||
|
|
||||||
|
#ifdef unix
|
||||||
|
#include "fcntl.h"
|
||||||
|
#endif /* defined unix */
|
||||||
|
|
||||||
|
#ifdef O_BINARY
|
||||||
|
#ifdef O_RDONLY
|
||||||
|
#define OPEN_MODE O_BINARY | O_RDONLY
|
||||||
|
#endif /* defined O_RDONLY */
|
||||||
|
#endif /* defined O_BINARY */
|
||||||
|
|
||||||
|
#ifndef OPEN_MODE
|
||||||
|
#define OPEN_MODE 0
|
||||||
|
#endif /* !defined OPEN_MODE */
|
||||||
|
|
||||||
|
#ifdef O_RDONLY
|
||||||
|
#define ACCESS_MODE O_RDONLY
|
||||||
|
#else /* !defined O_RDONLY */
|
||||||
|
#define ACCESS_MODE 4
|
||||||
|
#endif /* !defined O_RDONLY */
|
||||||
|
|
||||||
|
#ifdef const
|
||||||
|
|
||||||
|
#include "sys/types.h" /* to get time_t */
|
||||||
|
|
||||||
|
extern char * getenv();
|
||||||
|
|
||||||
|
#ifndef MAXPATHLEN
|
||||||
|
#include "sys/param.h"
|
||||||
|
#endif /* !defined MAXPATHLEN */
|
||||||
|
|
||||||
|
#else /* !defined const */
|
||||||
|
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
@ -21,23 +56,7 @@ static char elsieid[] = "%W%";
|
|||||||
#define MAXPATHLEN FILENAME_MAX
|
#define MAXPATHLEN FILENAME_MAX
|
||||||
#endif /* defined FILENAME_MAX */
|
#endif /* defined FILENAME_MAX */
|
||||||
|
|
||||||
#else /* !defined MODERN */
|
#endif /* !defined const */
|
||||||
|
|
||||||
/*
|
|
||||||
** sys/types.h is included to get time_t.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sys/types.h"
|
|
||||||
|
|
||||||
extern char * getenv();
|
|
||||||
|
|
||||||
#ifndef MAXPATHLEN
|
|
||||||
#include "sys/param.h"
|
|
||||||
#endif /* !defined MAXPATHLEN */
|
|
||||||
|
|
||||||
#define const
|
|
||||||
|
|
||||||
#endif /* !defined MODERN */
|
|
||||||
|
|
||||||
#ifndef MAXPATHLEN
|
#ifndef MAXPATHLEN
|
||||||
#define MAXPATHLEN 1024
|
#define MAXPATHLEN 1024
|
||||||
@ -48,12 +67,17 @@ extern char * getenv();
|
|||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#endif /* !defined TRUE */
|
#endif /* !defined TRUE */
|
||||||
|
|
||||||
|
static long detzcode P((const char * codep));
|
||||||
#ifdef STD_INSPIRED
|
#ifdef STD_INSPIRED
|
||||||
struct tm * offtime();
|
struct tm * offtime P((const time_t * clockp, long offset));
|
||||||
#else /* !defined STD_INSPIRED */
|
#else /* !defined STD_INSPIRED */
|
||||||
static struct tm * offtime();
|
static struct tm * offtime P((const time_t * clockp, long offset));
|
||||||
#endif /* !defined STD_INSPIRED */
|
#endif /* !defined STD_INSPIRED */
|
||||||
static struct tm * timesub();
|
static struct tm * timesub P((const time_t * clockp, long offset,
|
||||||
|
struct state * sp));
|
||||||
|
static int tzload P((const char * name, struct state * sp));
|
||||||
|
static void tzsetgmt P((struct state * sp));
|
||||||
|
void tzsetwall P((void));
|
||||||
|
|
||||||
struct ttinfo { /* time type information */
|
struct ttinfo { /* time type information */
|
||||||
long tt_gmtoff; /* GMT offset in seconds */
|
long tt_gmtoff; /* GMT offset in seconds */
|
||||||
@ -100,7 +124,7 @@ char * tz_abbr; /* compatibility w/older versions */
|
|||||||
|
|
||||||
static long
|
static long
|
||||||
detzcode(codep)
|
detzcode(codep)
|
||||||
char * codep;
|
const char * codep;
|
||||||
{
|
{
|
||||||
register long result;
|
register long result;
|
||||||
register int i;
|
register int i;
|
||||||
@ -111,27 +135,9 @@ char * codep;
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __TURBOC__
|
static int
|
||||||
#include "fcntl.h"
|
|
||||||
#endif /* defined __TURBOC__ */
|
|
||||||
|
|
||||||
#ifdef unix
|
|
||||||
#include "fcntl.h"
|
|
||||||
#endif /* defined unix */
|
|
||||||
|
|
||||||
#ifdef O_BINARY
|
|
||||||
#ifdef O_RDONLY
|
|
||||||
#define MODE O_BINARY | O_RDONLY
|
|
||||||
#endif /* defined O_RDONLY */
|
|
||||||
#endif /* defined O_BINARY */
|
|
||||||
|
|
||||||
#ifndef MODE
|
|
||||||
#define MODE 0
|
|
||||||
#endif /* !defined MODE */
|
|
||||||
|
|
||||||
static
|
|
||||||
tzload(name, sp)
|
tzload(name, sp)
|
||||||
register char * name;
|
register const char * name;
|
||||||
register struct state * sp;
|
register struct state * sp;
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
@ -161,9 +167,9 @@ register struct state * sp;
|
|||||||
doaccess = TRUE;
|
doaccess = TRUE;
|
||||||
name = fullname;
|
name = fullname;
|
||||||
}
|
}
|
||||||
if (doaccess && access(name, 4) != 0)
|
if (doaccess && access(name, ACCESS_MODE) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
if ((fid = open(name, MODE)) == -1)
|
if ((fid = open(name, OPEN_MODE)) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -249,12 +255,12 @@ register struct state * sp;
|
|||||||
tzname[1] = &sp->chars[ttisp->tt_abbrind];
|
tzname[1] = &sp->chars[ttisp->tt_abbrind];
|
||||||
#ifdef USG_COMPAT
|
#ifdef USG_COMPAT
|
||||||
daylight = 1;
|
daylight = 1;
|
||||||
#endif /* defined USG_COMPAT */
|
#endif /* defined USG_COMPAT */
|
||||||
} else {
|
} else {
|
||||||
tzname[0] = &sp->chars[ttisp->tt_abbrind];
|
tzname[0] = &sp->chars[ttisp->tt_abbrind];
|
||||||
#ifdef USG_COMPAT
|
#ifdef USG_COMPAT
|
||||||
timezone = -ttisp->tt_gmtoff;
|
timezone = -ttisp->tt_gmtoff;
|
||||||
#endif /* defined USG_COMPAT */
|
#endif /* defined USG_COMPAT */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +372,7 @@ struct tm *
|
|||||||
static struct tm *
|
static struct tm *
|
||||||
#endif /* !defined STD_INSPIRED */
|
#endif /* !defined STD_INSPIRED */
|
||||||
offtime(clock, offset)
|
offtime(clock, offset)
|
||||||
time_t * clock;
|
const time_t * clock;
|
||||||
long offset;
|
long offset;
|
||||||
{
|
{
|
||||||
if (!gmt_is_set) {
|
if (!gmt_is_set) {
|
||||||
@ -388,7 +394,7 @@ static int year_lengths[2] = {
|
|||||||
|
|
||||||
static struct tm *
|
static struct tm *
|
||||||
timesub(clock, offset, sp)
|
timesub(clock, offset, sp)
|
||||||
time_t * clock;
|
const time_t * clock;
|
||||||
long offset;
|
long offset;
|
||||||
register struct state * sp;
|
register struct state * sp;
|
||||||
{
|
{
|
||||||
@ -486,6 +492,7 @@ time_t * timep;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined BSD_COMPAT */
|
#endif /* defined BSD_COMPAT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** UNIX is a registered trademark of AT&T.
|
** UNIX is a registered trademark of AT&T.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user