Revision 1.04 changes
This commit is contained in:
parent
ce27e11c51
commit
c086e3bea2
|
@ -1,5 +1,5 @@
|
||||||
Makefile
|
Makefile
|
||||||
ntimed-client
|
ntimed*
|
||||||
.gdbinit
|
.gdbinit
|
||||||
.depend
|
.depend
|
||||||
*.o
|
*.o
|
||||||
|
|
26
COPYRIGHT
26
COPYRIGHT
|
@ -1,13 +1,13 @@
|
||||||
This software contains copyrighted material by:
|
This software contains copyrighted material by:
|
||||||
The NetBSD Foundation, Inc.
|
The NetBSD Foundation, Inc.
|
||||||
Poul-Henning Kamp
|
Poul-Henning Kamp
|
||||||
Motoyuki Kasahara
|
Motoyuki Kasahara
|
||||||
Diego Casorran
|
Carsten Larsen
|
||||||
Carsten Larsen
|
|
||||||
|
Portions of the code have been contributed by:
|
||||||
Portions of the code have been contributed by:
|
Charles M. Hannum
|
||||||
Charles M. Hannum
|
Poul-Henning Kamp
|
||||||
Poul-Henning Kamp
|
Motoyuki Kasahara
|
||||||
Motoyuki Kasahara
|
Carsten Larsen
|
||||||
Diego Casorran
|
|
||||||
Carsten Larsen
|
See license file for details.
|
||||||
|
|
5
HISTORY
5
HISTORY
|
@ -1,7 +1,8 @@
|
||||||
History
|
History
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
1.04 Bug-fixes in TCP/IP and debugging logic.
|
||||||
1.03 Rebuild for AROS. Removed broken Time Zone Database library.
|
1.03 Rebuild for AROS. Removed broken Time Zone Database library.
|
||||||
1.02 Restructured code. New fork of offical Ntimed with modifications.
|
1.02 Restructured code. New fork of official Ntimed with modifications.
|
||||||
1.01 Internal release. Testing and bugfixing. Never published
|
1.01 Internal release. Testing and bug fixing. Never published
|
||||||
1.00a Initial release. First public release
|
1.00a Initial release. First public release
|
||||||
|
|
7
LICENSE
7
LICENSE
|
@ -1,6 +1,3 @@
|
||||||
Copyright (c) 2015, Carsten Larsen
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
@ -21,7 +18,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
See individual files for license details.
|
|
||||||
|
|
57
compiler.h
57
compiler.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
//--------------------------------------------------------------------------//
|
||||||
* Copyright (c) 2015 Carsten Larsen
|
/* Copyright (c) 2015 Carsten Larsen
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -21,25 +21,21 @@
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifndef NTIMED_COMPILER_H
|
#ifndef NTIMED_COMPILER_H
|
||||||
#define NTIMED_COMPILER_H
|
#define NTIMED_COMPILER_H
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
/*
|
// More info at:
|
||||||
* See also:
|
// http://codewiz.org/projects/amiga/Headers/CompilerSpecific.h
|
||||||
* http://codewiz.org/projects/amiga/Headers/CompilerSpecific.h
|
//--------------------------------------------------------------------------//
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __VBCC__
|
#ifdef __VBCC__
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
|
@ -49,40 +45,31 @@
|
||||||
# define round(x) x > 0.0 ? floor(x + 0.5) : ceil(x - 0.5)
|
# define round(x) x > 0.0 ? floor(x + 0.5) : ceil(x - 0.5)
|
||||||
typedef uint32_t register_t;
|
typedef uint32_t register_t;
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# if (__GNUC__ == 2 && __GNUC_MINOR__ == 95)
|
# if (__GNUC__ == 2 && __GNUC_MINOR__ == 95)
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# define round(x) x > 0.0 ? floor(x + 0.5) : ceil(x - 0.5)
|
# define round(x) x > 0.0 ? floor(x + 0.5) : ceil(x - 0.5)
|
||||||
# define nan(p) 0./0.
|
# define nan(p) 0./0.
|
||||||
typedef u_int8_t uint8_t;
|
typedef u_int8_t uint8_t;
|
||||||
typedef u_int16_t uint16_t;
|
typedef u_int16_t uint16_t;
|
||||||
typedef u_int32_t uint32_t;
|
typedef u_int32_t uint32_t;
|
||||||
typedef u_int64_t uint64_t;
|
typedef u_int64_t uint64_t;
|
||||||
typedef uint32_t uintptr_t;
|
typedef uint32_t uintptr_t;
|
||||||
typedef unsigned int socklen_t;
|
typedef unsigned int socklen_t;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef AROS
|
# ifdef AROS
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
typedef uint32_t register_t;
|
typedef uint32_t register_t;
|
||||||
# endif
|
# endif
|
||||||
|
typedef uint16_t in_port_t;
|
||||||
|
typedef unsigned int sa_family_t;
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef __GNUC__
|
|
||||||
# define HAVE_ASCTIME
|
|
||||||
typedef uint16_t in_port_t;
|
|
||||||
typedef unsigned int sa_family_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// General socket address holding structure, big enough to hold either
|
|
||||||
// struct sockaddr_in or struct sockaddr_in6 data:
|
|
||||||
struct sockaddr_storage {
|
struct sockaddr_storage {
|
||||||
sa_family_t ss_family; // address family
|
sa_family_t ss_family;
|
||||||
|
char __ss_pad1[128 - sizeof(sa_family_t)];
|
||||||
// all this is padding, implementation specific, ignore it:
|
|
||||||
char __ss_pad1[128 - sizeof(sa_family_t)];
|
|
||||||
};
|
};
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -173,11 +173,11 @@ if $VALID ; then
|
||||||
echo ''
|
echo ''
|
||||||
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
|
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
|
||||||
echo 'CC = m68k-amigaos-gcc'
|
echo 'CC = m68k-amigaos-gcc'
|
||||||
echo "CFLAGS = -O2 -noixemul -DAOS3 -DWITHTEST -DHAVE_LIBTZ -I. -Ilib -Wall -Werror"
|
echo "CFLAGS = -O2 -noixemul -DAOS3 -DWITHTEST -I. -Iinclude -Wall -Werror"
|
||||||
echo "LDLIBS = -Llib/aos3 -ltz -lm"
|
echo "LDLIBS = -lm"
|
||||||
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
|
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
|
||||||
echo 'CC = gcc'
|
echo 'CC = gcc'
|
||||||
echo "CFLAGS = -O2 -DAROS -DWITHTEST -I. -Wall -Werror"
|
echo "CFLAGS = -O2 -DAROS -I. -Iinclude -Wall -Werror"
|
||||||
echo "LDLIBS = -lm"
|
echo "LDLIBS = -lm"
|
||||||
else
|
else
|
||||||
echo "CFLAGS = -O2 -Wall -DWITHTEST -Werror"
|
echo "CFLAGS = -O2 -Wall -DWITHTEST -Werror"
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define _SOCKET_AMITCP_H
|
#define _SOCKET_AMITCP_H
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#define AMITCP_BASE_NAME SocketBase
|
#define AMITCP_BASE_NAME SocketBase
|
||||||
#include "inline_amitcp.h"
|
#include "inline/amitcp.h"
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#define socket Socket
|
#define socket Socket
|
||||||
#define bind Bind
|
#define bind Bind
|
|
@ -0,0 +1,101 @@
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Carsten Larsen
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#ifndef _CLIB_TIMEZONE_H
|
||||||
|
#define _CLIB_TIMEZONE_H
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <devices/timer.h>
|
||||||
|
#include <libraries/locale.h>
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#define TZVARIABLE "timezone.prefs"
|
||||||
|
#define TZDIR "ZONEINFO:"
|
||||||
|
#define TZDEFAULT "localtime"
|
||||||
|
#define TZDEFRULES "posixrules"
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#ifndef HAVE_TIMEZONE_T
|
||||||
|
typedef struct timezone* timezone_t;
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#ifndef HAVE_LOCATE_T
|
||||||
|
typedef struct Locale* locale_t;
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#ifndef _TIME_H_
|
||||||
|
struct tm {
|
||||||
|
int tm_sec; /* seconds after the minute [0-61] */
|
||||||
|
int tm_min; /* minutes after the hour [0-59] */
|
||||||
|
int tm_hour; /* hours since midnight [0-23] */
|
||||||
|
int tm_mday; /* day of the month [1-31] */
|
||||||
|
int tm_mon; /* months since January [0-11] */
|
||||||
|
int tm_year; /* years since 1900 */
|
||||||
|
int tm_wday; /* days since Sunday [0-6] */
|
||||||
|
int tm_yday; /* days since January 1 [0-365] */
|
||||||
|
int tm_isdst; /* Daylight Savings Time flag */
|
||||||
|
long tm_gmtoff; /* offset from UTC in seconds */
|
||||||
|
char *tm_zone; /* timezone abbreviation */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
void tzset(void);
|
||||||
|
timezone_t tzalloc(char const *name);
|
||||||
|
void tzfree(timezone_t tz);
|
||||||
|
time_t time(time_t *p);
|
||||||
|
time_t mktime(struct tm *tmp);
|
||||||
|
time_t mktime_z(const timezone_t tz, struct tm *tmp);
|
||||||
|
struct tm* localtime(const time_t *const timep);
|
||||||
|
struct tm* localtime_r(const time_t *const timep, struct tm *tmp);
|
||||||
|
struct tm* localtime_rz(timezone_t tz, time_t const *timep, struct tm *tmp);
|
||||||
|
struct tm* gmtime(const time_t *timep);
|
||||||
|
struct tm* gmtime_r(const time_t *timep, struct tm *tmp);
|
||||||
|
char* ctime(const time_t *const timep);
|
||||||
|
char* ctime_r(const time_t *const timep, char *buf);
|
||||||
|
double difftime(const time_t time1, const time_t time0);
|
||||||
|
char* asctime(const struct tm *timeptr);
|
||||||
|
char* asctime_r(const struct tm *timeptr, char *buf);
|
||||||
|
size_t strftime(char * const s, const size_t maxsize,
|
||||||
|
const char *const format, const struct tm *const t);
|
||||||
|
size_t strftime_l(char * const s, size_t maxsize,
|
||||||
|
const char *const format, const struct tm *const t,
|
||||||
|
locale_t locale);
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
void getsystime(struct timeval *tv);
|
||||||
|
void setsystime(struct timeval *tv);
|
||||||
|
#ifndef AVOID_TIMEOFDAY
|
||||||
|
int gettimeofday(struct timeval *tv, const timezone_t tz);
|
||||||
|
int settimeofday(const struct timeval *tv, const timezone_t tz);
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
int gmtoffset(time_t tloc);
|
||||||
|
char* tzlocation(void);
|
||||||
|
void underscore_add(char *s);
|
||||||
|
void underscore_remove(char *s);
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
/* Automatically generated header! Do not edit! */
|
||||||
|
|
||||||
#ifndef _INLINE_AMITCP_H
|
#ifndef _INLINE_AMITCP_H
|
||||||
#define _INLINE_AMITCP_H
|
#define _INLINE_AMITCP_H
|
||||||
|
|
||||||
#ifndef __INLINE_MACROS_H
|
#ifndef __INLINE_MACROS_H
|
||||||
#include <inline/macros.h>
|
#include <inline/macros.h>
|
||||||
#endif
|
#endif /* !__INLINE_MACROS_H */
|
||||||
|
|
||||||
#ifndef AMITCP_BASE_NAME
|
#ifndef AMITCP_BASE_NAME
|
||||||
#define AMITCP_BASE_NAME lss->lx_BsdSocketBase
|
#define AMITCP_BASE_NAME lss->lx_BsdSocketBase
|
||||||
#endif
|
#endif /* !AMITCP_BASE_NAME */
|
||||||
|
|
||||||
#define TCP_Accept(s, addr, addrlen) \
|
#define TCP_Accept(s, addr, addrlen) \
|
||||||
LP3(0x30, LONG, TCP_Accept, LONG, s, d0, struct sockaddr *, addr, a0, int *, addrlen, a1, \
|
LP3(0x30, LONG, TCP_Accept, LONG, s, d0, struct sockaddr *, addr, a0, int *, addrlen, a1, \
|
||||||
|
@ -198,4 +200,4 @@
|
||||||
LP6(0x7e, LONG, TCP_WaitSelect, LONG, nfds, d0, fd_set *, readfds, a0, fd_set *, writefds, a1, fd_set *, execptfds, a2, struct timeval *, timeout, a3, ULONG *, maskp, d1, \
|
LP6(0x7e, LONG, TCP_WaitSelect, LONG, nfds, d0, fd_set *, readfds, a0, fd_set *, writefds, a1, fd_set *, execptfds, a2, struct timeval *, timeout, a3, ULONG *, maskp, d1, \
|
||||||
, AMITCP_BASE_NAME)
|
, AMITCP_BASE_NAME)
|
||||||
|
|
||||||
#endif
|
#endif /* !_INLINE_AMITCP_H */
|
|
@ -0,0 +1,122 @@
|
||||||
|
/* Automatically generated header! Do not edit! */
|
||||||
|
|
||||||
|
#ifndef _INLINE_TIMEZONE_H
|
||||||
|
#define _INLINE_TIMEZONE_H
|
||||||
|
|
||||||
|
#ifndef __INLINE_MACROS_H
|
||||||
|
#include <inline/macros.h>
|
||||||
|
#endif /* !__INLINE_MACROS_H */
|
||||||
|
|
||||||
|
#ifndef TIMEZONE_BASE_NAME
|
||||||
|
#define TIMEZONE_BASE_NAME TimezoneBase
|
||||||
|
#endif /* !TIMEZONE_BASE_NAME */
|
||||||
|
|
||||||
|
#define asctime(timeptr) \
|
||||||
|
LP1(0x72, char*, asctime, const struct tm *, timeptr, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define asctime_r(timeptr, buf) \
|
||||||
|
LP2(0x78, char*, asctime_r, const struct tm *, timeptr, a0, char *, buf, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define ctime(timep) \
|
||||||
|
LP1(0x60, char*, ctime, const time_t *const, timep, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define ctime_r(timep, buf) \
|
||||||
|
LP2(0x66, char*, ctime_r, const time_t *const, timep, a0, char *, buf, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define difftime(time1, time0) \
|
||||||
|
LP2(0x6c, double, difftime, const time_t, time1, d1, const time_t, time0, d0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define getsystime(tv) \
|
||||||
|
LP1NR(0x8a, getsystime, struct timeval *, tv, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#ifndef AVOID_TIMEOFDAY
|
||||||
|
#define gettimeofday(tv, tz) \
|
||||||
|
LP2(0x96, int, gettimeofday, struct timeval *, tv, a0, const timezone_t, tz, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define gmtime(timep) \
|
||||||
|
LP1(0x54, struct tm*, gmtime, const time_t *, timep, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define gmtime_r(timep, tm0) \
|
||||||
|
LP2(0x5a, struct tm*, gmtime_r, const time_t *, timep, a0, struct tm *, tm0, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define gmtoffset(tloc) \
|
||||||
|
LP1(0xa2, int, gmtoffset, time_t, tloc, d0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define localtime(timep) \
|
||||||
|
LP1(0x42, struct tm*, localtime, const time_t *const, timep, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define localtime_r(timep, tmp) \
|
||||||
|
LP2(0x48, struct tm*, localtime_r, const time_t *const, timep, a0, struct tm *, tmp, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define localtime_rz(tz, timep, tmp) \
|
||||||
|
LP3(0x4e, struct tm*, localtime_rz, timezone_t, tz, a2, time_t const *, timep, a0, struct tm *, tmp, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define mktime(tmp) \
|
||||||
|
LP1(0x36, time_t, mktime, struct tm *, tmp, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define mktime_z(tz, tmp) \
|
||||||
|
LP2(0x3c, time_t, mktime_z, const timezone_t, tz, a1, struct tm *, tmp, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define setsystime(tv) \
|
||||||
|
LP1NR(0x90, setsystime, struct timeval *, tv, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#ifndef AVOID_TIMEOFDAY
|
||||||
|
#define settimeofday(tv, tz) \
|
||||||
|
LP2(0x9c, int, settimeofday, const struct timeval *, tv, a0, const timezone_t, tz, a1, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define strftime(s, maxsize, format, t) \
|
||||||
|
LP4(0x7e, size_t, strftime, char * const, s, a0, size_t, maxsize, d0, const char *const, format, a1, const struct tm *const, t, a2, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define strftime_l(s, maxsize, format, t, locale) \
|
||||||
|
LP5(0x84, size_t, strftime_l, char * const, s, a0, size_t, maxsize, d0, const char *const, format, a1, const struct tm *const, t, a2, locale_t, locale, a3, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define time(p) \
|
||||||
|
LP1(0x30, time_t, time, time_t *, p, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define tzalloc(name) \
|
||||||
|
LP1(0x24, timezone_t, tzalloc, char const *, name, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define tzfree(tz) \
|
||||||
|
LP1NR(0x2a, tzfree, timezone_t, tz, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define tzlocation() \
|
||||||
|
LP0(0xa8, char*, tzlocation, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define tzset() \
|
||||||
|
LP0NR(0x1e, tzset, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define underscore_add(s) \
|
||||||
|
LP1NR(0xae, underscore_add, char *, s, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#define underscore_remove(s) \
|
||||||
|
LP1NR(0xb4, underscore_remove, char *, s, a0, \
|
||||||
|
, TIMEZONE_BASE_NAME)
|
||||||
|
|
||||||
|
#endif /* !_INLINE_TIMEZONE_H */
|
BIN
lib/aos3/libtz.a
BIN
lib/aos3/libtz.a
Binary file not shown.
Binary file not shown.
96
lib/tz.h
96
lib/tz.h
|
@ -1,96 +0,0 @@
|
||||||
/* $NetBSD: time.h,v 1.40 2010/12/16 18:36:47 christos Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
* (c) UNIX System Laboratories, Inc.
|
|
||||||
* All or some portions of this file are derived from material licensed
|
|
||||||
* to the University of California by American Telephone and Telegraph
|
|
||||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
|
||||||
* the permission of UNIX System Laboratories, Inc.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)time.h 8.3 (Berkeley) 1/21/94
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file tz.h
|
|
||||||
* @brief
|
|
||||||
* Parts of this file was retrieved from:
|
|
||||||
* ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/include/time.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TZ_HEADER
|
|
||||||
#define _TZ_HEADER
|
|
||||||
|
|
||||||
extern char *tzname[2];
|
|
||||||
|
|
||||||
#define TZVARIABLE "timezone.prefs"
|
|
||||||
#define TZDIR "LOCALE:Zoneinfo"
|
|
||||||
#define TZDEFAULT "localtime"
|
|
||||||
|
|
||||||
struct tm {
|
|
||||||
int tm_sec; /* seconds after the minute [0-61] */
|
|
||||||
int tm_min; /* minutes after the hour [0-59] */
|
|
||||||
int tm_hour; /* hours since midnight [0-23] */
|
|
||||||
int tm_mday; /* day of the month [1-31] */
|
|
||||||
int tm_mon; /* months since January [0-11] */
|
|
||||||
int tm_year; /* years since 1900 */
|
|
||||||
int tm_wday; /* days since Sunday [0-6] */
|
|
||||||
int tm_yday; /* days since January 1 [0-365] */
|
|
||||||
int tm_isdst; /* Daylight Savings Time flag */
|
|
||||||
long tm_gmtoff; /* offset from UTC in seconds */
|
|
||||||
char *tm_zone; /* timezone abbreviation */
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef HAVE_TIME_T
|
|
||||||
typedef long time_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct state *timezone_t;
|
|
||||||
|
|
||||||
void tzset(void);
|
|
||||||
void tzfree(const timezone_t);
|
|
||||||
timezone_t tzalloc(const char *);
|
|
||||||
time_t time(time_t *);
|
|
||||||
time_t mktime_z(const timezone_t, struct tm *);
|
|
||||||
time_t mktime(struct tm *);
|
|
||||||
struct tm *localtime_rz(const timezone_t, const time_t *, struct tm *);
|
|
||||||
struct tm *localtime_r(const time_t *, struct tm *);
|
|
||||||
struct tm *localtime(const time_t *);
|
|
||||||
struct tm *gmtime_r(const time_t *, struct tm *);
|
|
||||||
struct tm *gmtime(const time_t *);
|
|
||||||
char *ctime_r(const time_t *, char *);
|
|
||||||
char *ctime(const time_t *);
|
|
||||||
double difftime(time_t, time_t);
|
|
||||||
time_t time(time_t *x);
|
|
||||||
|
|
||||||
#ifndef HAVE_ASCTIME
|
|
||||||
char *asctime_r(const struct tm *, char *);
|
|
||||||
char *asctime(const struct tm *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -39,11 +39,13 @@ const char *vers = "\0$VER: ntimed-client" AMIGA_VERSION;
|
||||||
#undef PARAM_TABLE_NAME
|
#undef PARAM_TABLE_NAME
|
||||||
#undef PARAM_CLIENT
|
#undef PARAM_CLIENT
|
||||||
|
|
||||||
extern int validtime;
|
|
||||||
struct RDArgs *rdargs = NULL;
|
struct RDArgs *rdargs = NULL;
|
||||||
struct ntp_peerset *nps = NULL;
|
struct ntp_peerset *nps = NULL;
|
||||||
struct todolist *tdl = NULL;
|
struct todolist *tdl = NULL;
|
||||||
struct udp_socket *usc = NULL;
|
struct udp_socket *usc = NULL;
|
||||||
|
|
||||||
|
extern char *zone_message;
|
||||||
|
extern int validtime;
|
||||||
int savetime;
|
int savetime;
|
||||||
|
|
||||||
struct ntimedargs {
|
struct ntimedargs {
|
||||||
|
@ -63,8 +65,8 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
struct ntimedargs args = { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE };
|
struct ntimedargs args = { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE };
|
||||||
|
|
||||||
atexit(clean_exit);
|
atexit(clean_exit);
|
||||||
if((result = amiga_open_libs()) != 0) {
|
if((result = amiga_open_libs()) != 0) {
|
||||||
exit(result);
|
exit(result);
|
||||||
}
|
}
|
||||||
|
@ -172,13 +174,17 @@ static void init_logic(struct ntimedargs *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
amiga_init_offset();
|
amiga_init_offset();
|
||||||
|
|
||||||
|
if (zone_message) {
|
||||||
|
Put(NULL, OCX_DEBUG, "%s\n", zone_message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clean_exit()
|
static void clean_exit()
|
||||||
{
|
{
|
||||||
if (savetime && validtime) {
|
if (savetime && validtime) {
|
||||||
Time_Amiga_Save();
|
Time_Amiga_Save();
|
||||||
Put(NULL, OCX_DEBUG, "Saved to real-time clock\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArgTracefile(NULL);
|
ArgTracefile(NULL);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*-
|
/*-
|
||||||
|
* Copyright (c) 2015 Carsten Larsen
|
||||||
* Copyright (c) 2014 Poul-Henning Kamp
|
* Copyright (c) 2014 Poul-Henning Kamp
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -40,13 +41,13 @@ static void clean_exit()
|
||||||
int main(int argc, char * const *argv)
|
int main(int argc, char * const *argv)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
EnableDebug();
|
||||||
|
|
||||||
atexit(clean_exit);
|
atexit(clean_exit);
|
||||||
if((result = amiga_open_libs()) != 0) {
|
if((result = amiga_open_libs()) != 0) {
|
||||||
exit(result);
|
exit(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnableDebug();
|
|
||||||
amiga_init_offset();
|
amiga_init_offset();
|
||||||
Time_Amiga_Passive();
|
Time_Amiga_Passive();
|
||||||
TS_RunTest(NULL);
|
TS_RunTest(NULL);
|
||||||
|
|
91
mem.c
91
mem.c
|
@ -1,66 +1,47 @@
|
||||||
/*
|
//--------------------------------------------------------------------------//
|
||||||
* Copyright (c) 2015 Carsten Larsen
|
// This file is in the public domain. //
|
||||||
* All rights reserved.
|
//--------------------------------------------------------------------------//
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <exec/io.h>
|
#include <exec/io.h>
|
||||||
#include <exec/types.h>
|
#include <exec/types.h>
|
||||||
#include <exec/memory.h>
|
#include <exec/memory.h>
|
||||||
#include <exec/semaphores.h>
|
#include <exec/semaphores.h>
|
||||||
#include <clib/exec_protos.h>
|
#include <clib/exec_protos.h>
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#include "ntimed.h"
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
|
#include "ntimed.h"
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
struct MemoryBlock
|
struct MemoryBlock
|
||||||
{
|
{
|
||||||
struct MemoryBlock *next;
|
struct MemoryBlock *next;
|
||||||
size_t size;
|
size_t size;
|
||||||
void *address;
|
void *address;
|
||||||
};
|
};
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
struct MemoryList
|
struct MemoryList
|
||||||
{
|
{
|
||||||
struct MemoryBlock *first;
|
struct MemoryBlock *first;
|
||||||
struct MemoryBlock *last;
|
struct MemoryBlock *last;
|
||||||
long size;
|
long size;
|
||||||
long count;
|
long count;
|
||||||
|
long opcount;
|
||||||
};
|
};
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
struct MemoryList *list = NULL;
|
static struct MemoryList *list = NULL;
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
void allocerror(char*, size_t);
|
void allocerror(char*, size_t);
|
||||||
void deallocerror(char*, void*);
|
void deallocerror(char*, void*);
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
void* allocmem(size_t size)
|
void* allocmem(size_t size)
|
||||||
{
|
{
|
||||||
struct MemoryBlock *newblock;
|
struct MemoryBlock *newblock;
|
||||||
size_t allocsize;
|
size_t allocsize;
|
||||||
|
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
list = (struct MemoryList*)AllocVec(sizeof(struct MemoryList), MEMF_ANY | MEMF_CLEAR);
|
list =
|
||||||
|
(struct MemoryList*)
|
||||||
|
AllocVec(sizeof(struct MemoryList), MEMF_ANY | MEMF_CLEAR);
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
allocerror("list", sizeof(struct MemoryList));
|
allocerror("list", sizeof(struct MemoryList));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -75,13 +56,19 @@ void* allocmem(size_t size)
|
||||||
// Align to bytes of 4
|
// Align to bytes of 4
|
||||||
allocsize = (size + 3) & ~0x03;
|
allocsize = (size + 3) & ~0x03;
|
||||||
|
|
||||||
newblock = (struct MemoryBlock*)AllocVec(sizeof(struct MemoryBlock), MEMF_ANY | MEMF_CLEAR);
|
newblock =
|
||||||
|
(struct MemoryBlock*)
|
||||||
|
AllocVec(sizeof(struct MemoryBlock), MEMF_ANY | MEMF_CLEAR);
|
||||||
|
|
||||||
if (!newblock) {
|
if (!newblock) {
|
||||||
allocerror("block", sizeof(struct MemoryBlock));
|
allocerror("block", sizeof(struct MemoryBlock));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
newblock->address = (struct MemoryBlock*)AllocVec(allocsize, MEMF_ANY | MEMF_CLEAR);
|
newblock->address =
|
||||||
|
(struct MemoryBlock*)
|
||||||
|
AllocVec(allocsize, MEMF_ANY | MEMF_CLEAR);
|
||||||
|
|
||||||
if (!newblock->address) {
|
if (!newblock->address) {
|
||||||
FreeVec(newblock);
|
FreeVec(newblock);
|
||||||
allocerror("memory", allocsize);
|
allocerror("memory", allocsize);
|
||||||
|
@ -102,12 +89,23 @@ void* allocmem(size_t size)
|
||||||
list->size += allocsize;
|
list->size += allocsize;
|
||||||
list->count++;
|
list->count++;
|
||||||
|
|
||||||
// DEBUG code
|
list->opcount++;
|
||||||
// Debug(NULL, "Mememory allocated at address (%x)\n", newblock->address);
|
if (list->opcount % 25 == 0) {
|
||||||
|
Debug(
|
||||||
|
NULL,
|
||||||
|
"Memory usage: %d bytes allocated in %d blocks.\n",
|
||||||
|
list->size,
|
||||||
|
list->count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Debug(NULL, "Memory allocated at address (%x)\n", newblock->address);
|
||||||
|
|
||||||
return newblock->address;
|
return newblock->address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
|
||||||
void freemem(void* block)
|
void freemem(void* block)
|
||||||
{
|
{
|
||||||
struct MemoryBlock *current, *last;
|
struct MemoryBlock *current, *last;
|
||||||
|
@ -150,8 +148,9 @@ void freemem(void* block)
|
||||||
FreeVec(current->address);
|
FreeVec(current->address);
|
||||||
FreeVec(current);
|
FreeVec(current);
|
||||||
|
|
||||||
// DEBUG code
|
list->opcount++;
|
||||||
// Debug(NULL, "Mememory deallocated at address (%x)\n", block);
|
|
||||||
|
//Debug(NULL, "Memory deallocated at address (%x)\n", block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeall()
|
void freeall()
|
||||||
|
@ -174,16 +173,20 @@ void freeall()
|
||||||
list = NULL;
|
list = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
|
||||||
void allocerror(char *descr, size_t size)
|
void allocerror(char *descr, size_t size)
|
||||||
{
|
{
|
||||||
Debug(NULL, "Mememory allocation error (%s) with size (%d)\n", descr, size);
|
Debug(NULL, "Memory allocation error (%s) with size (%d)\n", descr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocerror(char *descr, void *p)
|
void deallocerror(char *descr, void *p)
|
||||||
{
|
{
|
||||||
Debug(NULL, "Mememory deallocation error (%s) address (%x)\n", descr, p);
|
Debug(NULL, "Memory deallocation error (%s) address (%x)\n", descr, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
|
||||||
char *strdup(const char *s1)
|
char *strdup(const char *s1)
|
||||||
{
|
{
|
||||||
char *s2;
|
char *s2;
|
||||||
|
@ -198,3 +201,5 @@ char *strdup(const char *s1)
|
||||||
memcpy(s2, s1, --len);
|
memcpy(s2, s1, --len);
|
||||||
return s2;
|
return s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
|
|
37
mem.h
37
mem.h
|
@ -1,39 +1,16 @@
|
||||||
/*
|
//--------------------------------------------------------------------------//
|
||||||
* Copyright (c) 2015 Carsten Larsen
|
// This file is in the public domain. //
|
||||||
* All rights reserved.
|
//--------------------------------------------------------------------------//
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AMIGA_MEM_H
|
#ifndef AMIGA_MEM_H
|
||||||
#define AMIGA_MEM_H
|
#define AMIGA_MEM_H
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
void* allocmem(size_t);
|
void* allocmem(size_t);
|
||||||
void freemem(void*);
|
void freemem(void*);
|
||||||
void freeall();
|
void freeall();
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#define strdup(s) managed_strdup(s)
|
#define strdup(s) managed_strdup(s)
|
||||||
char *strdup(const char *s1);
|
char *strdup(const char *s1);
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -508,7 +508,7 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_
|
||||||
#ifndef AOS3
|
#ifndef AOS3
|
||||||
ntoa_address = inet_ntoa(sa_in->sin_addr);
|
ntoa_address = inet_ntoa(sa_in->sin_addr);
|
||||||
#else
|
#else
|
||||||
ntoa_address = inet_ntoa((ULONG)&sa_in->sin_addr);
|
ntoa_address = inet_ntoa((LONG)sa_in->sin_addr.s_addr);
|
||||||
#endif
|
#endif
|
||||||
if (nodelen <= strlen(ntoa_address)) {
|
if (nodelen <= strlen(ntoa_address)) {
|
||||||
result = EAI_OVERFLOW;
|
result = EAI_OVERFLOW;
|
||||||
|
|
16
ntimed.guide
16
ntimed.guide
|
@ -1,16 +1,16 @@
|
||||||
@database ntimed.guide
|
@database ntimed.guide
|
||||||
@author Carsten Larsen
|
@author Carsten Larsen
|
||||||
@(c) Carsten Larsen
|
@(c) Carsten Larsen
|
||||||
@$VER: ntimed.guide 1.02 (10.07.2015)
|
@$VER: ntimed.guide 1.04 (25.07.2015)
|
||||||
@node Main "User manual"
|
@node Main "User manual"
|
||||||
@title "Ntimed user manual"
|
@title "Ntimed user manual"
|
||||||
|
|
||||||
Ntimed is a network time synchronization client for the Amiga. It is based on
|
Ntimed is a network time synchronization client for the Amiga. It is based on
|
||||||
the Ntimed free and open-source software by Poul-Henning Kamp, and sponsored
|
the Ntimed free and open-source software by Poul-Henning Kamp, sponsored by the
|
||||||
by the Linux Foundation.
|
Linux Foundation.
|
||||||
|
|
||||||
It uses the NTP protocol to synchronize the local Amiga clock to a set of
|
It uses the NTP protocol to synchronize the local Amiga clock to a set of
|
||||||
network server. Public available NTP servers are reachable through the
|
network servers. Public available NTP servers are reachable through the
|
||||||
Internet.
|
Internet.
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ Local GMT offset will be used if no time zone is selected.
|
||||||
@{b}Template@{ub}
|
@{b}Template@{ub}
|
||||||
P=PARAM/K, T=TRACEFILE/K, SERVERS/M/A, SYNC/S, SAVE/S, SHOW/S, QUIET/S
|
P=PARAM/K, T=TRACEFILE/K, SERVERS/M/A, SYNC/S, SAVE/S, SHOW/S, QUIET/S
|
||||||
|
|
||||||
PARAM are used to show and set internal Ntimed parameters. A list of parameters
|
PARAM is used to show and set internal Ntimed parameters. A list of parameters
|
||||||
will be shown when using question mark. TRACEFILE can be specified to write a
|
will be shown when using question mark. TRACEFILE can be specified to write a
|
||||||
full blow-by-blow trace file for analysis and debugging. {servers} is a list of
|
full blow-by-blow trace file for analysis and debugging. {servers} is a list of
|
||||||
NTP time servers.
|
NTP time servers.
|
||||||
|
|
||||||
SYNC will tell Ntimed to spent 5-10 seconds synchronizing and then exit. If
|
SYNC will tell Ntimed to spent 5-10 seconds synchronizing and then exit. If
|
||||||
SAVE is specified, time will be save to the real-time clock (RTC) upon exit.
|
SAVE is specified time will be save to the real-time clock (RTC) upon exit.
|
||||||
SHOW will display extended debugging information in the shell.
|
SHOW will display extended debugging information in the shell.
|
||||||
|
|
||||||
NTIMED can be stopped with CTRL C.
|
NTIMED can be stopped with CTRL C.
|
||||||
|
|
3
ntimed.h
3
ntimed.h
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
struct todolist;
|
struct todolist;
|
||||||
struct udp_socket;
|
struct udp_socket;
|
||||||
|
struct timestamp;
|
||||||
|
|
||||||
/* ocx_*.c -- Operational Context *************************************/
|
/* ocx_*.c -- Operational Context *************************************/
|
||||||
|
|
||||||
|
@ -54,6 +55,8 @@ enum ocx_chan {
|
||||||
void Put(struct ocx *, enum ocx_chan, const char *, ...)
|
void Put(struct ocx *, enum ocx_chan, const char *, ...)
|
||||||
__printflike(3, 4);
|
__printflike(3, 4);
|
||||||
void PutHex(struct ocx *, enum ocx_chan, const void *, ssize_t len);
|
void PutHex(struct ocx *, enum ocx_chan, const void *, ssize_t len);
|
||||||
|
void PutTime(struct ocx *, enum ocx_chan , const char *,
|
||||||
|
const struct timestamp *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report "Failure: " + args + "\n" [+ errno-line] + "\n". exit(1);
|
* Report "Failure: " + args + "\n" [+ errno-line] + "\n". exit(1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
//--------------------------------------------------------------------------//
|
||||||
* Copyright (c) 2015 Carsten Larsen
|
/* Copyright (c) 2015 Carsten Larsen
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -21,27 +21,18 @@
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifndef NTIMED_PLATFORM_H
|
#ifndef NTIMED_PLATFORM_H
|
||||||
#define NTIMED_PLATFORM_H
|
#define NTIMED_PLATFORM_H
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#if defined(AROS) || defined(AOS3)
|
#if defined(AROS) || defined(AOS3)
|
||||||
# define AMIGA_VERSION " 1.03 (13.07.2015)"
|
# define AMIGA_VERSION " 1.04 (25.07.2015)"
|
||||||
# ifndef AMIGA
|
# ifndef AMIGA
|
||||||
# define AMIGA
|
# define AMIGA
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef HAVE_LIBTZ
|
|
||||||
# define _TIME_H_
|
|
||||||
# define HAVE_TIME_T
|
|
||||||
# include <sys/time.h>
|
|
||||||
# include "tz.h"
|
|
||||||
#endif
|
|
||||||
#define HAVE_WAITSELECT
|
|
||||||
//--------------------------------------------------------------------------//
|
|
||||||
#ifdef AMIGA
|
#ifdef AMIGA
|
||||||
# include <exec/io.h>
|
# include <exec/io.h>
|
||||||
# include <exec/types.h>
|
# include <exec/types.h>
|
||||||
|
@ -77,19 +68,18 @@
|
||||||
#define LOCALELIB_REV 37L
|
#define LOCALELIB_REV 37L
|
||||||
#define BSDLIB_NAME "bsdsocket.library"
|
#define BSDLIB_NAME "bsdsocket.library"
|
||||||
#define BSDLIB_REV 03L
|
#define BSDLIB_REV 03L
|
||||||
|
#define TIMEZONELIB_NAME "timezone.library"
|
||||||
|
#define TIMEZONELIB_REV 0L
|
||||||
#define TIMER_NAME TIMERNAME
|
#define TIMER_NAME TIMERNAME
|
||||||
#define BATTCLOCK_NAME BATTCLOCKNAME
|
#define BATTCLOCK_NAME BATTCLOCKNAME
|
||||||
#ifdef TZVARIABLE
|
#define HAVE_WAITSELECT 1
|
||||||
# define TZVARIABLE_NAME TZVARIABLE
|
#define AVOID_TIMEOFDAY 1
|
||||||
#endif
|
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AOS3
|
#ifdef AOS3
|
||||||
# define REQ_ERROR "Requires Kickstart 2.04 (37.175) or later.\n"
|
|
||||||
# include "socket_amitcp.h"
|
|
||||||
# include <amitcp/socketbasetags.h>
|
# include <amitcp/socketbasetags.h>
|
||||||
|
# include "clib/amitcp_protos.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef AROS
|
#ifdef AROS
|
||||||
# define REQ_ERROR "Requires a newer version of AROS.\n"
|
|
||||||
# include <proto/socket.h>
|
# include <proto/socket.h>
|
||||||
# include <bsdsocket/socketbasetags.h>
|
# include <bsdsocket/socketbasetags.h>
|
||||||
# define APRT IPRT
|
# define APRT IPRT
|
||||||
|
@ -128,16 +118,16 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz);
|
||||||
#endif
|
#endif
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#ifndef _ALIGNBYTES
|
#ifndef _ALIGNBYTES
|
||||||
# define _ALIGNBYTES (sizeof(register_t) - 1)
|
# define _ALIGNBYTES (sizeof(register_t) - 1)
|
||||||
#endif
|
#endif
|
||||||
#ifndef ALIGN
|
#ifndef ALIGN
|
||||||
# define ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
|
# define ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
|
||||||
#endif
|
#endif
|
||||||
#ifndef SO_TIMESTAMPING
|
#ifndef SO_TIMESTAMPING
|
||||||
# define SO_TIMESTAMPING 37
|
# define SO_TIMESTAMPING 37
|
||||||
#endif
|
#endif
|
||||||
#ifndef SO_TIMESTAMPNS
|
#ifndef SO_TIMESTAMPNS
|
||||||
# define SO_TIMESTAMPNS 35
|
# define SO_TIMESTAMPNS 35
|
||||||
#endif
|
#endif
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
int amiga_open_libs();
|
int amiga_open_libs();
|
||||||
|
@ -153,5 +143,6 @@ extern struct Library *DOSBase;
|
||||||
extern struct Library *UtilityBase;
|
extern struct Library *UtilityBase;
|
||||||
extern struct Library *LocaleBase;
|
extern struct Library *LocaleBase;
|
||||||
extern struct Library *SocketBase;
|
extern struct Library *SocketBase;
|
||||||
|
extern struct Library *TimezoneBase;
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
#endif
|
#endif
|
||||||
|
|
41
ocx_stdio.c
41
ocx_stdio.c
|
@ -68,6 +68,11 @@
|
||||||
#include "ntimed_platform.h"
|
#include "ntimed_platform.h"
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
|
|
||||||
|
#ifdef AOS3
|
||||||
|
# include "clib/timezone_protos.h"
|
||||||
|
# include "inline/timezone.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int repeat_trace = 0;
|
int repeat_trace = 0;
|
||||||
|
|
||||||
static FILE *debugfile = NULL;
|
static FILE *debugfile = NULL;
|
||||||
|
@ -133,17 +138,18 @@ Put(struct ocx *ocx, enum ocx_chan chan, const char *fmt, ...)
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
dst = getdst(chan);
|
dst = getdst(chan);
|
||||||
if (dst != NULL && dst == stdout) {
|
if (dst != NULL) {
|
||||||
(void)vfprintf(dst, fmt, ap);
|
(void)vfprintf(dst, fmt, ap);
|
||||||
fflush(dst);
|
fflush(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = getdst(OCX_DEBUG);
|
// Repeat trace in debug channel
|
||||||
if (
|
if (chan == OCX_TRACE && repeat_trace) {
|
||||||
dst != NULL && dst == stdout &&
|
dst = getdst(OCX_DEBUG);
|
||||||
repeat_trace && chan == OCX_TRACE) {
|
if (dst != NULL) {
|
||||||
(void)vfprintf(dst, fmt, ap);
|
(void)vfprintf(dst, fmt, ap);
|
||||||
fflush(dst);
|
fflush(dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -164,6 +170,26 @@ PutHex(struct ocx *ocx, enum ocx_chan chan, const void *ptr, ssize_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PutTime(struct ocx *ocx, enum ocx_chan chan, const char *fmt, const struct timestamp *ts)
|
||||||
|
{
|
||||||
|
FILE *dst;
|
||||||
|
struct tm tm;
|
||||||
|
static char buf[80];
|
||||||
|
|
||||||
|
if (TimezoneBase) {
|
||||||
|
const time_t t = (uint32_t)ts->sec;
|
||||||
|
localtime_r((const time_t*)&t, &tm);
|
||||||
|
strftime(buf, 80, "%+", &tm);
|
||||||
|
|
||||||
|
dst = getdst(chan);
|
||||||
|
if (dst != NULL && dst == stdout) {
|
||||||
|
(void)fprintf(dst, fmt, buf);
|
||||||
|
fflush(dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Fail(struct ocx *ocx, int err, const char *fmt, ...)
|
Fail(struct ocx *ocx, int err, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -188,3 +214,4 @@ Fail(struct ocx *ocx, int err, const char *fmt, ...)
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
191
time_amiga.c
191
time_amiga.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
//--------------------------------------------------------------------------//
|
||||||
* Copyright (c) 2015 Carsten Larsen
|
/* Copyright (c) 2015 Carsten Larsen
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -21,16 +21,15 @@
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#include "ntimed_platform.h"
|
#include "ntimed_platform.h"
|
||||||
#include "ntimed.h"
|
#include "ntimed.h"
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef Debug
|
#ifdef Debug
|
||||||
#undef Debug
|
#undef Debug
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#include <exec/io.h>
|
#include <exec/io.h>
|
||||||
#include <exec/types.h>
|
#include <exec/types.h>
|
||||||
#include <exec/memory.h>
|
#include <exec/memory.h>
|
||||||
|
@ -44,49 +43,52 @@
|
||||||
#include <clib/locale_protos.h>
|
#include <clib/locale_protos.h>
|
||||||
#include <clib/utility_protos.h>
|
#include <clib/utility_protos.h>
|
||||||
#include <clib/battclock_protos.h>
|
#include <clib/battclock_protos.h>
|
||||||
|
// -------------------------------------------------------------------------- //
|
||||||
// 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6 normal)
|
#ifdef AOS3
|
||||||
#define AMIGAOFFSET 2922 * 24 * 60 * 60
|
# include "clib/timezone_protos.h"
|
||||||
|
# include "inline/timezone.h"
|
||||||
#define ENVSIZE 256
|
#endif
|
||||||
|
// -------------------------------------------------------------------------- //
|
||||||
|
// 2922 is the number of days between 1.1.1970 and 1.1.1978
|
||||||
|
// (2 leap years and 6 normal)
|
||||||
|
// 2922 * 24 * 60 * 60 = 252460800
|
||||||
|
// -------------------------------------------------------------------------- //
|
||||||
|
#define AMIGAOFFSET 252460800
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
int create_timer();
|
int create_timer();
|
||||||
int delete_timer();
|
int delete_timer();
|
||||||
void adjust_timeval(struct timeval *tv, double offset);
|
void adjust_timeval(struct timeval *tv, double offset);
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
struct Library *BattClockBase;
|
struct Library *BattClockBase;
|
||||||
struct Library *DOSBase = NULL;
|
struct Library *DOSBase = NULL;
|
||||||
struct Library *UtilityBase = NULL;
|
struct Library *UtilityBase = NULL;
|
||||||
struct Library *LocaleBase = NULL;
|
struct Library *LocaleBase = NULL;
|
||||||
struct Library *SocketBase = NULL;
|
struct Library *SocketBase = NULL;
|
||||||
struct Locale *locale = NULL;
|
struct Library *TimezoneBase = NULL;
|
||||||
struct Device *TimerBase = NULL;
|
struct Locale *locale = NULL;
|
||||||
struct timerequest *request = NULL;
|
struct Device *TimerBase = NULL;
|
||||||
|
struct timerequest *request = NULL;
|
||||||
struct timeval sync_time;
|
struct timeval sync_time;
|
||||||
|
char *zone_message = NULL;
|
||||||
int validtime = 0;
|
int validtime = 0;
|
||||||
int limited_sync = 0;
|
int limited_sync = 0;
|
||||||
long offset = 0;
|
long offset = 0;
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
#ifdef AOS3
|
#ifdef AOS3
|
||||||
int errno;
|
int errno;
|
||||||
int h_errno;
|
int h_errno;
|
||||||
#endif
|
#endif
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
void amiga_open_error(char *name)
|
void amiga_open_error(char *name)
|
||||||
{
|
{
|
||||||
Put(NULL, OCX_DIAG, OPEN_ERROR, "Locale");
|
Put(NULL, OCX_DIAG, OPEN_ERROR, name);
|
||||||
FPrintf(Output(), (STRPTR)OPEN_ERROR, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void amiga_open_lib_error(char *name, int version)
|
void amiga_open_lib_error(char *name, int version)
|
||||||
{
|
{
|
||||||
Put(NULL, OCX_DIAG, OPEN_VER_ERROR, name, version);
|
Put(NULL, OCX_DIAG, OPEN_VER_ERROR, name, version);
|
||||||
Put(NULL, OCX_DIAG, REQ_ERROR);
|
|
||||||
|
|
||||||
FPrintf(Output(), (STRPTR)OPEN_VER_ERROR, name, version);
|
|
||||||
FPrintf(Output(), (STRPTR)REQ_ERROR, NULL);
|
|
||||||
}
|
}
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
int amiga_open_libs()
|
int amiga_open_libs()
|
||||||
{
|
{
|
||||||
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
||||||
|
@ -130,11 +132,17 @@ int amiga_open_libs()
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimezoneBase = OpenLibrary((STRPTR)TIMEZONELIB_NAME, TIMEZONELIB_REV);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
void amiga_close_libs()
|
void amiga_close_libs()
|
||||||
{
|
{
|
||||||
|
if (TimezoneBase != NULL) {
|
||||||
|
CloseLibrary(TimezoneBase);
|
||||||
|
}
|
||||||
|
|
||||||
if (request != NULL) {
|
if (request != NULL) {
|
||||||
delete_timer();
|
delete_timer();
|
||||||
}
|
}
|
||||||
|
@ -163,65 +171,45 @@ void amiga_close_libs()
|
||||||
CloseLibrary(SocketBase);
|
CloseLibrary(SocketBase);
|
||||||
SocketBase = NULL;
|
SocketBase = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************/
|
if (zone_message != NULL) {
|
||||||
#ifdef HAVE_LIBTZ
|
freemem(zone_message);
|
||||||
int amiga_get_gmtoffset_attime(time_t locale_time)
|
zone_message = NULL;
|
||||||
{
|
|
||||||
struct tm tm;
|
|
||||||
timezone_t tz;
|
|
||||||
char *tzvar;
|
|
||||||
int gmtoffset = 0;
|
|
||||||
|
|
||||||
tzvar = AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
|
||||||
|
|
||||||
GetVar(
|
|
||||||
(STRPTR)TZVARIABLE_NAME,
|
|
||||||
(STRPTR)tzvar,
|
|
||||||
ENVSIZE - 1,
|
|
||||||
GVF_GLOBAL_ONLY
|
|
||||||
);
|
|
||||||
|
|
||||||
tz = tzalloc(tzvar);
|
|
||||||
|
|
||||||
if (tz) {
|
|
||||||
localtime_rz(tz, &locale_time, &tm);
|
|
||||||
tzfree(tz);
|
|
||||||
gmtoffset = tm.tm_gmtoff;
|
|
||||||
} else {
|
|
||||||
gmtoffset = locale->loc_GMTOffset * 60;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Put(NULL, OCX_DEBUG,
|
|
||||||
"Current time zone offset: UTC/GMT %.1f hour\n",
|
|
||||||
(float)gmtoffset / 60.0 / 60.0);
|
|
||||||
|
|
||||||
FreeVec(tzvar);
|
|
||||||
return gmtoffset;
|
|
||||||
}
|
}
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
int amiga_get_gmtoffset()
|
|
||||||
{
|
|
||||||
time_t now = time(NULL);
|
|
||||||
return amiga_get_gmtoffset_attime(now);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/**********************************************************************/
|
|
||||||
void amiga_init_offset()
|
void amiga_init_offset()
|
||||||
{
|
{
|
||||||
int gmt_offset;
|
time_t now;
|
||||||
|
struct tm tm;
|
||||||
|
int gmtoffset;
|
||||||
|
char *abbr;
|
||||||
|
|
||||||
#ifdef HAVE_LIBTZ
|
if (TimezoneBase) {
|
||||||
gmt_offset = amiga_get_gmtoffset();
|
now = time(NULL);
|
||||||
#else
|
localtime_r(&now, &tm);
|
||||||
gmt_offset = locale->loc_GMTOffset * 60 * 60;
|
gmtoffset = tm.tm_gmtoff;
|
||||||
|
abbr = tm.tm_zone;
|
||||||
|
} else {
|
||||||
|
gmtoffset = locale->loc_GMTOffset * 60 * 60;
|
||||||
|
abbr = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
if (!zone_message) {
|
||||||
|
zone_message = allocmem(40);
|
||||||
|
snprintf(zone_message, 40,
|
||||||
|
"Time zone is GMT %s %.f%s%s%s",
|
||||||
|
(gmtoffset >= 0.0 ? "+" : "-"),
|
||||||
|
fabs((float)gmtoffset / 60.0 / 60.0),
|
||||||
|
(abbr != '\0' ? " (" : '\0'),
|
||||||
|
(abbr != '\0' ? abbr : '\0'),
|
||||||
|
(abbr != '\0' ? ")" : '\0')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
offset = -gmt_offset + AMIGAOFFSET;
|
offset = -gmtoffset + AMIGAOFFSET;
|
||||||
}
|
}
|
||||||
/**********************************************************************/
|
//--------------------------------------------------------------------------//
|
||||||
int create_timer()
|
int create_timer()
|
||||||
{
|
{
|
||||||
LONG error;
|
LONG error;
|
||||||
|
@ -251,7 +239,7 @@ int create_timer()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
//--------------------------------------------------------------------------//
|
||||||
int delete_timer()
|
int delete_timer()
|
||||||
{
|
{
|
||||||
struct MsgPort *port;
|
struct MsgPort *port;
|
||||||
|
@ -268,18 +256,13 @@ int delete_timer()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/**********************************************************************/
|
//--------------------------------------------------------------------------//
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
{
|
{
|
||||||
#ifdef USESYSTIME
|
|
||||||
GetSysTime(tv);
|
|
||||||
tv_secs = (long)tv_secs + offset;
|
|
||||||
#else
|
|
||||||
request->tr_node.io_Command = TR_GETSYSTIME;
|
request->tr_node.io_Command = TR_GETSYSTIME;
|
||||||
DoIO((struct IORequest*)request);
|
DoIO((struct IORequest*)request);
|
||||||
tv->tv_secs = (long)request->tr_time.tv_secs + offset;
|
tv->tv_secs = (long)request->tr_time.tv_secs + offset;
|
||||||
tv->tv_micro = request->tr_time.tv_micro;
|
tv->tv_micro = request->tr_time.tv_micro;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,21 +272,35 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||||
request->tr_time.tv_secs = (long)tv->tv_secs - offset;
|
request->tr_time.tv_secs = (long)tv->tv_secs - offset;
|
||||||
request->tr_time.tv_micro = tv->tv_micro;
|
request->tr_time.tv_micro = tv->tv_micro;
|
||||||
DoIO((struct IORequest*)request);
|
DoIO((struct IORequest*)request);
|
||||||
validtime = 1;
|
validtime++;
|
||||||
|
|
||||||
|
// Make sure we are in the right timezone
|
||||||
|
if (validtime == 2) {
|
||||||
|
amiga_init_offset();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/**********************************************************************/
|
//--------------------------------------------------------------------------//
|
||||||
void amiga_save_time(void)
|
void amiga_save_time(void)
|
||||||
{
|
{
|
||||||
|
time_t now;
|
||||||
|
struct tm tm;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int gmt_offset = 0;
|
int gmtoffset = 0;
|
||||||
|
char *message = '\0';
|
||||||
|
|
||||||
#ifdef HAVE_LIBTZ
|
// Assume HW clock is in GMT if timezone library is present
|
||||||
gmt_offset = amiga_get_gmtoffset();
|
if (TimezoneBase) {
|
||||||
#endif
|
now = time(NULL);
|
||||||
|
localtime_r(&now, &tm);
|
||||||
|
gmtoffset = tm.tm_gmtoff;
|
||||||
|
message = " GMT";
|
||||||
|
}
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
WriteBattClock((long)tv.tv_secs - offset - gmt_offset);
|
WriteBattClock((long)tv.tv_secs - offset - gmtoffset);
|
||||||
|
Put(NULL, OCX_DEBUG, "Saved%s to real-time clock\n", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void amiga_sync_time(int seconds)
|
void amiga_sync_time(int seconds)
|
||||||
|
@ -344,7 +341,7 @@ int amiga_sleep_time(double dur)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/**********************************************************************/
|
//--------------------------------------------------------------------------//
|
||||||
void adjust_timeval(struct timeval *tv, double offset)
|
void adjust_timeval(struct timeval *tv, double offset)
|
||||||
{
|
{
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
|
@ -367,7 +364,7 @@ void adjust_timeval(struct timeval *tv, double offset)
|
||||||
tv->tv_secs = secs;
|
tv->tv_secs = secs;
|
||||||
tv->tv_micro = micro;
|
tv->tv_micro = micro;
|
||||||
}
|
}
|
||||||
/**********************************************************************/
|
//--------------------------------------------------------------------------//
|
||||||
#ifndef HAVE_POLL
|
#ifndef HAVE_POLL
|
||||||
int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
|
int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
|
||||||
{
|
{
|
||||||
|
@ -428,4 +425,4 @@ int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/**********************************************************************/
|
//--------------------------------------------------------------------------//
|
||||||
|
|
3
todo.c
3
todo.c
|
@ -167,6 +167,7 @@ enum todo_e
|
||||||
TODO_Run(struct ocx *ocx, struct todolist *tdl)
|
TODO_Run(struct ocx *ocx, struct todolist *tdl)
|
||||||
{
|
{
|
||||||
struct todo *tp;
|
struct todo *tp;
|
||||||
|
struct timestamp show;
|
||||||
enum todo_e ret = TODO_OK;
|
enum todo_e ret = TODO_OK;
|
||||||
char buf[40];
|
char buf[40];
|
||||||
int i;
|
int i;
|
||||||
|
@ -180,6 +181,8 @@ TODO_Run(struct ocx *ocx, struct todolist *tdl)
|
||||||
AZ(i);
|
AZ(i);
|
||||||
TS_Format(buf, sizeof buf, &tp->when);
|
TS_Format(buf, sizeof buf, &tp->when);
|
||||||
Put(ocx, OCX_TRACE, "Now %s %s\n", buf, tp->what);
|
Put(ocx, OCX_TRACE, "Now %s %s\n", buf, tp->what);
|
||||||
|
show = tp->when;
|
||||||
|
PutTime(ocx, OCX_DEBUG, "%s\n", &show);
|
||||||
ret = tp->func(ocx, tdl, tp->priv);
|
ret = tp->func(ocx, tdl, tp->priv);
|
||||||
if (ret == TODO_FAIL)
|
if (ret == TODO_FAIL)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue