/* CYGNUS LOCAL */
#include "winsup.h"
+#include "cygerrno.h"
#include <windows.h>
#define lint
#include "sys/types.h" /* for time_t */
#include "stdio.h"
-#include "errno.h"
#include "limits.h" /* for CHAR_BIT */
#include "time.h"
#include "stdlib.h"
#endif /* !defined remove */
/*
-** Some ancient errno.h implementations don't declare errno.
-** But some newer errno.h implementations define it as a macro.
-** Fix the former without affecting the latter.
-*/
-#ifndef errno
-extern int errno;
-#endif /* !defined errno */
-
-/*
-** Private function declarations.
-*/
-char * icalloc P((int nelem, int elsize));
-char * icatalloc P((char * old, const char * new));
-char * icpyalloc P((const char * string));
-char * imalloc P((int n));
-void * irealloc P((void * pointer, int size));
-void icfree P((char * pointer));
-void ifree P((char * pointer));
-char * scheck P((const char *string, const char *format));
-
-
-/*
** Finally, some convenience items.
*/
#endif /* defined ALTZONE */
static long
-detzcode(codep)
-const char * const codep;
+detzcode(const char *codep)
{
register long result;
register int i;
#include "tz_posixrules.h"
static int
-tzload(name, sp)
-register const char * name;
-register struct state * const sp;
+tzload(const char *name, struct state *sp)
{
register const char * p;
register int i;
register int fid;
+ save_errno save;
if (name == NULL && (name = TZDEFAULT) == NULL)
return -1;
*/
static const char *
-getzname(strp)
-register const char * strp;
+getzname(const char *strp)
{
register char c;
*/
static const char *
-getnum(strp, nump, min, max)
-register const char * strp;
-int * const nump;
-const int min;
-const int max;
+getnum(const char *strp, int *nump, const int min, const int max)
{
register char c;
register int num;
*/
static const char *
-getsecs(strp, secsp)
-register const char * strp;
-long * const secsp;
+getsecs(const char *strp, long *secsp)
{
int num;
*/
static const char *
-getoffset(strp, offsetp)
-register const char * strp;
-long * const offsetp;
+getoffset(const char *strp, long *offsetp)
{
register int neg = 0;
*/
static const char *
-getrule(strp, rulep)
-const char * strp;
-register struct rule * const rulep;
+getrule(const char *strp, struct rule *rulep)
{
if (*strp == 'J') {
/*
*/
static time_t
-transtime(janfirst, year, rulep, offset)
-const time_t janfirst;
-const int year;
-register const struct rule * const rulep;
-const long offset;
+transtime(const time_t janfirst, const int year, const struct rule *rulep,
+ long offset)
{
register int leapyear;
register time_t value;
*/
static int
-tzparse(name, sp, lastditch)
-const char * name;
-register struct state * const sp;
-const int lastditch;
+tzparse(const char *name, struct state *sp, const int lastditch)
{
const char * stdname;
const char * dstname;
}
static void
-gmtload(sp)
-struct state * const sp;
+gmtload(struct state *sp)
{
if (tzload(gmt, sp) != 0)
(void) tzparse(gmt, sp, TRUE);
settzname();
}
-void
+extern "C" void
tzset P((void))
{
const char * name = getenv("TZ");
/*ARGSUSED*/
static void
localsub (const time_t * const timep,
- const long offset __attribute__ ((unused)),
+ const long offset,
struct tm * const tmp)
{
register struct state * sp;
#endif /* defined TM_ZONE */
}
-struct tm *
-localtime(timep)
-const time_t * const timep;
+extern "C" struct tm *
+localtime(const time_t *timep)
{
tzset();
localsub(timep, 0L, &tm);
/*
* Re-entrant version of localtime
*/
-struct tm *
-localtime_r(timep, tm)
-const time_t * const timep;
-struct tm * tm;
+extern "C" struct tm *
+localtime_r(const time_t *timep, struct tm *tm)
{
localsub(timep, 0L, tm);
return tm;
*/
static void
-gmtsub(timep, offset, tmp)
-const time_t * const timep;
-const long offset;
-struct tm * const tmp;
+gmtsub(const time_t *timep, const long offset, struct tm *tmp)
{
if (!gmt_is_set) {
gmt_is_set = TRUE;
#endif /* defined TM_ZONE */
}
-struct tm *
-gmtime(timep)
-const time_t * const timep;
+extern "C" struct tm *
+gmtime(const time_t *timep)
{
gmtsub(timep, 0L, &tm);
return &tm;
/*
* Re-entrant version of gmtime
*/
-struct tm *
-gmtime_r(timep, tm)
-const time_t * const timep;
-struct tm * tm;
+extern "C" struct tm *
+gmtime_r(const time_t *timep, struct tm *tm)
{
gmtsub(timep, 0L, tm);
return tm;
#ifdef STD_INSPIRED
-struct tm *
-offtime(timep, offset)
-const time_t * const timep;
-const long offset;
+extern "C" struct tm *
+offtime(const time_t *timep, const long offset)
{
gmtsub(timep, offset, &tm);
return &tm;
#endif /* defined STD_INSPIRED */
static void
-timesub(timep, offset, sp, tmp)
-const time_t * const timep;
-const long offset;
-register const struct state * const sp;
-register struct tm * const tmp;
+timesub(const time_t *timep, const long offset, const struct state *sp,
+ struct tm *tmp)
{
register const struct lsinfo * lp;
register long days;
#endif /* defined TM_GMTOFF */
}
-char *
-ctime(timep)
-const time_t * const timep;
+extern "C" char *
+ctime(const time_t *timep)
{
/*
** Section 4.12.3.2 of X3.159-1989 requires that
return asctime(localtime(timep));
}
-char *
-ctime_r(timep, buf)
-const time_t * const timep;
-char * buf;
+extern "C" char *
+ctime_r(const time_t *timep, char *buf)
{
struct tm tm;
*/
static int
-increment_overflow(number, delta)
-int * number;
-int delta;
+increment_overflow(int *number, int delta)
{
int number0;
}
static int
-normalize_overflow(tensptr, unitsptr, base)
-int * const tensptr;
-int * const unitsptr;
-const int base;
+normalize_overflow(int *tensptr, int *unitsptr, const int base)
{
register int tensdelta;
}
static int
-tmcomp(atmp, btmp)
-register const struct tm * const atmp;
-register const struct tm * const btmp;
+tmcomp(register const struct tm *atmp, register const struct tm *btmp)
{
register int result;
}
static time_t
-time2sub(tmp, funcp, offset, okayp, do_norm_secs)
-struct tm * const tmp;
-void (* const funcp) P((const time_t*, long, struct tm*));
-const long offset;
-int * const okayp;
-const int do_norm_secs;
+time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
+ const long offset, int *okayp, const int do_norm_secs)
{
register const struct state * sp;
register int dir;
}
static time_t
-time2(tmp, funcp, offset, okayp)
-struct tm * const tmp;
-void (* const funcp) P((const time_t*, long, struct tm*));
-const long offset;
-int * const okayp;
+time2(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
+ const long offset, int *okayp)
{
time_t t;
}
static time_t
-time1(tmp, funcp, offset)
-struct tm * const tmp;
-void (* const funcp) P((const time_t *, long, struct tm *));
-const long offset;
+time1(struct tm *tmp, void (*funcp) P((const time_t *, long, struct tm *)),
+ const long offset)
{
register time_t t;
register const struct state * sp;
return WRONG;
}
-time_t
-mktime(tmp)
-struct tm * const tmp;
+extern "C" time_t
+mktime(struct tm *tmp)
{
tzset();
return time1(tmp, localsub, 0L);
#ifdef STD_INSPIRED
-time_t
-timelocal(tmp)
-struct tm * const tmp;
+extern "C" time_t
+timelocal(struct tm *tmp)
{
tmp->tm_isdst = -1; /* in case it wasn't initialized */
return mktime(tmp);
}
-time_t
-timegm(tmp)
-struct tm * const tmp;
+extern "C" time_t
+timegm(struct tm *tmp)
{
tmp->tm_isdst = 0;
return time1(tmp, gmtsub, 0L);
}
-time_t
-timeoff(tmp, offset)
-struct tm * const tmp;
-const long offset;
+extern "C" time_t
+timeoff(struct tm *tmp, const long offset)
{
tmp->tm_isdst = 0;
return time1(tmp, gmtsub, offset);
** previous versions of the CMUCS runtime library.
*/
-long
-gtime(tmp)
-struct tm * const tmp;
+extern "C" long
+gtime(struct tm *tmp)
{
const time_t t = mktime(tmp);
*/
static long
-leapcorr(timep)
-time_t * timep;
+leapcorr(time_t *timep)
{
register struct state * sp;
register struct lsinfo * lp;
return 0;
}
-time_t
-time2posix(t)
-time_t t;
+extern "C" time_t
+time2posix(time_t t)
{
tzset();
return t - leapcorr(&t);
}
-time_t
-posix2time(t)
-time_t t;
+extern "C" time_t
+posix2time(time_t t)
{
time_t x;
time_t y;