diff --git a/compiler.h b/compiler.h index 49ced2e..7478a3f 100644 --- a/compiler.h +++ b/compiler.h @@ -27,10 +27,18 @@ #ifndef NTIMED_COMPILER_H #define NTIMED_COMPILER_H -/* +#include +#include +#include +#include +#include +#include +#include + +/* * See also: * http://codewiz.org/projects/amiga/Headers/CompilerSpecific.h - * + * */ #ifdef __VBCC__ @@ -92,7 +100,7 @@ struct sockaddr_storage { sa_family_t ss_family; // address family // all this is padding, implementation specific, ignore it: - char __ss_pad1[128 - sizeof(sa_family_t)]; + char __ss_pad1[128 - sizeof(sa_family_t)]; }; #endif diff --git a/configure b/configure index bc0a8c4..1d7fadc 100644 --- a/configure +++ b/configure @@ -50,6 +50,7 @@ SRCS=' main_amiga_client.c main_amiga_poll.c main_amiga_sim.c + main_amiga_test.c combine_delta.c mem.c net_getaddrinfo.c @@ -137,6 +138,28 @@ SRCS3=' todo.c udp.c ' + +SRCS4=' + main_amiga_test.c + combine_delta.c + mem.c + net_getaddrinfo.c + net_poll.c + ntp_filter.c + ntp_packet.c + ntp_peer.c + ntp_peerset.c + ntp_tools.c + ocx_stdio.c + param.c + pll_std.c + suckaddr.c + time_amiga.c + time_stuff.c + todo.c + udp.c +' + ################################################# if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then @@ -151,16 +174,16 @@ if $VALID ; then ( echo '# Portable Makefile generated by configure' echo '' - echo 'all: ntimed ntimed-poll ntimed-sim' + echo 'all: ntimed ntimed-poll ntimed-sim ntimed-test' echo '' if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then echo 'CC = gcc' - echo "CFLAGS += -O2 -DAOS3 -Wall -Werror" + echo "CFLAGS += -O2 -DAOS3 -DWITHTEST -Wall -Werror" elif [ -n "$1" ] && [ $1 = "AROS" ] ; then echo 'CC = gcc' - echo "CFLAGS += -O2 -DAROS -Wall -Werror" + echo "CFLAGS += -O2 -DAROS -DWITHTEST -Wall -Werror" else - echo "CFLAGS += -O2 -Wall -Werror" + echo "CFLAGS += -O2 -Wall -DWITHTEST -Werror" fi echo '' @@ -200,18 +223,24 @@ if $VALID ; then do BIN1="${BIN1} `basename $f .c`.o" done - + BIN2="" for f in ${SRCS2} do BIN2="${BIN2} `basename $f .c`.o" done - + BIN3="" for f in ${SRCS3} do BIN3="${BIN3} `basename $f .c`.o" done + + BIN4="" + for f in ${SRCS4} + do + BIN4="${BIN4} `basename $f .c`.o" + done ################################################# echo @@ -224,8 +253,11 @@ if $VALID ; then echo "ntimed-sim: ${BIN3}" echo " \${CC} \${CFLAGS} -o ntimed-sim ${BIN3} -lm" echo + echo "ntimed-test: ${BIN4}" + echo " \${CC} \${CFLAGS} -o ntimed-test ${BIN4} -lm" + echo echo "clean:" - echo " rm -f ${l} ntimed ntimed-poll ntimed-sim" + echo " rm -f ${l} ntimed ntimed-poll ntimed-sim ntimed-test" echo echo "depend:" echo " @echo Dependencies already done" diff --git a/main_amiga_client.c b/main_amiga_client.c index 97b9109..79ab3c0 100644 --- a/main_amiga_client.c +++ b/main_amiga_client.c @@ -25,67 +25,22 @@ * */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef Debug -#undef Debug -#endif - -#ifdef AROS -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#ifdef Debug -#undef Debug -#endif -#endif - -#include "tz.h" -#include "ntimed.h" #include "ntimed_platform.h" -#include "mem.h" +#include "ntimed.h" +#include "tz.h" #include "ntp.h" #include "udp.h" +#define ARGSFORMAT "P=PARAM/K,T=TRACEFILE/K,Z=TIMEZONE/K,SERVERS/M,SYNC/S,SAVE/S,QUIET/S" +const char *vers = "\0$VER: ntimed-client 1.0a"; + #define PARAM_CLIENT PARAM_INSTANCE #define PARAM_TABLE_NAME client_param_table #include "param_instance.h" #undef PARAM_TABLE_NAME #undef PARAM_CLIENT -#define ARGSFORMAT "P=PARAM/K,T=TRACEFILE/K,Z=TIMEZONE/K,SERVERS/M,SYNC/S,SAVE/S,QUIET/S" -const char *vers = "\0$VER: ntimed 1.0a"; - void Time_Amiga(struct todolist *); -void Time_Amiga_Passive(void); extern int validtime; BOOL savetime; diff --git a/main_amiga_poll.c b/main_amiga_poll.c index 6747bff..de3f153 100644 --- a/main_amiga_poll.c +++ b/main_amiga_poll.c @@ -25,56 +25,15 @@ * */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef Debug -#undef Debug -#endif - -#ifdef AROS -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#ifdef Debug -#undef Debug -#endif -#endif - -#include "tz.h" -#include "ntimed.h" #include "ntimed_platform.h" -#include "mem.h" +#include "ntimed.h" +#include "tz.h" #include "ntp.h" #include "udp.h" #define ARGSFORMAT "D=DURATION/N,M=MONITOR/K,T=TRACEFILE/K,Z=TIMEZONE/K,SERVERS/M,QUIET/S" const char *vers = "\0$VER: ntimed-poll 1.0a"; -void Time_Amiga(struct todolist *); void Time_Amiga_Passive(void); BOOL started_from_wb; diff --git a/main_amiga_sim.c b/main_amiga_sim.c index 58b453b..7fcf227 100644 --- a/main_amiga_sim.c +++ b/main_amiga_sim.c @@ -25,52 +25,14 @@ * */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef Debug -#undef Debug -#endif - -#ifdef AROS -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#ifdef Debug -#undef Debug -#endif -#endif - -#include "tz.h" -#include "ntimed.h" #include "ntimed_platform.h" -#include "mem.h" +#include "ntimed.h" #include "ntp.h" #include "udp.h" +#define ARGSFORMAT "P=PARAM/K,B=BUMP/K,T=TRACEFILE/K,SIMFILE/A,QUIET/S" +const char *vers = "\0$VER: ntimed-sim 1.0a"; + #define PARAM_CLIENT PARAM_INSTANCE #define PARAM_TABLE_NAME client_param_table #include "param_instance.h" @@ -107,9 +69,6 @@ struct Library *SocketBase = NULL; struct RDArgs *rdargs = NULL; struct todolist *tdl = NULL; -#define ARGSFORMAT "P=PARAM/K,B=BUMP/K,T=TRACEFILE/K,SIMFILE/A,QUIET/S" -const char *vers = "\0$VER: ntimed-sim 1.0a"; - struct ntimedargs { char *params; char *bump; diff --git a/ntimed_platform.h b/ntimed_platform.h index bfe0c75..0e41d78 100644 --- a/ntimed_platform.h +++ b/ntimed_platform.h @@ -33,6 +33,37 @@ #endif #endif +#include "mem.h" +#include +#include +#include +#include +#include +#include + +#ifdef AROS +#ifdef Debug +#undef Debug +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef Debug +#undef Debug +#endif +#endif + #ifdef AOS3 #define ARGPTR STRPTR #define ARGS_FORMAT ARGSFORMAT diff --git a/ntp.h b/ntp.h index 6821ea6..abe5a42 100644 --- a/ntp.h +++ b/ntp.h @@ -56,28 +56,28 @@ enum ntp_state { /* ntp_packet.c -- [De]Serialisation **********************************/ struct ntp_packet { - unsigned magic; + unsigned magic; #define NTP_PACKET_MAGIC 0x78b7f0be - enum ntp_leap ntp_leap; - uint8_t ntp_version; - enum ntp_mode ntp_mode; - uint8_t ntp_stratum; - uint8_t ntp_poll; - int8_t ntp_precision; - struct timestamp ntp_delay; - struct timestamp ntp_dispersion; - uint8_t ntp_refid[4]; - struct timestamp ntp_reference; - struct timestamp ntp_origin; - struct timestamp ntp_receive; - struct timestamp ntp_transmit; + enum ntp_leap ntp_leap; + uint8_t ntp_version; + enum ntp_mode ntp_mode; + uint8_t ntp_stratum; + uint8_t ntp_poll; + int8_t ntp_precision; + struct timestamp ntp_delay; + struct timestamp ntp_dispersion; + uint8_t ntp_refid[4]; + struct timestamp ntp_reference; + struct timestamp ntp_origin; + struct timestamp ntp_receive; + struct timestamp ntp_transmit; - struct timestamp ts_rx; + struct timestamp ts_rx; }; struct ntp_packet *NTP_Packet_Unpack(struct ntp_packet *dst, void *ptr, - ssize_t len); + ssize_t len); size_t NTP_Packet_Pack(void *ptr, ssize_t len, struct ntp_packet *); /* ntp_tools.c -- Handy tools *****************************************/ @@ -97,45 +97,45 @@ void NF_Init(void); struct ntp_peer { - unsigned magic; + unsigned magic; #define NTP_PEER_MAGIC 0xbf0740a0 - char *hostname; - char *ip; - struct sockaddr *sa; - unsigned sa_len; - struct ntp_packet *tx_pkt; - struct ntp_packet *rx_pkt; + char *hostname; + char *ip; + struct sockaddr *sa; + unsigned sa_len; + struct ntp_packet *tx_pkt; + struct ntp_packet *rx_pkt; - ntp_filter_f *filter_func; - void *filter_priv; + ntp_filter_f *filter_func; + void *filter_priv; - struct combiner *combiner; + struct combiner *combiner; - // For ntp_peerset.c - TAILQ_ENTRY(ntp_peer) list; - struct ntp_group *group; - enum ntp_state state; - const struct ntp_peer *other; + // For ntp_peerset.c + TAILQ_ENTRY(ntp_peer) list; + struct ntp_group *group; + enum ntp_state state; + const struct ntp_peer *other; }; struct ntp_peer *NTP_Peer_New(const char *name, const void *, unsigned); struct ntp_peer *NTP_Peer_NewLookup(struct ocx *ocx, const char *name); void NTP_Peer_Destroy(struct ntp_peer *np); int NTP_Peer_Poll(struct ocx *, const struct udp_socket *, - const struct ntp_peer *, double tmo); + const struct ntp_peer *, double tmo); /* ntp_peerset.c -- Peer set management ****************************/ struct ntp_peerset *NTP_PeerSet_New(struct ocx *); void NTP_PeerSet_AddSim(struct ocx *, struct ntp_peerset *, - const char *hostname, const char *ip); + const char *hostname, const char *ip); int NTP_PeerSet_Add(struct ocx *, struct ntp_peerset *, const char *hostname); void NTP_PeerSet_Poll(struct ocx *, struct ntp_peerset *, struct udp_socket *, - struct todolist *); + struct todolist *); struct ntp_peer *NTP_PeerSet_Iter0(const struct ntp_peerset *); struct ntp_peer *NTP_PeerSet_IterN(const struct ntp_peerset *, - const struct ntp_peer *); + const struct ntp_peer *); #define NTP_PeerSet_Foreach(var, nps) \ for(var = NTP_PeerSet_Iter0(nps); \ diff --git a/time_stuff.c b/time_stuff.c index 29daa35..6ee1f6e 100644 --- a/time_stuff.c +++ b/time_stuff.c @@ -216,6 +216,8 @@ tb_adjust_f *TB_Adjust = tb_Adjust; * Timebase test functions. */ +#ifdef WITHTEST + static int ts_onetest(struct ocx *ocx, const struct timestamp *ts, double off) { @@ -264,4 +266,4 @@ TS_RunTest(struct ocx *ocx) AZ(nf); } - +#endif