summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/libntp
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2015-10-26 11:37:31 +0000
committerglebius <glebius@FreeBSD.org>2015-10-26 11:37:31 +0000
commit81511473d32294dc562d10f7b3e97630ccf0b64f (patch)
tree83f2b5fa5bca87e28ea638c9459aebb211698059 /contrib/ntp/libntp
parenta5a01b895b5c5a5a2f92fb611161c7c0f840a76a (diff)
downloadFreeBSD-src-81511473d32294dc562d10f7b3e97630ccf0b64f.zip
FreeBSD-src-81511473d32294dc562d10f7b3e97630ccf0b64f.tar.gz
Upgrade NTP to 4.2.8p4.
Security: FreeBSD-SA-15:25.ntp Security: CVE-2015-7871 Security: CVE-2015-7855 Security: CVE-2015-7854 Security: CVE-2015-7853 Security: CVE-2015-7852 Security: CVE-2015-7851 Security: CVE-2015-7850 Security: CVE-2015-7849 Security: CVE-2015-7848 Security: CVE-2015-7701 Security: CVE-2015-7703 Security: CVE-2015-7704, CVE-2015-7705 Security: CVE-2015-7691, CVE-2015-7692, CVE-2015-7702 Approved by: so
Diffstat (limited to 'contrib/ntp/libntp')
-rw-r--r--contrib/ntp/libntp/Makefile.am145
-rw-r--r--contrib/ntp/libntp/Makefile.in1881
-rw-r--r--contrib/ntp/libntp/a_md5encrypt.c139
-rw-r--r--contrib/ntp/libntp/atoint.c3
-rw-r--r--contrib/ntp/libntp/atolfp.c14
-rw-r--r--contrib/ntp/libntp/atouint.c31
-rw-r--r--contrib/ntp/libntp/audio.c119
-rw-r--r--contrib/ntp/libntp/authkeys.c716
-rw-r--r--contrib/ntp/libntp/authreadkeys.c210
-rw-r--r--contrib/ntp/libntp/authusekey.c21
-rw-r--r--contrib/ntp/libntp/bsd_strerror.c (renamed from contrib/ntp/libntp/strerror.c)7
-rw-r--r--contrib/ntp/libntp/buftvtots.c15
-rw-r--r--contrib/ntp/libntp/caljulian.c153
-rw-r--r--contrib/ntp/libntp/caltontp.c78
-rw-r--r--contrib/ntp/libntp/calyearstart.c86
-rw-r--r--contrib/ntp/libntp/clocktime.c211
-rw-r--r--contrib/ntp/libntp/clocktypes.c13
-rw-r--r--contrib/ntp/libntp/decodenetnum.c75
-rw-r--r--contrib/ntp/libntp/dofptoa.c43
-rw-r--r--contrib/ntp/libntp/dolfptoa.c207
-rw-r--r--contrib/ntp/libntp/emalloc.c139
-rw-r--r--contrib/ntp/libntp/findconfig.c12
-rw-r--r--contrib/ntp/libntp/fptoa.c25
-rw-r--r--contrib/ntp/libntp/fptoms.c24
-rw-r--r--contrib/ntp/libntp/getopt.c1
-rw-r--r--contrib/ntp/libntp/hextoint.c27
-rw-r--r--contrib/ntp/libntp/hextolfp.c5
-rw-r--r--contrib/ntp/libntp/humandate.c66
-rw-r--r--contrib/ntp/libntp/icom.c321
-rw-r--r--contrib/ntp/libntp/inttoa.c20
-rw-r--r--contrib/ntp/libntp/iosignal.c75
-rw-r--r--contrib/ntp/libntp/lib_strbuf.c26
-rw-r--r--contrib/ntp/libntp/lib_strbuf.h28
-rw-r--r--contrib/ntp/libntp/machines.c112
-rw-r--r--contrib/ntp/libntp/md5c.c354
-rw-r--r--contrib/ntp/libntp/memmove.c140
-rw-r--r--contrib/ntp/libntp/mfptoa.c23
-rw-r--r--contrib/ntp/libntp/mfptoms.c23
-rw-r--r--contrib/ntp/libntp/mktime.c13
-rw-r--r--contrib/ntp/libntp/modetoa.c9
-rw-r--r--contrib/ntp/libntp/mstolfp.c11
-rw-r--r--contrib/ntp/libntp/msutotsf.c35
-rw-r--r--contrib/ntp/libntp/msyslog.c628
-rw-r--r--contrib/ntp/libntp/netof.c57
-rw-r--r--contrib/ntp/libntp/ntp_calendar.c1801
-rw-r--r--contrib/ntp/libntp/ntp_crypto_rnd.c113
-rw-r--r--contrib/ntp/libntp/ntp_intres.c1128
-rw-r--r--contrib/ntp/libntp/ntp_libopts.c58
-rw-r--r--contrib/ntp/libntp/ntp_lineedit.c245
-rw-r--r--contrib/ntp/libntp/ntp_random.c64
-rw-r--r--contrib/ntp/libntp/ntp_rfc2553.c177
-rw-r--r--contrib/ntp/libntp/ntp_worker.c340
-rw-r--r--contrib/ntp/libntp/numtoa.c41
-rw-r--r--contrib/ntp/libntp/numtohost.c11
-rw-r--r--contrib/ntp/libntp/octtoint.c3
-rw-r--r--contrib/ntp/libntp/prettydate.c273
-rw-r--r--contrib/ntp/libntp/recvbuff.c204
-rw-r--r--contrib/ntp/libntp/refidsmear.c58
-rw-r--r--contrib/ntp/libntp/refnumtoa.c38
-rw-r--r--contrib/ntp/libntp/snprintf.c2158
-rw-r--r--contrib/ntp/libntp/socket.c218
-rw-r--r--contrib/ntp/libntp/socktoa.c166
-rw-r--r--contrib/ntp/libntp/socktohost.c95
-rw-r--r--contrib/ntp/libntp/ssl_init.c187
-rw-r--r--contrib/ntp/libntp/statestr.c500
-rw-r--r--contrib/ntp/libntp/strdup.c29
-rw-r--r--contrib/ntp/libntp/strl_obsd.c123
-rw-r--r--contrib/ntp/libntp/strstr.c52
-rw-r--r--contrib/ntp/libntp/syssignal.c159
-rw-r--r--contrib/ntp/libntp/systime.c660
-rw-r--r--contrib/ntp/libntp/timetoa.c106
-rw-r--r--contrib/ntp/libntp/timevalops.c297
-rw-r--r--contrib/ntp/libntp/tsftomsu.c38
-rw-r--r--contrib/ntp/libntp/tstotv.c135
-rw-r--r--contrib/ntp/libntp/tvtoa.c39
-rw-r--r--contrib/ntp/libntp/tvtots.c159
-rw-r--r--contrib/ntp/libntp/uglydate.c9
-rw-r--r--contrib/ntp/libntp/uinttoa.c20
-rw-r--r--contrib/ntp/libntp/utvtoa.c26
-rw-r--r--contrib/ntp/libntp/vint64ops.c284
-rw-r--r--contrib/ntp/libntp/work_fork.c545
-rw-r--r--contrib/ntp/libntp/work_thread.c726
-rw-r--r--contrib/ntp/libntp/ymd2yd.c39
83 files changed, 13474 insertions, 4191 deletions
diff --git a/contrib/ntp/libntp/Makefile.am b/contrib/ntp/libntp/Makefile.am
index 932f87b..914badb 100644
--- a/contrib/ntp/libntp/Makefile.am
+++ b/contrib/ntp/libntp/Makefile.am
@@ -1,38 +1,127 @@
-#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies
-AUTOMAKE_OPTIONS = ../util/ansi2knr
+NULL=
+BUILT_SOURCES =
+CLEANFILES =
noinst_LIBRARIES = libntp.a @MAKE_LIBNTPSIM@
EXTRA_LIBRARIES = libntpsim.a
-libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \
- audio.c authkeys.c authreadkeys.c authusekey.c buftvtots.c \
- caljulian.c caltontp.c calyearstart.c clocktime.c \
- clocktypes.c decodenetnum.c dofptoa.c dolfptoa.c emalloc.c \
- findconfig.c fptoa.c fptoms.c getopt.c hextoint.c \
- hextolfp.c humandate.c icom.c inttoa.c iosignal.c \
- lib_strbuf.c machines.c md5c.c memmove.c mfptoa.c \
- mfptoms.c mktime.c modetoa.c mstolfp.c msutotsf.c msyslog.c netof.c \
- ntp_rfc2553.c numtoa.c numtohost.c octtoint.c prettydate.c \
- ntp_random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \
- statestr.c strdup.c strerror.c strstr.c \
- syssignal.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \
- uglydate.c uinttoa.c utvtoa.c ymd2yd.c \
- $(srcdir)/../libisc/assertions.c $(srcdir)/../libisc/error.c \
- $(srcdir)/../libisc/interfaceiter.c $(srcdir)/../libisc/lib.c \
- $(srcdir)/../libisc/mem.c $(srcdir)/../libisc/msgcat.c \
- $(srcdir)/../libisc/net.c $(srcdir)/../libisc/isc_strerror.c \
- $(srcdir)/../libisc/inet_ntop.c \
- $(srcdir)/../libisc/inet_pton.c \
- $(srcdir)/../libisc/netaddr.c $(srcdir)/../libisc/sockaddr.c \
- $(srcdir)/../libisc/netscope.c
+
+libisc_SRCS = \
+ $(srcdir)/../lib/isc/assertions.c \
+ $(srcdir)/../lib/isc/buffer.c \
+ $(srcdir)/../lib/isc/backtrace-emptytbl.c \
+ $(srcdir)/../lib/isc/backtrace.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c \
+ $(srcdir)/../lib/isc/unix/dir.c \
+ $(srcdir)/../lib/isc/error.c \
+ $(srcdir)/../lib/isc/unix/errno2result.c \
+ $(srcdir)/../lib/isc/event.c \
+ $(srcdir)/../lib/isc/unix/file.c \
+ $(srcdir)/../lib/isc/inet_ntop.c \
+ $(srcdir)/../lib/isc/inet_pton.c \
+ $(srcdir)/../lib/isc/unix/interfaceiter.c \
+ $(srcdir)/../lib/isc/lib.c \
+ $(srcdir)/../lib/isc/log.c \
+ $(srcdir)/../lib/isc/md5.c \
+ $(srcdir)/../lib/isc/nls/msgcat.c \
+ $(srcdir)/../lib/isc/unix/net.c \
+ $(srcdir)/../lib/isc/netaddr.c \
+ $(srcdir)/../lib/isc/netscope.c \
+ $(srcdir)/../lib/isc/ondestroy.c \
+ $(srcdir)/../lib/isc/random.c \
+ $(srcdir)/../lib/isc/result.c \
+ $(srcdir)/../lib/isc/unix/stdio.c \
+ $(srcdir)/../lib/isc/unix/stdtime.c \
+ $(srcdir)/../lib/isc/unix/strerror.c \
+ $(srcdir)/../lib/isc/task.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c \
+ $(srcdir)/../lib/isc/unix/time.c \
+ $(srcdir)/../lib/isc/sha1.c \
+ $(srcdir)/../lib/isc/sockaddr.c \
+ $(NULL)
+
+if PTHREADS
+libisc_SRCS += $(srcdir)/../lib/isc/pthreads/mutex.c
+endif
+
+libntp_a_SRCS = \
+ a_md5encrypt.c \
+ adjtime.c \
+ atoint.c \
+ atolfp.c \
+ atouint.c \
+ audio.c \
+ authkeys.c \
+ authreadkeys.c \
+ authusekey.c \
+ bsd_strerror.c \
+ buftvtots.c \
+ caljulian.c \
+ caltontp.c \
+ calyearstart.c \
+ clocktime.c \
+ clocktypes.c \
+ decodenetnum.c \
+ dofptoa.c \
+ dolfptoa.c \
+ emalloc.c \
+ findconfig.c \
+ getopt.c \
+ hextoint.c \
+ hextolfp.c \
+ humandate.c \
+ icom.c \
+ iosignal.c \
+ lib_strbuf.c \
+ machines.c \
+ mktime.c \
+ modetoa.c \
+ mstolfp.c \
+ msyslog.c \
+ netof.c \
+ ntp_calendar.c \
+ ntp_crypto_rnd.c \
+ ntp_intres.c \
+ ntp_libopts.c \
+ ntp_lineedit.c \
+ ntp_random.c \
+ ntp_rfc2553.c \
+ ntp_worker.c \
+ numtoa.c \
+ numtohost.c \
+ octtoint.c \
+ prettydate.c \
+ refidsmear.c \
+ recvbuff.c \
+ refnumtoa.c \
+ snprintf.c \
+ socket.c \
+ socktoa.c \
+ socktohost.c \
+ ssl_init.c \
+ statestr.c \
+ strdup.c \
+ strl_obsd.c \
+ syssignal.c \
+ timetoa.c \
+ timevalops.c \
+ uglydate.c \
+ vint64ops.c \
+ work_fork.c \
+ work_thread.c \
+ ymd2yd.c \
+ $(libisc_SRCS) \
+ $(NULL)
+
libntp_a_SOURCES = systime.c $(libntp_a_SRCS)
libntpsim_a_SOURCES = systime_s.c $(libntp_a_SRCS)
EXTRA_libntp_a_SOURCES = adjtimex.c
-INCLUDES = -I$(top_srcdir)/include -I../include
-ETAGS_ARGS = Makefile.am
-noinst_HEADERS = lib_strbuf.h
+AM_CFLAGS = $(CFLAGS_NTP)
-../include/des.h:
- touch ../include/des.h
+AM_CPPFLAGS = $(NTP_INCS)
+AM_CPPFLAGS += $(LIBOPTS_CFLAGS)
+AM_CPPFLAGS += $(CPPFLAGS_NTP)
EXTRA_DIST = README
+include $(top_srcdir)/depsver.mf
+include $(top_srcdir)/includes.mf
diff --git a/contrib/ntp/libntp/Makefile.in b/contrib/ntp/libntp/Makefile.in
index 6b6c3367..6e40cd4 100644
--- a/contrib/ntp/libntp/Makefile.in
+++ b/contrib/ntp/libntp/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -15,8 +14,62 @@
@SET_MAKE@
-
VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -35,121 +88,324 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-ANSI2KNR = ../util/ansi2knr
+@PTHREADS_TRUE@am__append_1 = $(srcdir)/../lib/isc/pthreads/mutex.c
subdir = libntp
-DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
- $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
- $(top_srcdir)/m4/define_dir.m4 \
- $(top_srcdir)/m4/hs_ulong_const.m4 \
- $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/version.m4 \
- $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
+ $(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
+ $(top_srcdir)/sntp/m4/define_dir.m4 \
+ $(top_srcdir)/sntp/m4/hms_search_lib.m4 \
+ $(top_srcdir)/sntp/m4/libtool.m4 \
+ $(top_srcdir)/sntp/m4/ltoptions.m4 \
+ $(top_srcdir)/sntp/m4/ltsugar.m4 \
+ $(top_srcdir)/sntp/m4/ltversion.m4 \
+ $(top_srcdir)/sntp/m4/lt~obsolete.m4 \
+ $(top_srcdir)/sntp/m4/ntp_cacheversion.m4 \
+ $(top_srcdir)/sntp/m4/ntp_compiler.m4 \
+ $(top_srcdir)/sntp/m4/ntp_crosscompile.m4 \
+ $(top_srcdir)/sntp/m4/ntp_crypto_rand.m4 \
+ $(top_srcdir)/sntp/m4/ntp_debug.m4 \
+ $(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
+ $(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
+ $(top_srcdir)/sntp/m4/ntp_googletest.m4 \
+ $(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
+ $(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
+ $(top_srcdir)/sntp/m4/ntp_libevent.m4 \
+ $(top_srcdir)/sntp/m4/ntp_libntp.m4 \
+ $(top_srcdir)/sntp/m4/ntp_lineeditlibs.m4 \
+ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \
+ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \
+ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \
+ $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \
+ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \
+ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \
+ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \
+ $(top_srcdir)/sntp/m4/ntp_unitytest.m4 \
+ $(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
+ $(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/os_cflags.m4 \
+ $(top_srcdir)/sntp/m4/snprintf.m4 \
+ $(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LIBRARIES = $(noinst_LIBRARIES)
ARFLAGS = @ARFLAGS@
+AM_V_AR = $(am__v_AR_@AM_V@)
+am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
libntp_a_AR = $(AR) $(ARFLAGS)
libntp_a_LIBADD =
-am__objects_1 = a_md5encrypt$U.$(OBJEXT) adjtime$U.$(OBJEXT) \
- atoint$U.$(OBJEXT) atolfp$U.$(OBJEXT) atouint$U.$(OBJEXT) \
- audio$U.$(OBJEXT) authkeys$U.$(OBJEXT) \
- authreadkeys$U.$(OBJEXT) authusekey$U.$(OBJEXT) \
- buftvtots$U.$(OBJEXT) caljulian$U.$(OBJEXT) \
- caltontp$U.$(OBJEXT) calyearstart$U.$(OBJEXT) \
- clocktime$U.$(OBJEXT) clocktypes$U.$(OBJEXT) \
- decodenetnum$U.$(OBJEXT) dofptoa$U.$(OBJEXT) \
- dolfptoa$U.$(OBJEXT) emalloc$U.$(OBJEXT) \
- findconfig$U.$(OBJEXT) fptoa$U.$(OBJEXT) fptoms$U.$(OBJEXT) \
- getopt$U.$(OBJEXT) hextoint$U.$(OBJEXT) hextolfp$U.$(OBJEXT) \
- humandate$U.$(OBJEXT) icom$U.$(OBJEXT) inttoa$U.$(OBJEXT) \
- iosignal$U.$(OBJEXT) lib_strbuf$U.$(OBJEXT) \
- machines$U.$(OBJEXT) md5c$U.$(OBJEXT) memmove$U.$(OBJEXT) \
- mfptoa$U.$(OBJEXT) mfptoms$U.$(OBJEXT) mktime$U.$(OBJEXT) \
- modetoa$U.$(OBJEXT) mstolfp$U.$(OBJEXT) msutotsf$U.$(OBJEXT) \
- msyslog$U.$(OBJEXT) netof$U.$(OBJEXT) ntp_rfc2553$U.$(OBJEXT) \
- numtoa$U.$(OBJEXT) numtohost$U.$(OBJEXT) octtoint$U.$(OBJEXT) \
- prettydate$U.$(OBJEXT) ntp_random$U.$(OBJEXT) \
- recvbuff$U.$(OBJEXT) refnumtoa$U.$(OBJEXT) \
- snprintf$U.$(OBJEXT) socktoa$U.$(OBJEXT) \
- socktohost$U.$(OBJEXT) statestr$U.$(OBJEXT) strdup$U.$(OBJEXT) \
- strerror$U.$(OBJEXT) strstr$U.$(OBJEXT) syssignal$U.$(OBJEXT) \
- tsftomsu$U.$(OBJEXT) tstotv$U.$(OBJEXT) tvtoa$U.$(OBJEXT) \
- tvtots$U.$(OBJEXT) uglydate$U.$(OBJEXT) uinttoa$U.$(OBJEXT) \
- utvtoa$U.$(OBJEXT) ymd2yd$U.$(OBJEXT) assertions$U.$(OBJEXT) \
- error$U.$(OBJEXT) interfaceiter$U.$(OBJEXT) lib$U.$(OBJEXT) \
- mem$U.$(OBJEXT) msgcat$U.$(OBJEXT) net$U.$(OBJEXT) \
- isc_strerror$U.$(OBJEXT) inet_ntop$U.$(OBJEXT) \
- inet_pton$U.$(OBJEXT) netaddr$U.$(OBJEXT) sockaddr$U.$(OBJEXT) \
- netscope$U.$(OBJEXT)
-am_libntp_a_OBJECTS = systime$U.$(OBJEXT) $(am__objects_1)
+am__libntp_a_SOURCES_DIST = systime.c a_md5encrypt.c adjtime.c \
+ atoint.c atolfp.c atouint.c audio.c authkeys.c authreadkeys.c \
+ authusekey.c bsd_strerror.c buftvtots.c caljulian.c caltontp.c \
+ calyearstart.c clocktime.c clocktypes.c decodenetnum.c \
+ dofptoa.c dolfptoa.c emalloc.c findconfig.c getopt.c \
+ hextoint.c hextolfp.c humandate.c icom.c iosignal.c \
+ lib_strbuf.c machines.c mktime.c modetoa.c mstolfp.c msyslog.c \
+ netof.c ntp_calendar.c ntp_crypto_rnd.c ntp_intres.c \
+ ntp_libopts.c ntp_lineedit.c ntp_random.c ntp_rfc2553.c \
+ ntp_worker.c numtoa.c numtohost.c octtoint.c prettydate.c \
+ refidsmear.c recvbuff.c refnumtoa.c snprintf.c socket.c \
+ socktoa.c socktohost.c ssl_init.c statestr.c strdup.c \
+ strl_obsd.c syssignal.c timetoa.c timevalops.c uglydate.c \
+ vint64ops.c work_fork.c work_thread.c ymd2yd.c \
+ $(srcdir)/../lib/isc/assertions.c \
+ $(srcdir)/../lib/isc/buffer.c \
+ $(srcdir)/../lib/isc/backtrace-emptytbl.c \
+ $(srcdir)/../lib/isc/backtrace.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c \
+ $(srcdir)/../lib/isc/unix/dir.c $(srcdir)/../lib/isc/error.c \
+ $(srcdir)/../lib/isc/unix/errno2result.c \
+ $(srcdir)/../lib/isc/event.c $(srcdir)/../lib/isc/unix/file.c \
+ $(srcdir)/../lib/isc/inet_ntop.c \
+ $(srcdir)/../lib/isc/inet_pton.c \
+ $(srcdir)/../lib/isc/unix/interfaceiter.c \
+ $(srcdir)/../lib/isc/lib.c $(srcdir)/../lib/isc/log.c \
+ $(srcdir)/../lib/isc/md5.c $(srcdir)/../lib/isc/nls/msgcat.c \
+ $(srcdir)/../lib/isc/unix/net.c $(srcdir)/../lib/isc/netaddr.c \
+ $(srcdir)/../lib/isc/netscope.c \
+ $(srcdir)/../lib/isc/ondestroy.c $(srcdir)/../lib/isc/random.c \
+ $(srcdir)/../lib/isc/result.c \
+ $(srcdir)/../lib/isc/unix/stdio.c \
+ $(srcdir)/../lib/isc/unix/stdtime.c \
+ $(srcdir)/../lib/isc/unix/strerror.c \
+ $(srcdir)/../lib/isc/task.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c \
+ $(srcdir)/../lib/isc/unix/time.c $(srcdir)/../lib/isc/sha1.c \
+ $(srcdir)/../lib/isc/sockaddr.c \
+ $(srcdir)/../lib/isc/pthreads/mutex.c
+am__objects_1 =
+@PTHREADS_TRUE@am__objects_2 = mutex.$(OBJEXT)
+am__objects_3 = assertions.$(OBJEXT) buffer.$(OBJEXT) \
+ backtrace-emptytbl.$(OBJEXT) backtrace.$(OBJEXT) \
+ condition.$(OBJEXT) dir.$(OBJEXT) error.$(OBJEXT) \
+ errno2result.$(OBJEXT) event.$(OBJEXT) file.$(OBJEXT) \
+ inet_ntop.$(OBJEXT) inet_pton.$(OBJEXT) \
+ interfaceiter.$(OBJEXT) lib.$(OBJEXT) log.$(OBJEXT) \
+ md5.$(OBJEXT) msgcat.$(OBJEXT) net.$(OBJEXT) netaddr.$(OBJEXT) \
+ netscope.$(OBJEXT) ondestroy.$(OBJEXT) random.$(OBJEXT) \
+ result.$(OBJEXT) stdio.$(OBJEXT) stdtime.$(OBJEXT) \
+ strerror.$(OBJEXT) task.$(OBJEXT) thread.$(OBJEXT) \
+ time.$(OBJEXT) sha1.$(OBJEXT) sockaddr.$(OBJEXT) \
+ $(am__objects_1) $(am__objects_2)
+am__objects_4 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \
+ atoint.$(OBJEXT) atolfp.$(OBJEXT) atouint.$(OBJEXT) \
+ audio.$(OBJEXT) authkeys.$(OBJEXT) authreadkeys.$(OBJEXT) \
+ authusekey.$(OBJEXT) bsd_strerror.$(OBJEXT) \
+ buftvtots.$(OBJEXT) caljulian.$(OBJEXT) caltontp.$(OBJEXT) \
+ calyearstart.$(OBJEXT) clocktime.$(OBJEXT) \
+ clocktypes.$(OBJEXT) decodenetnum.$(OBJEXT) dofptoa.$(OBJEXT) \
+ dolfptoa.$(OBJEXT) emalloc.$(OBJEXT) findconfig.$(OBJEXT) \
+ getopt.$(OBJEXT) hextoint.$(OBJEXT) hextolfp.$(OBJEXT) \
+ humandate.$(OBJEXT) icom.$(OBJEXT) iosignal.$(OBJEXT) \
+ lib_strbuf.$(OBJEXT) machines.$(OBJEXT) mktime.$(OBJEXT) \
+ modetoa.$(OBJEXT) mstolfp.$(OBJEXT) msyslog.$(OBJEXT) \
+ netof.$(OBJEXT) ntp_calendar.$(OBJEXT) \
+ ntp_crypto_rnd.$(OBJEXT) ntp_intres.$(OBJEXT) \
+ ntp_libopts.$(OBJEXT) ntp_lineedit.$(OBJEXT) \
+ ntp_random.$(OBJEXT) ntp_rfc2553.$(OBJEXT) \
+ ntp_worker.$(OBJEXT) numtoa.$(OBJEXT) numtohost.$(OBJEXT) \
+ octtoint.$(OBJEXT) prettydate.$(OBJEXT) refidsmear.$(OBJEXT) \
+ recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) snprintf.$(OBJEXT) \
+ socket.$(OBJEXT) socktoa.$(OBJEXT) socktohost.$(OBJEXT) \
+ ssl_init.$(OBJEXT) statestr.$(OBJEXT) strdup.$(OBJEXT) \
+ strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timetoa.$(OBJEXT) \
+ timevalops.$(OBJEXT) uglydate.$(OBJEXT) vint64ops.$(OBJEXT) \
+ work_fork.$(OBJEXT) work_thread.$(OBJEXT) ymd2yd.$(OBJEXT) \
+ $(am__objects_3) $(am__objects_1)
+am_libntp_a_OBJECTS = systime.$(OBJEXT) $(am__objects_4)
libntp_a_OBJECTS = $(am_libntp_a_OBJECTS)
libntpsim_a_AR = $(AR) $(ARFLAGS)
libntpsim_a_LIBADD =
-am_libntpsim_a_OBJECTS = systime_s$U.$(OBJEXT) $(am__objects_1)
+am__libntpsim_a_SOURCES_DIST = systime_s.c a_md5encrypt.c adjtime.c \
+ atoint.c atolfp.c atouint.c audio.c authkeys.c authreadkeys.c \
+ authusekey.c bsd_strerror.c buftvtots.c caljulian.c caltontp.c \
+ calyearstart.c clocktime.c clocktypes.c decodenetnum.c \
+ dofptoa.c dolfptoa.c emalloc.c findconfig.c getopt.c \
+ hextoint.c hextolfp.c humandate.c icom.c iosignal.c \
+ lib_strbuf.c machines.c mktime.c modetoa.c mstolfp.c msyslog.c \
+ netof.c ntp_calendar.c ntp_crypto_rnd.c ntp_intres.c \
+ ntp_libopts.c ntp_lineedit.c ntp_random.c ntp_rfc2553.c \
+ ntp_worker.c numtoa.c numtohost.c octtoint.c prettydate.c \
+ refidsmear.c recvbuff.c refnumtoa.c snprintf.c socket.c \
+ socktoa.c socktohost.c ssl_init.c statestr.c strdup.c \
+ strl_obsd.c syssignal.c timetoa.c timevalops.c uglydate.c \
+ vint64ops.c work_fork.c work_thread.c ymd2yd.c \
+ $(srcdir)/../lib/isc/assertions.c \
+ $(srcdir)/../lib/isc/buffer.c \
+ $(srcdir)/../lib/isc/backtrace-emptytbl.c \
+ $(srcdir)/../lib/isc/backtrace.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c \
+ $(srcdir)/../lib/isc/unix/dir.c $(srcdir)/../lib/isc/error.c \
+ $(srcdir)/../lib/isc/unix/errno2result.c \
+ $(srcdir)/../lib/isc/event.c $(srcdir)/../lib/isc/unix/file.c \
+ $(srcdir)/../lib/isc/inet_ntop.c \
+ $(srcdir)/../lib/isc/inet_pton.c \
+ $(srcdir)/../lib/isc/unix/interfaceiter.c \
+ $(srcdir)/../lib/isc/lib.c $(srcdir)/../lib/isc/log.c \
+ $(srcdir)/../lib/isc/md5.c $(srcdir)/../lib/isc/nls/msgcat.c \
+ $(srcdir)/../lib/isc/unix/net.c $(srcdir)/../lib/isc/netaddr.c \
+ $(srcdir)/../lib/isc/netscope.c \
+ $(srcdir)/../lib/isc/ondestroy.c $(srcdir)/../lib/isc/random.c \
+ $(srcdir)/../lib/isc/result.c \
+ $(srcdir)/../lib/isc/unix/stdio.c \
+ $(srcdir)/../lib/isc/unix/stdtime.c \
+ $(srcdir)/../lib/isc/unix/strerror.c \
+ $(srcdir)/../lib/isc/task.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c \
+ $(srcdir)/../lib/isc/unix/time.c $(srcdir)/../lib/isc/sha1.c \
+ $(srcdir)/../lib/isc/sockaddr.c \
+ $(srcdir)/../lib/isc/pthreads/mutex.c
+am_libntpsim_a_OBJECTS = systime_s.$(OBJEXT) $(am__objects_4)
libntpsim_a_OBJECTS = $(am_libntpsim_a_OBJECTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
+depcomp = $(SHELL) $(top_srcdir)/sntp/libevent/build-aux/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
- $(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
SOURCES = $(libntp_a_SOURCES) $(EXTRA_libntp_a_SOURCES) \
$(libntpsim_a_SOURCES)
-DIST_SOURCES = $(libntp_a_SOURCES) $(EXTRA_libntp_a_SOURCES) \
- $(libntpsim_a_SOURCES)
-HEADERS = $(noinst_HEADERS)
+DIST_SOURCES = $(am__libntp_a_SOURCES_DIST) $(EXTRA_libntp_a_SOURCES) \
+ $(am__libntpsim_a_SOURCES_DIST)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depsver.mf \
+ $(top_srcdir)/includes.mf \
+ $(top_srcdir)/sntp/libevent/build-aux/depcomp README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
-ARLIB_DIR = @ARLIB_DIR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
-BINSUBDIR = @BINSUBDIR@
+BUILD_THREAD = @BUILD_THREAD@
+CALC_TICKADJ_DB = @CALC_TICKADJ_DB@
+CALC_TICKADJ_DL = @CALC_TICKADJ_DL@
+CALC_TICKADJ_DS = @CALC_TICKADJ_DS@
+CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
+CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
+CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
+CFLAGS_NTP = @CFLAGS_NTP@
CHUTEST = @CHUTEST@
-CLKTEST = @CLKTEST@
+CONFIG_SHELL = @CONFIG_SHELL@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
+CPPFLAGS_NTP = @CPPFLAGS_NTP@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
-ECHO = @ECHO@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
-EF_LIBS = @EF_LIBS@
-EF_PROGS = @EF_PROGS@
+EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
+FGREP = @FGREP@
GREP = @GREP@
+GTEST_CONFIG = @GTEST_CONFIG@
+GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
+GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
+GTEST_LDFLAGS = @GTEST_LDFLAGS@
+GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
+HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
+HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
+HAVE_RLIMIT_STACK = @HAVE_RLIMIT_STACK@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LCRYPTO = @LCRYPTO@
+LD = @LD@
+LDADD_LIBEVENT = @LDADD_LIBEVENT@
+LDADD_LIBNTP = @LDADD_LIBNTP@
+LDADD_LIBUTIL = @LDADD_LIBUTIL@
+LDADD_NLIST = @LDADD_NLIST@
+LDADD_NTP = @LDADD_NTP@
LDFLAGS = @LDFLAGS@
+LDFLAGS_NTP = @LDFLAGS_NTP@
+LIBISC_PTHREADS_NOTHREADS = @LIBISC_PTHREADS_NOTHREADS@
+LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
LIBOPTS_DIR = @LIBOPTS_DIR@
@@ -157,8 +413,11 @@ LIBOPTS_LDADD = @LIBOPTS_LDADD@
LIBPARSE = @LIBPARSE@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
LN_S = @LN_S@
LSCF = @LSCF@
+LTHREAD_LIBS = @LTHREAD_LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAKE_ADJTIMED = @MAKE_ADJTIMED@
@@ -168,15 +427,76 @@ MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
MAKE_LIBPARSE = @MAKE_LIBPARSE@
MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPSNMPD = @MAKE_NTPSNMPD@
MAKE_NTPTIME = @MAKE_NTPTIME@
MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
MAKE_TICKADJ = @MAKE_TICKADJ@
MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MANTAGFMT = @MANTAGFMT@
MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NTPDATE_DB = @NTPDATE_DB@
+NTPDATE_DL = @NTPDATE_DL@
+NTPDATE_DS = @NTPDATE_DS@
+NTPDATE_MS = @NTPDATE_MS@
+NTPDATE_NI = @NTPDATE_NI@
+NTPDC_DB = @NTPDC_DB@
+NTPDC_DL = @NTPDC_DL@
+NTPDC_DS = @NTPDC_DS@
+NTPDC_MS = @NTPDC_MS@
+NTPDC_NI = @NTPDC_NI@
+NTPDSIM_DB = @NTPDSIM_DB@
+NTPDSIM_DL = @NTPDSIM_DL@
+NTPDSIM_DS = @NTPDSIM_DS@
+NTPDSIM_MS = @NTPDSIM_MS@
+NTPDSIM_NI = @NTPDSIM_NI@
+NTPD_DB = @NTPD_DB@
+NTPD_DL = @NTPD_DL@
+NTPD_DS = @NTPD_DS@
+NTPD_MS = @NTPD_MS@
+NTPD_NI = @NTPD_NI@
+NTPQ_DB = @NTPQ_DB@
+NTPQ_DL = @NTPQ_DL@
+NTPQ_DS = @NTPQ_DS@
+NTPQ_MS = @NTPQ_MS@
+NTPQ_NI = @NTPQ_NI@
+NTPSNMPD_DB = @NTPSNMPD_DB@
+NTPSNMPD_DL = @NTPSNMPD_DL@
+NTPSNMPD_DS = @NTPSNMPD_DS@
+NTPSNMPD_MS = @NTPSNMPD_MS@
+NTPSNMPD_NI = @NTPSNMPD_NI@
+NTPSWEEP_DB = @NTPSWEEP_DB@
+NTPSWEEP_DL = @NTPSWEEP_DL@
+NTPSWEEP_DS = @NTPSWEEP_DS@
+NTPSWEEP_MS = @NTPSWEEP_MS@
+NTPSWEEP_NI = @NTPSWEEP_NI@
+NTPTIME_DB = @NTPTIME_DB@
+NTPTIME_DL = @NTPTIME_DL@
+NTPTIME_DS = @NTPTIME_DS@
+NTPTIME_MS = @NTPTIME_MS@
+NTPTIME_NI = @NTPTIME_NI@
+NTPTRACE_DB = @NTPTRACE_DB@
+NTPTRACE_DL = @NTPTRACE_DL@
+NTPTRACE_DS = @NTPTRACE_DS@
+NTPTRACE_MS = @NTPTRACE_MS@
+NTPTRACE_NI = @NTPTRACE_NI@
+NTP_KEYGEN_DB = @NTP_KEYGEN_DB@
+NTP_KEYGEN_DL = @NTP_KEYGEN_DL@
+NTP_KEYGEN_DS = @NTP_KEYGEN_DS@
+NTP_KEYGEN_MS = @NTP_KEYGEN_MS@
+NTP_KEYGEN_NI = @NTP_KEYGEN_NI@
+NTP_KEYSDIR = @NTP_KEYSDIR@
+NTP_WAIT_DB = @NTP_WAIT_DB@
+NTP_WAIT_DL = @NTP_WAIT_DL@
+NTP_WAIT_DS = @NTP_WAIT_DS@
+NTP_WAIT_MS = @NTP_WAIT_MS@
+NTP_WAIT_NI = @NTP_WAIT_NI@
+OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
-OPENSSL = @OPENSSL@
-OPENSSL_INC = @OPENSSL_INC@
-OPENSSL_LIB = @OPENSSL_LIB@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
@@ -184,23 +504,59 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
PATH_PERL = @PATH_PERL@
+PATH_RUBY = @PATH_RUBY@
PATH_SEPARATOR = @PATH_SEPARATOR@
-PATH_SH = @PATH_SH@
+PATH_TEST = @PATH_TEST@
+PERLLIBDIR = @PERLLIBDIR@
+PKG_CONFIG = @PKG_CONFIG@
+POSIX_SHELL = @POSIX_SHELL@
PROPDELAY = @PROPDELAY@
+PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@
-READLINE_LIBS = @READLINE_LIBS@
+SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
+SNMP_CFLAGS = @SNMP_CFLAGS@
+SNMP_CPPFLAGS = @SNMP_CPPFLAGS@
+SNMP_LIBS = @SNMP_LIBS@
+SNTP = @SNTP@
+SNTP_DB = @SNTP_DB@
+SNTP_DL = @SNTP_DL@
+SNTP_DS = @SNTP_DS@
+SNTP_MS = @SNTP_MS@
+SNTP_NI = @SNTP_NI@
+STDNORETURN_H = @STDNORETURN_H@
STRIP = @STRIP@
TESTDCF = @TESTDCF@
-U = @U@
+TICKADJ_DB = @TICKADJ_DB@
+TICKADJ_DL = @TICKADJ_DL@
+TICKADJ_DS = @TICKADJ_DS@
+TICKADJ_MS = @TICKADJ_MS@
+TICKADJ_NI = @TICKADJ_NI@
+TIMETRIM_DB = @TIMETRIM_DB@
+TIMETRIM_DL = @TIMETRIM_DL@
+TIMETRIM_DS = @TIMETRIM_DS@
+TIMETRIM_MS = @TIMETRIM_MS@
+TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
+VER_SUFFIX = @VER_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -247,45 +603,119 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-
-#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies
-AUTOMAKE_OPTIONS = ../util/ansi2knr
+NULL =
+BUILT_SOURCES = .deps-ver
+CLEANFILES = .deps-ver
noinst_LIBRARIES = libntp.a @MAKE_LIBNTPSIM@
EXTRA_LIBRARIES = libntpsim.a
-libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \
- audio.c authkeys.c authreadkeys.c authusekey.c buftvtots.c \
- caljulian.c caltontp.c calyearstart.c clocktime.c \
- clocktypes.c decodenetnum.c dofptoa.c dolfptoa.c emalloc.c \
- findconfig.c fptoa.c fptoms.c getopt.c hextoint.c \
- hextolfp.c humandate.c icom.c inttoa.c iosignal.c \
- lib_strbuf.c machines.c md5c.c memmove.c mfptoa.c \
- mfptoms.c mktime.c modetoa.c mstolfp.c msutotsf.c msyslog.c netof.c \
- ntp_rfc2553.c numtoa.c numtohost.c octtoint.c prettydate.c \
- ntp_random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \
- statestr.c strdup.c strerror.c strstr.c \
- syssignal.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \
- uglydate.c uinttoa.c utvtoa.c ymd2yd.c \
- $(srcdir)/../libisc/assertions.c $(srcdir)/../libisc/error.c \
- $(srcdir)/../libisc/interfaceiter.c $(srcdir)/../libisc/lib.c \
- $(srcdir)/../libisc/mem.c $(srcdir)/../libisc/msgcat.c \
- $(srcdir)/../libisc/net.c $(srcdir)/../libisc/isc_strerror.c \
- $(srcdir)/../libisc/inet_ntop.c \
- $(srcdir)/../libisc/inet_pton.c \
- $(srcdir)/../libisc/netaddr.c $(srcdir)/../libisc/sockaddr.c \
- $(srcdir)/../libisc/netscope.c
+libisc_SRCS = $(srcdir)/../lib/isc/assertions.c \
+ $(srcdir)/../lib/isc/buffer.c \
+ $(srcdir)/../lib/isc/backtrace-emptytbl.c \
+ $(srcdir)/../lib/isc/backtrace.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c \
+ $(srcdir)/../lib/isc/unix/dir.c $(srcdir)/../lib/isc/error.c \
+ $(srcdir)/../lib/isc/unix/errno2result.c \
+ $(srcdir)/../lib/isc/event.c $(srcdir)/../lib/isc/unix/file.c \
+ $(srcdir)/../lib/isc/inet_ntop.c \
+ $(srcdir)/../lib/isc/inet_pton.c \
+ $(srcdir)/../lib/isc/unix/interfaceiter.c \
+ $(srcdir)/../lib/isc/lib.c $(srcdir)/../lib/isc/log.c \
+ $(srcdir)/../lib/isc/md5.c $(srcdir)/../lib/isc/nls/msgcat.c \
+ $(srcdir)/../lib/isc/unix/net.c $(srcdir)/../lib/isc/netaddr.c \
+ $(srcdir)/../lib/isc/netscope.c \
+ $(srcdir)/../lib/isc/ondestroy.c $(srcdir)/../lib/isc/random.c \
+ $(srcdir)/../lib/isc/result.c \
+ $(srcdir)/../lib/isc/unix/stdio.c \
+ $(srcdir)/../lib/isc/unix/stdtime.c \
+ $(srcdir)/../lib/isc/unix/strerror.c \
+ $(srcdir)/../lib/isc/task.c \
+ $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c \
+ $(srcdir)/../lib/isc/unix/time.c $(srcdir)/../lib/isc/sha1.c \
+ $(srcdir)/../lib/isc/sockaddr.c $(NULL) $(am__append_1)
+libntp_a_SRCS = \
+ a_md5encrypt.c \
+ adjtime.c \
+ atoint.c \
+ atolfp.c \
+ atouint.c \
+ audio.c \
+ authkeys.c \
+ authreadkeys.c \
+ authusekey.c \
+ bsd_strerror.c \
+ buftvtots.c \
+ caljulian.c \
+ caltontp.c \
+ calyearstart.c \
+ clocktime.c \
+ clocktypes.c \
+ decodenetnum.c \
+ dofptoa.c \
+ dolfptoa.c \
+ emalloc.c \
+ findconfig.c \
+ getopt.c \
+ hextoint.c \
+ hextolfp.c \
+ humandate.c \
+ icom.c \
+ iosignal.c \
+ lib_strbuf.c \
+ machines.c \
+ mktime.c \
+ modetoa.c \
+ mstolfp.c \
+ msyslog.c \
+ netof.c \
+ ntp_calendar.c \
+ ntp_crypto_rnd.c \
+ ntp_intres.c \
+ ntp_libopts.c \
+ ntp_lineedit.c \
+ ntp_random.c \
+ ntp_rfc2553.c \
+ ntp_worker.c \
+ numtoa.c \
+ numtohost.c \
+ octtoint.c \
+ prettydate.c \
+ refidsmear.c \
+ recvbuff.c \
+ refnumtoa.c \
+ snprintf.c \
+ socket.c \
+ socktoa.c \
+ socktohost.c \
+ ssl_init.c \
+ statestr.c \
+ strdup.c \
+ strl_obsd.c \
+ syssignal.c \
+ timetoa.c \
+ timevalops.c \
+ uglydate.c \
+ vint64ops.c \
+ work_fork.c \
+ work_thread.c \
+ ymd2yd.c \
+ $(libisc_SRCS) \
+ $(NULL)
libntp_a_SOURCES = systime.c $(libntp_a_SRCS)
libntpsim_a_SOURCES = systime_s.c $(libntp_a_SRCS)
EXTRA_libntp_a_SOURCES = adjtimex.c
-INCLUDES = -I$(top_srcdir)/include -I../include
-ETAGS_ARGS = Makefile.am
-noinst_HEADERS = lib_strbuf.h
+AM_CFLAGS = $(CFLAGS_NTP)
+AM_CPPFLAGS = $(NTP_INCS) $(LIBOPTS_CFLAGS) $(CPPFLAGS_NTP)
EXTRA_DIST = README
-all: all-am
+NTP_INCS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \
+ -I$(top_srcdir)/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include \
+ -I$(top_srcdir)/lib/isc/unix/include
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -297,7 +727,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libntp/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign libntp/Makefile
-.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@@ -306,6 +735,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
+$(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__empty):
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -318,696 +748,592 @@ $(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
-libntp.a: $(libntp_a_OBJECTS) $(libntp_a_DEPENDENCIES)
- -rm -f libntp.a
- $(libntp_a_AR) libntp.a $(libntp_a_OBJECTS) $(libntp_a_LIBADD)
- $(RANLIB) libntp.a
-libntpsim.a: $(libntpsim_a_OBJECTS) $(libntpsim_a_DEPENDENCIES)
- -rm -f libntpsim.a
- $(libntpsim_a_AR) libntpsim.a $(libntpsim_a_OBJECTS) $(libntpsim_a_LIBADD)
- $(RANLIB) libntpsim.a
+
+libntp.a: $(libntp_a_OBJECTS) $(libntp_a_DEPENDENCIES) $(EXTRA_libntp_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libntp.a
+ $(AM_V_AR)$(libntp_a_AR) libntp.a $(libntp_a_OBJECTS) $(libntp_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libntp.a
+
+libntpsim.a: $(libntpsim_a_OBJECTS) $(libntpsim_a_DEPENDENCIES) $(EXTRA_libntpsim_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libntpsim.a
+ $(AM_V_AR)$(libntpsim_a_AR) libntpsim.a $(libntpsim_a_OBJECTS) $(libntpsim_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libntpsim.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
-../util/ansi2knr:
- $(am__cd) ../util && $(MAKE) $(AM_MAKEFLAGS) ./ansi2knr
-
-mostlyclean-kr:
- -test "$U" = "" || rm -f *_.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_md5encrypt$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtime$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtimex$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assertions$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atoint$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atolfp$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atouint$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authkeys$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authreadkeys$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authusekey$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buftvtots$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caljulian$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caltontp$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calyearstart$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clocktime$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clocktypes$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decodenetnum$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dofptoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dolfptoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emalloc$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/findconfig$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fptoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fptoms$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hextoint$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hextolfp$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/humandate$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icom$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_ntop$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_pton$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interfaceiter$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inttoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iosignal$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isc_strerror$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_strbuf$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machines$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5c$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memmove$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfptoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfptoms$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modetoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msgcat$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mstolfp$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msutotsf$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msyslog$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netaddr$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netof$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netscope$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_random$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_rfc2553$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtohost$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/octtoint$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prettydate$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recvbuff$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refnumtoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockaddr$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktohost$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statestr$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syssignal$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/systime$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/systime_s$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsftomsu$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tstotv$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvtoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvtots$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uglydate$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uinttoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utvtoa$U.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ymd2yd$U.Po@am__quote@
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_md5encrypt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtimex.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assertions.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atoint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atolfp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atouint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authkeys.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authreadkeys.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authusekey.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backtrace-emptytbl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backtrace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_strerror.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buftvtots.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caljulian.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caltontp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calyearstart.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clocktime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clocktypes.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/condition.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decodenetnum.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dofptoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dolfptoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emalloc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errno2result.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/findconfig.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hextoint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hextolfp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/humandate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icom.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_ntop.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_pton.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interfaceiter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iosignal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib_strbuf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machines.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modetoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msgcat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mstolfp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msyslog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutex.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netaddr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netof.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netscope.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_calendar.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_crypto_rnd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_intres.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_libopts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_lineedit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_random.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_rfc2553.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_worker.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtohost.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/octtoint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ondestroy.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prettydate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recvbuff.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refidsmear.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refnumtoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/result.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockaddr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socktohost.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statestr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdtime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strl_obsd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syssignal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/systime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/systime_s.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/task.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timetoa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timevalops.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uglydate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vint64ops.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/work_fork.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/work_thread.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ymd2yd.Po@am__quote@
.c.o:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
-@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+assertions.o: $(srcdir)/../lib/isc/assertions.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions.o -MD -MP -MF $(DEPDIR)/assertions.Tpo -c -o assertions.o `test -f '$(srcdir)/../lib/isc/assertions.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/assertions.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/assertions.Tpo $(DEPDIR)/assertions.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/assertions.c' object='assertions.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions.o `test -f '$(srcdir)/../lib/isc/assertions.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/assertions.c
+
+assertions.obj: $(srcdir)/../lib/isc/assertions.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions.obj -MD -MP -MF $(DEPDIR)/assertions.Tpo -c -o assertions.obj `if test -f '$(srcdir)/../lib/isc/assertions.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/assertions.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/assertions.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/assertions.Tpo $(DEPDIR)/assertions.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/assertions.c' object='assertions.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions.obj `if test -f '$(srcdir)/../lib/isc/assertions.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/assertions.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/assertions.c'; fi`
+
+buffer.o: $(srcdir)/../lib/isc/buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT buffer.o -MD -MP -MF $(DEPDIR)/buffer.Tpo -c -o buffer.o `test -f '$(srcdir)/../lib/isc/buffer.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/buffer.Tpo $(DEPDIR)/buffer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/buffer.c' object='buffer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o buffer.o `test -f '$(srcdir)/../lib/isc/buffer.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/buffer.c
+
+buffer.obj: $(srcdir)/../lib/isc/buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT buffer.obj -MD -MP -MF $(DEPDIR)/buffer.Tpo -c -o buffer.obj `if test -f '$(srcdir)/../lib/isc/buffer.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/buffer.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/buffer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/buffer.Tpo $(DEPDIR)/buffer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/buffer.c' object='buffer.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o buffer.obj `if test -f '$(srcdir)/../lib/isc/buffer.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/buffer.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/buffer.c'; fi`
-assertions_.o: assertions_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions_.o -MD -MP -MF $(DEPDIR)/assertions_.Tpo -c -o assertions_.o `test -f 'assertions_.c' || echo '$(srcdir)/'`assertions_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/assertions_.Tpo $(DEPDIR)/assertions_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='assertions_.c' object='assertions_.o' libtool=no @AMDEPBACKSLASH@
+backtrace-emptytbl.o: $(srcdir)/../lib/isc/backtrace-emptytbl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT backtrace-emptytbl.o -MD -MP -MF $(DEPDIR)/backtrace-emptytbl.Tpo -c -o backtrace-emptytbl.o `test -f '$(srcdir)/../lib/isc/backtrace-emptytbl.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/backtrace-emptytbl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/backtrace-emptytbl.Tpo $(DEPDIR)/backtrace-emptytbl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/backtrace-emptytbl.c' object='backtrace-emptytbl.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions_.o `test -f 'assertions_.c' || echo '$(srcdir)/'`assertions_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o backtrace-emptytbl.o `test -f '$(srcdir)/../lib/isc/backtrace-emptytbl.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/backtrace-emptytbl.c
-assertions_.obj: assertions_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions_.obj -MD -MP -MF $(DEPDIR)/assertions_.Tpo -c -o assertions_.obj `if test -f 'assertions_.c'; then $(CYGPATH_W) 'assertions_.c'; else $(CYGPATH_W) '$(srcdir)/assertions_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/assertions_.Tpo $(DEPDIR)/assertions_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='assertions_.c' object='assertions_.obj' libtool=no @AMDEPBACKSLASH@
+backtrace-emptytbl.obj: $(srcdir)/../lib/isc/backtrace-emptytbl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT backtrace-emptytbl.obj -MD -MP -MF $(DEPDIR)/backtrace-emptytbl.Tpo -c -o backtrace-emptytbl.obj `if test -f '$(srcdir)/../lib/isc/backtrace-emptytbl.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/backtrace-emptytbl.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/backtrace-emptytbl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/backtrace-emptytbl.Tpo $(DEPDIR)/backtrace-emptytbl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/backtrace-emptytbl.c' object='backtrace-emptytbl.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions_.obj `if test -f 'assertions_.c'; then $(CYGPATH_W) 'assertions_.c'; else $(CYGPATH_W) '$(srcdir)/assertions_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o backtrace-emptytbl.obj `if test -f '$(srcdir)/../lib/isc/backtrace-emptytbl.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/backtrace-emptytbl.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/backtrace-emptytbl.c'; fi`
-assertions.o: $(srcdir)/../libisc/assertions.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions.o -MD -MP -MF $(DEPDIR)/assertions.Tpo -c -o assertions.o `test -f '$(srcdir)/../libisc/assertions.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/assertions.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/assertions.Tpo $(DEPDIR)/assertions.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/assertions.c' object='assertions.o' libtool=no @AMDEPBACKSLASH@
+backtrace.o: $(srcdir)/../lib/isc/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT backtrace.o -MD -MP -MF $(DEPDIR)/backtrace.Tpo -c -o backtrace.o `test -f '$(srcdir)/../lib/isc/backtrace.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/backtrace.Tpo $(DEPDIR)/backtrace.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/backtrace.c' object='backtrace.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions.o `test -f '$(srcdir)/../libisc/assertions.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/assertions.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o backtrace.o `test -f '$(srcdir)/../lib/isc/backtrace.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/backtrace.c
-assertions.obj: $(srcdir)/../libisc/assertions.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT assertions.obj -MD -MP -MF $(DEPDIR)/assertions.Tpo -c -o assertions.obj `if test -f '$(srcdir)/../libisc/assertions.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/assertions.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/assertions.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/assertions.Tpo $(DEPDIR)/assertions.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/assertions.c' object='assertions.obj' libtool=no @AMDEPBACKSLASH@
+backtrace.obj: $(srcdir)/../lib/isc/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT backtrace.obj -MD -MP -MF $(DEPDIR)/backtrace.Tpo -c -o backtrace.obj `if test -f '$(srcdir)/../lib/isc/backtrace.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/backtrace.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/backtrace.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/backtrace.Tpo $(DEPDIR)/backtrace.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/backtrace.c' object='backtrace.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o assertions.obj `if test -f '$(srcdir)/../libisc/assertions.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/assertions.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/assertions.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o backtrace.obj `if test -f '$(srcdir)/../lib/isc/backtrace.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/backtrace.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/backtrace.c'; fi`
-error_.o: error_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error_.o -MD -MP -MF $(DEPDIR)/error_.Tpo -c -o error_.o `test -f 'error_.c' || echo '$(srcdir)/'`error_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/error_.Tpo $(DEPDIR)/error_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error_.c' object='error_.o' libtool=no @AMDEPBACKSLASH@
+condition.o: $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT condition.o -MD -MP -MF $(DEPDIR)/condition.Tpo -c -o condition.o `test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/condition.Tpo $(DEPDIR)/condition.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c' object='condition.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error_.o `test -f 'error_.c' || echo '$(srcdir)/'`error_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o condition.o `test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c
-error_.obj: error_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error_.obj -MD -MP -MF $(DEPDIR)/error_.Tpo -c -o error_.obj `if test -f 'error_.c'; then $(CYGPATH_W) 'error_.c'; else $(CYGPATH_W) '$(srcdir)/error_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/error_.Tpo $(DEPDIR)/error_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error_.c' object='error_.obj' libtool=no @AMDEPBACKSLASH@
+condition.obj: $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT condition.obj -MD -MP -MF $(DEPDIR)/condition.Tpo -c -o condition.obj `if test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/condition.Tpo $(DEPDIR)/condition.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c' object='condition.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error_.obj `if test -f 'error_.c'; then $(CYGPATH_W) 'error_.c'; else $(CYGPATH_W) '$(srcdir)/error_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o condition.obj `if test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/condition.c'; fi`
-error.o: $(srcdir)/../libisc/error.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error.o -MD -MP -MF $(DEPDIR)/error.Tpo -c -o error.o `test -f '$(srcdir)/../libisc/error.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/error.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/error.Tpo $(DEPDIR)/error.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/error.c' object='error.o' libtool=no @AMDEPBACKSLASH@
+dir.o: $(srcdir)/../lib/isc/unix/dir.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dir.o -MD -MP -MF $(DEPDIR)/dir.Tpo -c -o dir.o `test -f '$(srcdir)/../lib/isc/unix/dir.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/dir.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dir.Tpo $(DEPDIR)/dir.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/dir.c' object='dir.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error.o `test -f '$(srcdir)/../libisc/error.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/error.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dir.o `test -f '$(srcdir)/../lib/isc/unix/dir.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/dir.c
-error.obj: $(srcdir)/../libisc/error.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error.obj -MD -MP -MF $(DEPDIR)/error.Tpo -c -o error.obj `if test -f '$(srcdir)/../libisc/error.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/error.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/error.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/error.Tpo $(DEPDIR)/error.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/error.c' object='error.obj' libtool=no @AMDEPBACKSLASH@
+dir.obj: $(srcdir)/../lib/isc/unix/dir.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dir.obj -MD -MP -MF $(DEPDIR)/dir.Tpo -c -o dir.obj `if test -f '$(srcdir)/../lib/isc/unix/dir.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/dir.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/dir.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dir.Tpo $(DEPDIR)/dir.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/dir.c' object='dir.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error.obj `if test -f '$(srcdir)/../libisc/error.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/error.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/error.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dir.obj `if test -f '$(srcdir)/../lib/isc/unix/dir.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/dir.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/dir.c'; fi`
-interfaceiter_.o: interfaceiter_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter_.o -MD -MP -MF $(DEPDIR)/interfaceiter_.Tpo -c -o interfaceiter_.o `test -f 'interfaceiter_.c' || echo '$(srcdir)/'`interfaceiter_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/interfaceiter_.Tpo $(DEPDIR)/interfaceiter_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interfaceiter_.c' object='interfaceiter_.o' libtool=no @AMDEPBACKSLASH@
+error.o: $(srcdir)/../lib/isc/error.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error.o -MD -MP -MF $(DEPDIR)/error.Tpo -c -o error.o `test -f '$(srcdir)/../lib/isc/error.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/error.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/error.Tpo $(DEPDIR)/error.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/error.c' object='error.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter_.o `test -f 'interfaceiter_.c' || echo '$(srcdir)/'`interfaceiter_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error.o `test -f '$(srcdir)/../lib/isc/error.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/error.c
-interfaceiter_.obj: interfaceiter_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter_.obj -MD -MP -MF $(DEPDIR)/interfaceiter_.Tpo -c -o interfaceiter_.obj `if test -f 'interfaceiter_.c'; then $(CYGPATH_W) 'interfaceiter_.c'; else $(CYGPATH_W) '$(srcdir)/interfaceiter_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/interfaceiter_.Tpo $(DEPDIR)/interfaceiter_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interfaceiter_.c' object='interfaceiter_.obj' libtool=no @AMDEPBACKSLASH@
+error.obj: $(srcdir)/../lib/isc/error.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error.obj -MD -MP -MF $(DEPDIR)/error.Tpo -c -o error.obj `if test -f '$(srcdir)/../lib/isc/error.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/error.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/error.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/error.Tpo $(DEPDIR)/error.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/error.c' object='error.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter_.obj `if test -f 'interfaceiter_.c'; then $(CYGPATH_W) 'interfaceiter_.c'; else $(CYGPATH_W) '$(srcdir)/interfaceiter_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error.obj `if test -f '$(srcdir)/../lib/isc/error.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/error.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/error.c'; fi`
-interfaceiter.o: $(srcdir)/../libisc/interfaceiter.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter.o -MD -MP -MF $(DEPDIR)/interfaceiter.Tpo -c -o interfaceiter.o `test -f '$(srcdir)/../libisc/interfaceiter.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/interfaceiter.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/interfaceiter.Tpo $(DEPDIR)/interfaceiter.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/interfaceiter.c' object='interfaceiter.o' libtool=no @AMDEPBACKSLASH@
+errno2result.o: $(srcdir)/../lib/isc/unix/errno2result.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errno2result.o -MD -MP -MF $(DEPDIR)/errno2result.Tpo -c -o errno2result.o `test -f '$(srcdir)/../lib/isc/unix/errno2result.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/errno2result.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/errno2result.Tpo $(DEPDIR)/errno2result.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/errno2result.c' object='errno2result.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter.o `test -f '$(srcdir)/../libisc/interfaceiter.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/interfaceiter.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errno2result.o `test -f '$(srcdir)/../lib/isc/unix/errno2result.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/errno2result.c
-interfaceiter.obj: $(srcdir)/../libisc/interfaceiter.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter.obj -MD -MP -MF $(DEPDIR)/interfaceiter.Tpo -c -o interfaceiter.obj `if test -f '$(srcdir)/../libisc/interfaceiter.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/interfaceiter.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/interfaceiter.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/interfaceiter.Tpo $(DEPDIR)/interfaceiter.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/interfaceiter.c' object='interfaceiter.obj' libtool=no @AMDEPBACKSLASH@
+errno2result.obj: $(srcdir)/../lib/isc/unix/errno2result.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errno2result.obj -MD -MP -MF $(DEPDIR)/errno2result.Tpo -c -o errno2result.obj `if test -f '$(srcdir)/../lib/isc/unix/errno2result.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/errno2result.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/errno2result.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/errno2result.Tpo $(DEPDIR)/errno2result.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/errno2result.c' object='errno2result.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter.obj `if test -f '$(srcdir)/../libisc/interfaceiter.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/interfaceiter.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/interfaceiter.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errno2result.obj `if test -f '$(srcdir)/../lib/isc/unix/errno2result.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/errno2result.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/errno2result.c'; fi`
-lib_.o: lib_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib_.o -MD -MP -MF $(DEPDIR)/lib_.Tpo -c -o lib_.o `test -f 'lib_.c' || echo '$(srcdir)/'`lib_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/lib_.Tpo $(DEPDIR)/lib_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lib_.c' object='lib_.o' libtool=no @AMDEPBACKSLASH@
+event.o: $(srcdir)/../lib/isc/event.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT event.o -MD -MP -MF $(DEPDIR)/event.Tpo -c -o event.o `test -f '$(srcdir)/../lib/isc/event.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/event.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/event.Tpo $(DEPDIR)/event.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/event.c' object='event.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib_.o `test -f 'lib_.c' || echo '$(srcdir)/'`lib_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o event.o `test -f '$(srcdir)/../lib/isc/event.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/event.c
-lib_.obj: lib_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib_.obj -MD -MP -MF $(DEPDIR)/lib_.Tpo -c -o lib_.obj `if test -f 'lib_.c'; then $(CYGPATH_W) 'lib_.c'; else $(CYGPATH_W) '$(srcdir)/lib_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/lib_.Tpo $(DEPDIR)/lib_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lib_.c' object='lib_.obj' libtool=no @AMDEPBACKSLASH@
+event.obj: $(srcdir)/../lib/isc/event.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT event.obj -MD -MP -MF $(DEPDIR)/event.Tpo -c -o event.obj `if test -f '$(srcdir)/../lib/isc/event.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/event.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/event.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/event.Tpo $(DEPDIR)/event.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/event.c' object='event.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib_.obj `if test -f 'lib_.c'; then $(CYGPATH_W) 'lib_.c'; else $(CYGPATH_W) '$(srcdir)/lib_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o event.obj `if test -f '$(srcdir)/../lib/isc/event.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/event.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/event.c'; fi`
-lib.o: $(srcdir)/../libisc/lib.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib.o -MD -MP -MF $(DEPDIR)/lib.Tpo -c -o lib.o `test -f '$(srcdir)/../libisc/lib.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/lib.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/lib.Tpo $(DEPDIR)/lib.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/lib.c' object='lib.o' libtool=no @AMDEPBACKSLASH@
+file.o: $(srcdir)/../lib/isc/unix/file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT file.o -MD -MP -MF $(DEPDIR)/file.Tpo -c -o file.o `test -f '$(srcdir)/../lib/isc/unix/file.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/file.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file.Tpo $(DEPDIR)/file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/file.c' object='file.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib.o `test -f '$(srcdir)/../libisc/lib.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/lib.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o file.o `test -f '$(srcdir)/../lib/isc/unix/file.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/file.c
-lib.obj: $(srcdir)/../libisc/lib.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib.obj -MD -MP -MF $(DEPDIR)/lib.Tpo -c -o lib.obj `if test -f '$(srcdir)/../libisc/lib.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/lib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/lib.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/lib.Tpo $(DEPDIR)/lib.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/lib.c' object='lib.obj' libtool=no @AMDEPBACKSLASH@
+file.obj: $(srcdir)/../lib/isc/unix/file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT file.obj -MD -MP -MF $(DEPDIR)/file.Tpo -c -o file.obj `if test -f '$(srcdir)/../lib/isc/unix/file.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/file.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/file.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file.Tpo $(DEPDIR)/file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/file.c' object='file.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib.obj `if test -f '$(srcdir)/../libisc/lib.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/lib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/lib.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o file.obj `if test -f '$(srcdir)/../lib/isc/unix/file.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/file.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/file.c'; fi`
-mem_.o: mem_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem_.o -MD -MP -MF $(DEPDIR)/mem_.Tpo -c -o mem_.o `test -f 'mem_.c' || echo '$(srcdir)/'`mem_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/mem_.Tpo $(DEPDIR)/mem_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem_.c' object='mem_.o' libtool=no @AMDEPBACKSLASH@
+inet_ntop.o: $(srcdir)/../lib/isc/inet_ntop.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop.o -MD -MP -MF $(DEPDIR)/inet_ntop.Tpo -c -o inet_ntop.o `test -f '$(srcdir)/../lib/isc/inet_ntop.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/inet_ntop.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inet_ntop.Tpo $(DEPDIR)/inet_ntop.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/inet_ntop.c' object='inet_ntop.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem_.o `test -f 'mem_.c' || echo '$(srcdir)/'`mem_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop.o `test -f '$(srcdir)/../lib/isc/inet_ntop.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/inet_ntop.c
-mem_.obj: mem_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem_.obj -MD -MP -MF $(DEPDIR)/mem_.Tpo -c -o mem_.obj `if test -f 'mem_.c'; then $(CYGPATH_W) 'mem_.c'; else $(CYGPATH_W) '$(srcdir)/mem_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/mem_.Tpo $(DEPDIR)/mem_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem_.c' object='mem_.obj' libtool=no @AMDEPBACKSLASH@
+inet_ntop.obj: $(srcdir)/../lib/isc/inet_ntop.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop.obj -MD -MP -MF $(DEPDIR)/inet_ntop.Tpo -c -o inet_ntop.obj `if test -f '$(srcdir)/../lib/isc/inet_ntop.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/inet_ntop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/inet_ntop.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inet_ntop.Tpo $(DEPDIR)/inet_ntop.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/inet_ntop.c' object='inet_ntop.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem_.obj `if test -f 'mem_.c'; then $(CYGPATH_W) 'mem_.c'; else $(CYGPATH_W) '$(srcdir)/mem_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop.obj `if test -f '$(srcdir)/../lib/isc/inet_ntop.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/inet_ntop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/inet_ntop.c'; fi`
-mem.o: $(srcdir)/../libisc/mem.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem.o -MD -MP -MF $(DEPDIR)/mem.Tpo -c -o mem.o `test -f '$(srcdir)/../libisc/mem.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/mem.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/mem.Tpo $(DEPDIR)/mem.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/mem.c' object='mem.o' libtool=no @AMDEPBACKSLASH@
+inet_pton.o: $(srcdir)/../lib/isc/inet_pton.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton.o -MD -MP -MF $(DEPDIR)/inet_pton.Tpo -c -o inet_pton.o `test -f '$(srcdir)/../lib/isc/inet_pton.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/inet_pton.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inet_pton.Tpo $(DEPDIR)/inet_pton.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/inet_pton.c' object='inet_pton.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem.o `test -f '$(srcdir)/../libisc/mem.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/mem.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton.o `test -f '$(srcdir)/../lib/isc/inet_pton.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/inet_pton.c
-mem.obj: $(srcdir)/../libisc/mem.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem.obj -MD -MP -MF $(DEPDIR)/mem.Tpo -c -o mem.obj `if test -f '$(srcdir)/../libisc/mem.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/mem.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/mem.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/mem.Tpo $(DEPDIR)/mem.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/mem.c' object='mem.obj' libtool=no @AMDEPBACKSLASH@
+inet_pton.obj: $(srcdir)/../lib/isc/inet_pton.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton.obj -MD -MP -MF $(DEPDIR)/inet_pton.Tpo -c -o inet_pton.obj `if test -f '$(srcdir)/../lib/isc/inet_pton.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/inet_pton.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inet_pton.Tpo $(DEPDIR)/inet_pton.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/inet_pton.c' object='inet_pton.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem.obj `if test -f '$(srcdir)/../libisc/mem.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/mem.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/mem.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton.obj `if test -f '$(srcdir)/../lib/isc/inet_pton.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/inet_pton.c'; fi`
-msgcat_.o: msgcat_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat_.o -MD -MP -MF $(DEPDIR)/msgcat_.Tpo -c -o msgcat_.o `test -f 'msgcat_.c' || echo '$(srcdir)/'`msgcat_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/msgcat_.Tpo $(DEPDIR)/msgcat_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='msgcat_.c' object='msgcat_.o' libtool=no @AMDEPBACKSLASH@
+interfaceiter.o: $(srcdir)/../lib/isc/unix/interfaceiter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter.o -MD -MP -MF $(DEPDIR)/interfaceiter.Tpo -c -o interfaceiter.o `test -f '$(srcdir)/../lib/isc/unix/interfaceiter.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/interfaceiter.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/interfaceiter.Tpo $(DEPDIR)/interfaceiter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/interfaceiter.c' object='interfaceiter.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat_.o `test -f 'msgcat_.c' || echo '$(srcdir)/'`msgcat_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter.o `test -f '$(srcdir)/../lib/isc/unix/interfaceiter.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/interfaceiter.c
-msgcat_.obj: msgcat_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat_.obj -MD -MP -MF $(DEPDIR)/msgcat_.Tpo -c -o msgcat_.obj `if test -f 'msgcat_.c'; then $(CYGPATH_W) 'msgcat_.c'; else $(CYGPATH_W) '$(srcdir)/msgcat_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/msgcat_.Tpo $(DEPDIR)/msgcat_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='msgcat_.c' object='msgcat_.obj' libtool=no @AMDEPBACKSLASH@
+interfaceiter.obj: $(srcdir)/../lib/isc/unix/interfaceiter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interfaceiter.obj -MD -MP -MF $(DEPDIR)/interfaceiter.Tpo -c -o interfaceiter.obj `if test -f '$(srcdir)/../lib/isc/unix/interfaceiter.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/interfaceiter.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/interfaceiter.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/interfaceiter.Tpo $(DEPDIR)/interfaceiter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/interfaceiter.c' object='interfaceiter.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat_.obj `if test -f 'msgcat_.c'; then $(CYGPATH_W) 'msgcat_.c'; else $(CYGPATH_W) '$(srcdir)/msgcat_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interfaceiter.obj `if test -f '$(srcdir)/../lib/isc/unix/interfaceiter.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/interfaceiter.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/interfaceiter.c'; fi`
-msgcat.o: $(srcdir)/../libisc/msgcat.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat.o -MD -MP -MF $(DEPDIR)/msgcat.Tpo -c -o msgcat.o `test -f '$(srcdir)/../libisc/msgcat.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/msgcat.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/msgcat.Tpo $(DEPDIR)/msgcat.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/msgcat.c' object='msgcat.o' libtool=no @AMDEPBACKSLASH@
+lib.o: $(srcdir)/../lib/isc/lib.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib.o -MD -MP -MF $(DEPDIR)/lib.Tpo -c -o lib.o `test -f '$(srcdir)/../lib/isc/lib.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/lib.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lib.Tpo $(DEPDIR)/lib.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/lib.c' object='lib.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat.o `test -f '$(srcdir)/../libisc/msgcat.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/msgcat.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib.o `test -f '$(srcdir)/../lib/isc/lib.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/lib.c
-msgcat.obj: $(srcdir)/../libisc/msgcat.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat.obj -MD -MP -MF $(DEPDIR)/msgcat.Tpo -c -o msgcat.obj `if test -f '$(srcdir)/../libisc/msgcat.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/msgcat.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/msgcat.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/msgcat.Tpo $(DEPDIR)/msgcat.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/msgcat.c' object='msgcat.obj' libtool=no @AMDEPBACKSLASH@
+lib.obj: $(srcdir)/../lib/isc/lib.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib.obj -MD -MP -MF $(DEPDIR)/lib.Tpo -c -o lib.obj `if test -f '$(srcdir)/../lib/isc/lib.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/lib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/lib.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/lib.Tpo $(DEPDIR)/lib.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/lib.c' object='lib.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat.obj `if test -f '$(srcdir)/../libisc/msgcat.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/msgcat.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/msgcat.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib.obj `if test -f '$(srcdir)/../lib/isc/lib.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/lib.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/lib.c'; fi`
-net_.o: net_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_.o -MD -MP -MF $(DEPDIR)/net_.Tpo -c -o net_.o `test -f 'net_.c' || echo '$(srcdir)/'`net_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/net_.Tpo $(DEPDIR)/net_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='net_.c' object='net_.o' libtool=no @AMDEPBACKSLASH@
+log.o: $(srcdir)/../lib/isc/log.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT log.o -MD -MP -MF $(DEPDIR)/log.Tpo -c -o log.o `test -f '$(srcdir)/../lib/isc/log.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/log.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/log.Tpo $(DEPDIR)/log.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/log.c' object='log.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_.o `test -f 'net_.c' || echo '$(srcdir)/'`net_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o log.o `test -f '$(srcdir)/../lib/isc/log.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/log.c
-net_.obj: net_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net_.obj -MD -MP -MF $(DEPDIR)/net_.Tpo -c -o net_.obj `if test -f 'net_.c'; then $(CYGPATH_W) 'net_.c'; else $(CYGPATH_W) '$(srcdir)/net_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/net_.Tpo $(DEPDIR)/net_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='net_.c' object='net_.obj' libtool=no @AMDEPBACKSLASH@
+log.obj: $(srcdir)/../lib/isc/log.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT log.obj -MD -MP -MF $(DEPDIR)/log.Tpo -c -o log.obj `if test -f '$(srcdir)/../lib/isc/log.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/log.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/log.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/log.Tpo $(DEPDIR)/log.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/log.c' object='log.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net_.obj `if test -f 'net_.c'; then $(CYGPATH_W) 'net_.c'; else $(CYGPATH_W) '$(srcdir)/net_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o log.obj `if test -f '$(srcdir)/../lib/isc/log.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/log.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/log.c'; fi`
-net.o: $(srcdir)/../libisc/net.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net.o -MD -MP -MF $(DEPDIR)/net.Tpo -c -o net.o `test -f '$(srcdir)/../libisc/net.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/net.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/net.Tpo $(DEPDIR)/net.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/net.c' object='net.o' libtool=no @AMDEPBACKSLASH@
+md5.o: $(srcdir)/../lib/isc/md5.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT md5.o -MD -MP -MF $(DEPDIR)/md5.Tpo -c -o md5.o `test -f '$(srcdir)/../lib/isc/md5.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/md5.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/md5.Tpo $(DEPDIR)/md5.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/md5.c' object='md5.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net.o `test -f '$(srcdir)/../libisc/net.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/net.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o md5.o `test -f '$(srcdir)/../lib/isc/md5.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/md5.c
-net.obj: $(srcdir)/../libisc/net.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net.obj -MD -MP -MF $(DEPDIR)/net.Tpo -c -o net.obj `if test -f '$(srcdir)/../libisc/net.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/net.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/net.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/net.Tpo $(DEPDIR)/net.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/net.c' object='net.obj' libtool=no @AMDEPBACKSLASH@
+md5.obj: $(srcdir)/../lib/isc/md5.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT md5.obj -MD -MP -MF $(DEPDIR)/md5.Tpo -c -o md5.obj `if test -f '$(srcdir)/../lib/isc/md5.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/md5.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/md5.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/md5.Tpo $(DEPDIR)/md5.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/md5.c' object='md5.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net.obj `if test -f '$(srcdir)/../libisc/net.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/net.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/net.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o md5.obj `if test -f '$(srcdir)/../lib/isc/md5.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/md5.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/md5.c'; fi`
-isc_strerror_.o: isc_strerror_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror_.o -MD -MP -MF $(DEPDIR)/isc_strerror_.Tpo -c -o isc_strerror_.o `test -f 'isc_strerror_.c' || echo '$(srcdir)/'`isc_strerror_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/isc_strerror_.Tpo $(DEPDIR)/isc_strerror_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='isc_strerror_.c' object='isc_strerror_.o' libtool=no @AMDEPBACKSLASH@
+msgcat.o: $(srcdir)/../lib/isc/nls/msgcat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat.o -MD -MP -MF $(DEPDIR)/msgcat.Tpo -c -o msgcat.o `test -f '$(srcdir)/../lib/isc/nls/msgcat.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/nls/msgcat.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/msgcat.Tpo $(DEPDIR)/msgcat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/nls/msgcat.c' object='msgcat.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror_.o `test -f 'isc_strerror_.c' || echo '$(srcdir)/'`isc_strerror_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat.o `test -f '$(srcdir)/../lib/isc/nls/msgcat.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/nls/msgcat.c
-isc_strerror_.obj: isc_strerror_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror_.obj -MD -MP -MF $(DEPDIR)/isc_strerror_.Tpo -c -o isc_strerror_.obj `if test -f 'isc_strerror_.c'; then $(CYGPATH_W) 'isc_strerror_.c'; else $(CYGPATH_W) '$(srcdir)/isc_strerror_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/isc_strerror_.Tpo $(DEPDIR)/isc_strerror_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='isc_strerror_.c' object='isc_strerror_.obj' libtool=no @AMDEPBACKSLASH@
+msgcat.obj: $(srcdir)/../lib/isc/nls/msgcat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msgcat.obj -MD -MP -MF $(DEPDIR)/msgcat.Tpo -c -o msgcat.obj `if test -f '$(srcdir)/../lib/isc/nls/msgcat.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/nls/msgcat.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/nls/msgcat.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/msgcat.Tpo $(DEPDIR)/msgcat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/nls/msgcat.c' object='msgcat.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror_.obj `if test -f 'isc_strerror_.c'; then $(CYGPATH_W) 'isc_strerror_.c'; else $(CYGPATH_W) '$(srcdir)/isc_strerror_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msgcat.obj `if test -f '$(srcdir)/../lib/isc/nls/msgcat.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/nls/msgcat.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/nls/msgcat.c'; fi`
-isc_strerror.o: $(srcdir)/../libisc/isc_strerror.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror.o -MD -MP -MF $(DEPDIR)/isc_strerror.Tpo -c -o isc_strerror.o `test -f '$(srcdir)/../libisc/isc_strerror.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/isc_strerror.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/isc_strerror.Tpo $(DEPDIR)/isc_strerror.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/isc_strerror.c' object='isc_strerror.o' libtool=no @AMDEPBACKSLASH@
+net.o: $(srcdir)/../lib/isc/unix/net.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net.o -MD -MP -MF $(DEPDIR)/net.Tpo -c -o net.o `test -f '$(srcdir)/../lib/isc/unix/net.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/net.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/net.Tpo $(DEPDIR)/net.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/net.c' object='net.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror.o `test -f '$(srcdir)/../libisc/isc_strerror.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/isc_strerror.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net.o `test -f '$(srcdir)/../lib/isc/unix/net.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/net.c
-isc_strerror.obj: $(srcdir)/../libisc/isc_strerror.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT isc_strerror.obj -MD -MP -MF $(DEPDIR)/isc_strerror.Tpo -c -o isc_strerror.obj `if test -f '$(srcdir)/../libisc/isc_strerror.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/isc_strerror.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/isc_strerror.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/isc_strerror.Tpo $(DEPDIR)/isc_strerror.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/isc_strerror.c' object='isc_strerror.obj' libtool=no @AMDEPBACKSLASH@
+net.obj: $(srcdir)/../lib/isc/unix/net.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT net.obj -MD -MP -MF $(DEPDIR)/net.Tpo -c -o net.obj `if test -f '$(srcdir)/../lib/isc/unix/net.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/net.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/net.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/net.Tpo $(DEPDIR)/net.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/net.c' object='net.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o isc_strerror.obj `if test -f '$(srcdir)/../libisc/isc_strerror.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/isc_strerror.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/isc_strerror.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o net.obj `if test -f '$(srcdir)/../lib/isc/unix/net.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/net.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/net.c'; fi`
-inet_ntop_.o: inet_ntop_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop_.o -MD -MP -MF $(DEPDIR)/inet_ntop_.Tpo -c -o inet_ntop_.o `test -f 'inet_ntop_.c' || echo '$(srcdir)/'`inet_ntop_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_ntop_.Tpo $(DEPDIR)/inet_ntop_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_ntop_.c' object='inet_ntop_.o' libtool=no @AMDEPBACKSLASH@
+netaddr.o: $(srcdir)/../lib/isc/netaddr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr.o -MD -MP -MF $(DEPDIR)/netaddr.Tpo -c -o netaddr.o `test -f '$(srcdir)/../lib/isc/netaddr.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/netaddr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/netaddr.Tpo $(DEPDIR)/netaddr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/netaddr.c' object='netaddr.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop_.o `test -f 'inet_ntop_.c' || echo '$(srcdir)/'`inet_ntop_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr.o `test -f '$(srcdir)/../lib/isc/netaddr.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/netaddr.c
-inet_ntop_.obj: inet_ntop_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop_.obj -MD -MP -MF $(DEPDIR)/inet_ntop_.Tpo -c -o inet_ntop_.obj `if test -f 'inet_ntop_.c'; then $(CYGPATH_W) 'inet_ntop_.c'; else $(CYGPATH_W) '$(srcdir)/inet_ntop_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_ntop_.Tpo $(DEPDIR)/inet_ntop_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_ntop_.c' object='inet_ntop_.obj' libtool=no @AMDEPBACKSLASH@
+netaddr.obj: $(srcdir)/../lib/isc/netaddr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr.obj -MD -MP -MF $(DEPDIR)/netaddr.Tpo -c -o netaddr.obj `if test -f '$(srcdir)/../lib/isc/netaddr.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/netaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/netaddr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/netaddr.Tpo $(DEPDIR)/netaddr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/netaddr.c' object='netaddr.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop_.obj `if test -f 'inet_ntop_.c'; then $(CYGPATH_W) 'inet_ntop_.c'; else $(CYGPATH_W) '$(srcdir)/inet_ntop_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr.obj `if test -f '$(srcdir)/../lib/isc/netaddr.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/netaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/netaddr.c'; fi`
-inet_ntop.o: $(srcdir)/../libisc/inet_ntop.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop.o -MD -MP -MF $(DEPDIR)/inet_ntop.Tpo -c -o inet_ntop.o `test -f '$(srcdir)/../libisc/inet_ntop.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_ntop.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_ntop.Tpo $(DEPDIR)/inet_ntop.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_ntop.c' object='inet_ntop.o' libtool=no @AMDEPBACKSLASH@
+netscope.o: $(srcdir)/../lib/isc/netscope.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope.o -MD -MP -MF $(DEPDIR)/netscope.Tpo -c -o netscope.o `test -f '$(srcdir)/../lib/isc/netscope.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/netscope.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/netscope.Tpo $(DEPDIR)/netscope.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/netscope.c' object='netscope.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop.o `test -f '$(srcdir)/../libisc/inet_ntop.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_ntop.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope.o `test -f '$(srcdir)/../lib/isc/netscope.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/netscope.c
-inet_ntop.obj: $(srcdir)/../libisc/inet_ntop.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_ntop.obj -MD -MP -MF $(DEPDIR)/inet_ntop.Tpo -c -o inet_ntop.obj `if test -f '$(srcdir)/../libisc/inet_ntop.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_ntop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_ntop.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_ntop.Tpo $(DEPDIR)/inet_ntop.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_ntop.c' object='inet_ntop.obj' libtool=no @AMDEPBACKSLASH@
+netscope.obj: $(srcdir)/../lib/isc/netscope.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope.obj -MD -MP -MF $(DEPDIR)/netscope.Tpo -c -o netscope.obj `if test -f '$(srcdir)/../lib/isc/netscope.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/netscope.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/netscope.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/netscope.Tpo $(DEPDIR)/netscope.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/netscope.c' object='netscope.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_ntop.obj `if test -f '$(srcdir)/../libisc/inet_ntop.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_ntop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_ntop.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope.obj `if test -f '$(srcdir)/../lib/isc/netscope.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/netscope.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/netscope.c'; fi`
-inet_pton_.o: inet_pton_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton_.o -MD -MP -MF $(DEPDIR)/inet_pton_.Tpo -c -o inet_pton_.o `test -f 'inet_pton_.c' || echo '$(srcdir)/'`inet_pton_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_pton_.Tpo $(DEPDIR)/inet_pton_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_pton_.c' object='inet_pton_.o' libtool=no @AMDEPBACKSLASH@
+ondestroy.o: $(srcdir)/../lib/isc/ondestroy.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ondestroy.o -MD -MP -MF $(DEPDIR)/ondestroy.Tpo -c -o ondestroy.o `test -f '$(srcdir)/../lib/isc/ondestroy.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/ondestroy.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ondestroy.Tpo $(DEPDIR)/ondestroy.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/ondestroy.c' object='ondestroy.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton_.o `test -f 'inet_pton_.c' || echo '$(srcdir)/'`inet_pton_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ondestroy.o `test -f '$(srcdir)/../lib/isc/ondestroy.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/ondestroy.c
-inet_pton_.obj: inet_pton_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton_.obj -MD -MP -MF $(DEPDIR)/inet_pton_.Tpo -c -o inet_pton_.obj `if test -f 'inet_pton_.c'; then $(CYGPATH_W) 'inet_pton_.c'; else $(CYGPATH_W) '$(srcdir)/inet_pton_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_pton_.Tpo $(DEPDIR)/inet_pton_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='inet_pton_.c' object='inet_pton_.obj' libtool=no @AMDEPBACKSLASH@
+ondestroy.obj: $(srcdir)/../lib/isc/ondestroy.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ondestroy.obj -MD -MP -MF $(DEPDIR)/ondestroy.Tpo -c -o ondestroy.obj `if test -f '$(srcdir)/../lib/isc/ondestroy.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/ondestroy.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/ondestroy.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ondestroy.Tpo $(DEPDIR)/ondestroy.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/ondestroy.c' object='ondestroy.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton_.obj `if test -f 'inet_pton_.c'; then $(CYGPATH_W) 'inet_pton_.c'; else $(CYGPATH_W) '$(srcdir)/inet_pton_.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ondestroy.obj `if test -f '$(srcdir)/../lib/isc/ondestroy.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/ondestroy.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/ondestroy.c'; fi`
-inet_pton.o: $(srcdir)/../libisc/inet_pton.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton.o -MD -MP -MF $(DEPDIR)/inet_pton.Tpo -c -o inet_pton.o `test -f '$(srcdir)/../libisc/inet_pton.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_pton.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_pton.Tpo $(DEPDIR)/inet_pton.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_pton.c' object='inet_pton.o' libtool=no @AMDEPBACKSLASH@
+random.o: $(srcdir)/../lib/isc/random.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT random.o -MD -MP -MF $(DEPDIR)/random.Tpo -c -o random.o `test -f '$(srcdir)/../lib/isc/random.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/random.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/random.Tpo $(DEPDIR)/random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/random.c' object='random.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton.o `test -f '$(srcdir)/../libisc/inet_pton.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/inet_pton.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o random.o `test -f '$(srcdir)/../lib/isc/random.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/random.c
-inet_pton.obj: $(srcdir)/../libisc/inet_pton.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet_pton.obj -MD -MP -MF $(DEPDIR)/inet_pton.Tpo -c -o inet_pton.obj `if test -f '$(srcdir)/../libisc/inet_pton.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_pton.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet_pton.Tpo $(DEPDIR)/inet_pton.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/inet_pton.c' object='inet_pton.obj' libtool=no @AMDEPBACKSLASH@
+random.obj: $(srcdir)/../lib/isc/random.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT random.obj -MD -MP -MF $(DEPDIR)/random.Tpo -c -o random.obj `if test -f '$(srcdir)/../lib/isc/random.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/random.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/random.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/random.Tpo $(DEPDIR)/random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/random.c' object='random.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet_pton.obj `if test -f '$(srcdir)/../libisc/inet_pton.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/inet_pton.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/inet_pton.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o random.obj `if test -f '$(srcdir)/../lib/isc/random.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/random.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/random.c'; fi`
-netaddr_.o: netaddr_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr_.o -MD -MP -MF $(DEPDIR)/netaddr_.Tpo -c -o netaddr_.o `test -f 'netaddr_.c' || echo '$(srcdir)/'`netaddr_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netaddr_.Tpo $(DEPDIR)/netaddr_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netaddr_.c' object='netaddr_.o' libtool=no @AMDEPBACKSLASH@
+result.o: $(srcdir)/../lib/isc/result.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT result.o -MD -MP -MF $(DEPDIR)/result.Tpo -c -o result.o `test -f '$(srcdir)/../lib/isc/result.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/result.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/result.Tpo $(DEPDIR)/result.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/result.c' object='result.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr_.o `test -f 'netaddr_.c' || echo '$(srcdir)/'`netaddr_.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o result.o `test -f '$(srcdir)/../lib/isc/result.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/result.c
-netaddr_.obj: netaddr_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr_.obj -MD -MP -MF $(DEPDIR)/netaddr_.Tpo -c -o netaddr_.obj `if test -f 'netaddr_.c'; then $(CYGPATH_W) 'netaddr_.c'; else $(CYGPATH_W) '$(srcdir)/netaddr_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netaddr_.Tpo $(DEPDIR)/netaddr_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netaddr_.c' object='netaddr_.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr_.obj `if test -f 'netaddr_.c'; then $(CYGPATH_W) 'netaddr_.c'; else $(CYGPATH_W) '$(srcdir)/netaddr_.c'; fi`
-
-netaddr.o: $(srcdir)/../libisc/netaddr.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr.o -MD -MP -MF $(DEPDIR)/netaddr.Tpo -c -o netaddr.o `test -f '$(srcdir)/../libisc/netaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netaddr.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netaddr.Tpo $(DEPDIR)/netaddr.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netaddr.c' object='netaddr.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr.o `test -f '$(srcdir)/../libisc/netaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netaddr.c
-
-netaddr.obj: $(srcdir)/../libisc/netaddr.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netaddr.obj -MD -MP -MF $(DEPDIR)/netaddr.Tpo -c -o netaddr.obj `if test -f '$(srcdir)/../libisc/netaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netaddr.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netaddr.Tpo $(DEPDIR)/netaddr.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netaddr.c' object='netaddr.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netaddr.obj `if test -f '$(srcdir)/../libisc/netaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netaddr.c'; fi`
-
-sockaddr_.o: sockaddr_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr_.o -MD -MP -MF $(DEPDIR)/sockaddr_.Tpo -c -o sockaddr_.o `test -f 'sockaddr_.c' || echo '$(srcdir)/'`sockaddr_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sockaddr_.Tpo $(DEPDIR)/sockaddr_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sockaddr_.c' object='sockaddr_.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr_.o `test -f 'sockaddr_.c' || echo '$(srcdir)/'`sockaddr_.c
-
-sockaddr_.obj: sockaddr_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr_.obj -MD -MP -MF $(DEPDIR)/sockaddr_.Tpo -c -o sockaddr_.obj `if test -f 'sockaddr_.c'; then $(CYGPATH_W) 'sockaddr_.c'; else $(CYGPATH_W) '$(srcdir)/sockaddr_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sockaddr_.Tpo $(DEPDIR)/sockaddr_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sockaddr_.c' object='sockaddr_.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr_.obj `if test -f 'sockaddr_.c'; then $(CYGPATH_W) 'sockaddr_.c'; else $(CYGPATH_W) '$(srcdir)/sockaddr_.c'; fi`
-
-sockaddr.o: $(srcdir)/../libisc/sockaddr.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr.o -MD -MP -MF $(DEPDIR)/sockaddr.Tpo -c -o sockaddr.o `test -f '$(srcdir)/../libisc/sockaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/sockaddr.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sockaddr.Tpo $(DEPDIR)/sockaddr.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/sockaddr.c' object='sockaddr.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr.o `test -f '$(srcdir)/../libisc/sockaddr.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/sockaddr.c
-
-sockaddr.obj: $(srcdir)/../libisc/sockaddr.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr.obj -MD -MP -MF $(DEPDIR)/sockaddr.Tpo -c -o sockaddr.obj `if test -f '$(srcdir)/../libisc/sockaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/sockaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/sockaddr.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sockaddr.Tpo $(DEPDIR)/sockaddr.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/sockaddr.c' object='sockaddr.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr.obj `if test -f '$(srcdir)/../libisc/sockaddr.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/sockaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/sockaddr.c'; fi`
-
-netscope_.o: netscope_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope_.o -MD -MP -MF $(DEPDIR)/netscope_.Tpo -c -o netscope_.o `test -f 'netscope_.c' || echo '$(srcdir)/'`netscope_.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netscope_.Tpo $(DEPDIR)/netscope_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netscope_.c' object='netscope_.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope_.o `test -f 'netscope_.c' || echo '$(srcdir)/'`netscope_.c
-
-netscope_.obj: netscope_.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope_.obj -MD -MP -MF $(DEPDIR)/netscope_.Tpo -c -o netscope_.obj `if test -f 'netscope_.c'; then $(CYGPATH_W) 'netscope_.c'; else $(CYGPATH_W) '$(srcdir)/netscope_.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netscope_.Tpo $(DEPDIR)/netscope_.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='netscope_.c' object='netscope_.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope_.obj `if test -f 'netscope_.c'; then $(CYGPATH_W) 'netscope_.c'; else $(CYGPATH_W) '$(srcdir)/netscope_.c'; fi`
-
-netscope.o: $(srcdir)/../libisc/netscope.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope.o -MD -MP -MF $(DEPDIR)/netscope.Tpo -c -o netscope.o `test -f '$(srcdir)/../libisc/netscope.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netscope.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netscope.Tpo $(DEPDIR)/netscope.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netscope.c' object='netscope.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope.o `test -f '$(srcdir)/../libisc/netscope.c' || echo '$(srcdir)/'`$(srcdir)/../libisc/netscope.c
-
-netscope.obj: $(srcdir)/../libisc/netscope.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netscope.obj -MD -MP -MF $(DEPDIR)/netscope.Tpo -c -o netscope.obj `if test -f '$(srcdir)/../libisc/netscope.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netscope.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netscope.c'; fi`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netscope.Tpo $(DEPDIR)/netscope.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../libisc/netscope.c' object='netscope.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netscope.obj `if test -f '$(srcdir)/../libisc/netscope.c'; then $(CYGPATH_W) '$(srcdir)/../libisc/netscope.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../libisc/netscope.c'; fi`
-a_md5encrypt_.c: a_md5encrypt.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/a_md5encrypt.c; then echo $(srcdir)/a_md5encrypt.c; else echo a_md5encrypt.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-adjtime_.c: adjtime.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/adjtime.c; then echo $(srcdir)/adjtime.c; else echo adjtime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-adjtimex_.c: adjtimex.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/adjtimex.c; then echo $(srcdir)/adjtimex.c; else echo adjtimex.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-assertions_.c: $(srcdir)/../libisc/assertions.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/assertions.c; then echo $(srcdir)/$(srcdir)/../libisc/assertions.c; else echo $(srcdir)/../libisc/assertions.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-atoint_.c: atoint.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atoint.c; then echo $(srcdir)/atoint.c; else echo atoint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-atolfp_.c: atolfp.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atolfp.c; then echo $(srcdir)/atolfp.c; else echo atolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-atouint_.c: atouint.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atouint.c; then echo $(srcdir)/atouint.c; else echo atouint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-audio_.c: audio.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/audio.c; then echo $(srcdir)/audio.c; else echo audio.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-authkeys_.c: authkeys.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/authkeys.c; then echo $(srcdir)/authkeys.c; else echo authkeys.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-authreadkeys_.c: authreadkeys.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/authreadkeys.c; then echo $(srcdir)/authreadkeys.c; else echo authreadkeys.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-authusekey_.c: authusekey.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/authusekey.c; then echo $(srcdir)/authusekey.c; else echo authusekey.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-buftvtots_.c: buftvtots.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/buftvtots.c; then echo $(srcdir)/buftvtots.c; else echo buftvtots.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-caljulian_.c: caljulian.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/caljulian.c; then echo $(srcdir)/caljulian.c; else echo caljulian.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-caltontp_.c: caltontp.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/caltontp.c; then echo $(srcdir)/caltontp.c; else echo caltontp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-calyearstart_.c: calyearstart.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/calyearstart.c; then echo $(srcdir)/calyearstart.c; else echo calyearstart.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-clocktime_.c: clocktime.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clocktime.c; then echo $(srcdir)/clocktime.c; else echo clocktime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-clocktypes_.c: clocktypes.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clocktypes.c; then echo $(srcdir)/clocktypes.c; else echo clocktypes.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-decodenetnum_.c: decodenetnum.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/decodenetnum.c; then echo $(srcdir)/decodenetnum.c; else echo decodenetnum.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-dofptoa_.c: dofptoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dofptoa.c; then echo $(srcdir)/dofptoa.c; else echo dofptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-dolfptoa_.c: dolfptoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dolfptoa.c; then echo $(srcdir)/dolfptoa.c; else echo dolfptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-emalloc_.c: emalloc.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/emalloc.c; then echo $(srcdir)/emalloc.c; else echo emalloc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-error_.c: $(srcdir)/../libisc/error.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/error.c; then echo $(srcdir)/$(srcdir)/../libisc/error.c; else echo $(srcdir)/../libisc/error.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-findconfig_.c: findconfig.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/findconfig.c; then echo $(srcdir)/findconfig.c; else echo findconfig.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-fptoa_.c: fptoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fptoa.c; then echo $(srcdir)/fptoa.c; else echo fptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-fptoms_.c: fptoms.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fptoms.c; then echo $(srcdir)/fptoms.c; else echo fptoms.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-getopt_.c: getopt.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/getopt.c; then echo $(srcdir)/getopt.c; else echo getopt.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-hextoint_.c: hextoint.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/hextoint.c; then echo $(srcdir)/hextoint.c; else echo hextoint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-hextolfp_.c: hextolfp.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/hextolfp.c; then echo $(srcdir)/hextolfp.c; else echo hextolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-humandate_.c: humandate.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/humandate.c; then echo $(srcdir)/humandate.c; else echo humandate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-icom_.c: icom.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/icom.c; then echo $(srcdir)/icom.c; else echo icom.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-inet_ntop_.c: $(srcdir)/../libisc/inet_ntop.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/inet_ntop.c; then echo $(srcdir)/$(srcdir)/../libisc/inet_ntop.c; else echo $(srcdir)/../libisc/inet_ntop.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-inet_pton_.c: $(srcdir)/../libisc/inet_pton.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/inet_pton.c; then echo $(srcdir)/$(srcdir)/../libisc/inet_pton.c; else echo $(srcdir)/../libisc/inet_pton.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-interfaceiter_.c: $(srcdir)/../libisc/interfaceiter.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/interfaceiter.c; then echo $(srcdir)/$(srcdir)/../libisc/interfaceiter.c; else echo $(srcdir)/../libisc/interfaceiter.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-inttoa_.c: inttoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/inttoa.c; then echo $(srcdir)/inttoa.c; else echo inttoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-iosignal_.c: iosignal.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/iosignal.c; then echo $(srcdir)/iosignal.c; else echo iosignal.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-isc_strerror_.c: $(srcdir)/../libisc/isc_strerror.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/isc_strerror.c; then echo $(srcdir)/$(srcdir)/../libisc/isc_strerror.c; else echo $(srcdir)/../libisc/isc_strerror.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-lib_.c: $(srcdir)/../libisc/lib.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/lib.c; then echo $(srcdir)/$(srcdir)/../libisc/lib.c; else echo $(srcdir)/../libisc/lib.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-lib_strbuf_.c: lib_strbuf.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lib_strbuf.c; then echo $(srcdir)/lib_strbuf.c; else echo lib_strbuf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-machines_.c: machines.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/machines.c; then echo $(srcdir)/machines.c; else echo machines.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-md5c_.c: md5c.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/md5c.c; then echo $(srcdir)/md5c.c; else echo md5c.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-mem_.c: $(srcdir)/../libisc/mem.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/mem.c; then echo $(srcdir)/$(srcdir)/../libisc/mem.c; else echo $(srcdir)/../libisc/mem.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-memmove_.c: memmove.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memmove.c; then echo $(srcdir)/memmove.c; else echo memmove.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-mfptoa_.c: mfptoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mfptoa.c; then echo $(srcdir)/mfptoa.c; else echo mfptoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-mfptoms_.c: mfptoms.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mfptoms.c; then echo $(srcdir)/mfptoms.c; else echo mfptoms.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-mktime_.c: mktime.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mktime.c; then echo $(srcdir)/mktime.c; else echo mktime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-modetoa_.c: modetoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/modetoa.c; then echo $(srcdir)/modetoa.c; else echo modetoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-msgcat_.c: $(srcdir)/../libisc/msgcat.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/msgcat.c; then echo $(srcdir)/$(srcdir)/../libisc/msgcat.c; else echo $(srcdir)/../libisc/msgcat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-mstolfp_.c: mstolfp.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mstolfp.c; then echo $(srcdir)/mstolfp.c; else echo mstolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-msutotsf_.c: msutotsf.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/msutotsf.c; then echo $(srcdir)/msutotsf.c; else echo msutotsf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-msyslog_.c: msyslog.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/msyslog.c; then echo $(srcdir)/msyslog.c; else echo msyslog.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-net_.c: $(srcdir)/../libisc/net.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/net.c; then echo $(srcdir)/$(srcdir)/../libisc/net.c; else echo $(srcdir)/../libisc/net.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-netaddr_.c: $(srcdir)/../libisc/netaddr.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/netaddr.c; then echo $(srcdir)/$(srcdir)/../libisc/netaddr.c; else echo $(srcdir)/../libisc/netaddr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-netof_.c: netof.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/netof.c; then echo $(srcdir)/netof.c; else echo netof.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-netscope_.c: $(srcdir)/../libisc/netscope.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/netscope.c; then echo $(srcdir)/$(srcdir)/../libisc/netscope.c; else echo $(srcdir)/../libisc/netscope.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-ntp_random_.c: ntp_random.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_random.c; then echo $(srcdir)/ntp_random.c; else echo ntp_random.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-ntp_rfc2553_.c: ntp_rfc2553.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_rfc2553.c; then echo $(srcdir)/ntp_rfc2553.c; else echo ntp_rfc2553.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-numtoa_.c: numtoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/numtoa.c; then echo $(srcdir)/numtoa.c; else echo numtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-numtohost_.c: numtohost.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/numtohost.c; then echo $(srcdir)/numtohost.c; else echo numtohost.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-octtoint_.c: octtoint.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/octtoint.c; then echo $(srcdir)/octtoint.c; else echo octtoint.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-prettydate_.c: prettydate.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/prettydate.c; then echo $(srcdir)/prettydate.c; else echo prettydate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-recvbuff_.c: recvbuff.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/recvbuff.c; then echo $(srcdir)/recvbuff.c; else echo recvbuff.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-refnumtoa_.c: refnumtoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refnumtoa.c; then echo $(srcdir)/refnumtoa.c; else echo refnumtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-snprintf_.c: snprintf.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/snprintf.c; then echo $(srcdir)/snprintf.c; else echo snprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-sockaddr_.c: $(srcdir)/../libisc/sockaddr.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/$(srcdir)/../libisc/sockaddr.c; then echo $(srcdir)/$(srcdir)/../libisc/sockaddr.c; else echo $(srcdir)/../libisc/sockaddr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-socktoa_.c: socktoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/socktoa.c; then echo $(srcdir)/socktoa.c; else echo socktoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-socktohost_.c: socktohost.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/socktohost.c; then echo $(srcdir)/socktohost.c; else echo socktohost.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-statestr_.c: statestr.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/statestr.c; then echo $(srcdir)/statestr.c; else echo statestr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-strdup_.c: strdup.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strdup.c; then echo $(srcdir)/strdup.c; else echo strdup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-strerror_.c: strerror.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strerror.c; then echo $(srcdir)/strerror.c; else echo strerror.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-strstr_.c: strstr.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strstr.c; then echo $(srcdir)/strstr.c; else echo strstr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-syssignal_.c: syssignal.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/syssignal.c; then echo $(srcdir)/syssignal.c; else echo syssignal.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-systime_.c: systime.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/systime.c; then echo $(srcdir)/systime.c; else echo systime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-systime_s_.c: systime_s.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/systime_s.c; then echo $(srcdir)/systime_s.c; else echo systime_s.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-tsftomsu_.c: tsftomsu.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tsftomsu.c; then echo $(srcdir)/tsftomsu.c; else echo tsftomsu.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-tstotv_.c: tstotv.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tstotv.c; then echo $(srcdir)/tstotv.c; else echo tstotv.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-tvtoa_.c: tvtoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tvtoa.c; then echo $(srcdir)/tvtoa.c; else echo tvtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-tvtots_.c: tvtots.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tvtots.c; then echo $(srcdir)/tvtots.c; else echo tvtots.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-uglydate_.c: uglydate.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/uglydate.c; then echo $(srcdir)/uglydate.c; else echo uglydate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-uinttoa_.c: uinttoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/uinttoa.c; then echo $(srcdir)/uinttoa.c; else echo uinttoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-utvtoa_.c: utvtoa.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/utvtoa.c; then echo $(srcdir)/utvtoa.c; else echo utvtoa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-ymd2yd_.c: ymd2yd.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ymd2yd.c; then echo $(srcdir)/ymd2yd.c; else echo ymd2yd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
-a_md5encrypt_.$(OBJEXT) a_md5encrypt_.lo adjtime_.$(OBJEXT) \
-adjtime_.lo adjtimex_.$(OBJEXT) adjtimex_.lo assertions_.$(OBJEXT) \
-assertions_.lo atoint_.$(OBJEXT) atoint_.lo atolfp_.$(OBJEXT) \
-atolfp_.lo atouint_.$(OBJEXT) atouint_.lo audio_.$(OBJEXT) audio_.lo \
-authkeys_.$(OBJEXT) authkeys_.lo authreadkeys_.$(OBJEXT) \
-authreadkeys_.lo authusekey_.$(OBJEXT) authusekey_.lo \
-buftvtots_.$(OBJEXT) buftvtots_.lo caljulian_.$(OBJEXT) caljulian_.lo \
-caltontp_.$(OBJEXT) caltontp_.lo calyearstart_.$(OBJEXT) \
-calyearstart_.lo clocktime_.$(OBJEXT) clocktime_.lo \
-clocktypes_.$(OBJEXT) clocktypes_.lo decodenetnum_.$(OBJEXT) \
-decodenetnum_.lo dofptoa_.$(OBJEXT) dofptoa_.lo dolfptoa_.$(OBJEXT) \
-dolfptoa_.lo emalloc_.$(OBJEXT) emalloc_.lo error_.$(OBJEXT) error_.lo \
-findconfig_.$(OBJEXT) findconfig_.lo fptoa_.$(OBJEXT) fptoa_.lo \
-fptoms_.$(OBJEXT) fptoms_.lo getopt_.$(OBJEXT) getopt_.lo \
-hextoint_.$(OBJEXT) hextoint_.lo hextolfp_.$(OBJEXT) hextolfp_.lo \
-humandate_.$(OBJEXT) humandate_.lo icom_.$(OBJEXT) icom_.lo \
-inet_ntop_.$(OBJEXT) inet_ntop_.lo inet_pton_.$(OBJEXT) inet_pton_.lo \
-interfaceiter_.$(OBJEXT) interfaceiter_.lo inttoa_.$(OBJEXT) \
-inttoa_.lo iosignal_.$(OBJEXT) iosignal_.lo isc_strerror_.$(OBJEXT) \
-isc_strerror_.lo lib_.$(OBJEXT) lib_.lo lib_strbuf_.$(OBJEXT) \
-lib_strbuf_.lo machines_.$(OBJEXT) machines_.lo md5c_.$(OBJEXT) \
-md5c_.lo mem_.$(OBJEXT) mem_.lo memmove_.$(OBJEXT) memmove_.lo \
-mfptoa_.$(OBJEXT) mfptoa_.lo mfptoms_.$(OBJEXT) mfptoms_.lo \
-mktime_.$(OBJEXT) mktime_.lo modetoa_.$(OBJEXT) modetoa_.lo \
-msgcat_.$(OBJEXT) msgcat_.lo mstolfp_.$(OBJEXT) mstolfp_.lo \
-msutotsf_.$(OBJEXT) msutotsf_.lo msyslog_.$(OBJEXT) msyslog_.lo \
-net_.$(OBJEXT) net_.lo netaddr_.$(OBJEXT) netaddr_.lo netof_.$(OBJEXT) \
-netof_.lo netscope_.$(OBJEXT) netscope_.lo ntp_random_.$(OBJEXT) \
-ntp_random_.lo ntp_rfc2553_.$(OBJEXT) ntp_rfc2553_.lo \
-numtoa_.$(OBJEXT) numtoa_.lo numtohost_.$(OBJEXT) numtohost_.lo \
-octtoint_.$(OBJEXT) octtoint_.lo prettydate_.$(OBJEXT) prettydate_.lo \
-recvbuff_.$(OBJEXT) recvbuff_.lo refnumtoa_.$(OBJEXT) refnumtoa_.lo \
-snprintf_.$(OBJEXT) snprintf_.lo sockaddr_.$(OBJEXT) sockaddr_.lo \
-socktoa_.$(OBJEXT) socktoa_.lo socktohost_.$(OBJEXT) socktohost_.lo \
-statestr_.$(OBJEXT) statestr_.lo strdup_.$(OBJEXT) strdup_.lo \
-strerror_.$(OBJEXT) strerror_.lo strstr_.$(OBJEXT) strstr_.lo \
-syssignal_.$(OBJEXT) syssignal_.lo systime_.$(OBJEXT) systime_.lo \
-systime_s_.$(OBJEXT) systime_s_.lo tsftomsu_.$(OBJEXT) tsftomsu_.lo \
-tstotv_.$(OBJEXT) tstotv_.lo tvtoa_.$(OBJEXT) tvtoa_.lo \
-tvtots_.$(OBJEXT) tvtots_.lo uglydate_.$(OBJEXT) uglydate_.lo \
-uinttoa_.$(OBJEXT) uinttoa_.lo utvtoa_.$(OBJEXT) utvtoa_.lo \
-ymd2yd_.$(OBJEXT) ymd2yd_.lo : $(ANSI2KNR)
+result.obj: $(srcdir)/../lib/isc/result.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT result.obj -MD -MP -MF $(DEPDIR)/result.Tpo -c -o result.obj `if test -f '$(srcdir)/../lib/isc/result.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/result.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/result.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/result.Tpo $(DEPDIR)/result.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/result.c' object='result.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o result.obj `if test -f '$(srcdir)/../lib/isc/result.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/result.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/result.c'; fi`
+
+stdio.o: $(srcdir)/../lib/isc/unix/stdio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdio.o -MD -MP -MF $(DEPDIR)/stdio.Tpo -c -o stdio.o `test -f '$(srcdir)/../lib/isc/unix/stdio.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/stdio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stdio.Tpo $(DEPDIR)/stdio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/stdio.c' object='stdio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdio.o `test -f '$(srcdir)/../lib/isc/unix/stdio.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/stdio.c
+
+stdio.obj: $(srcdir)/../lib/isc/unix/stdio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdio.obj -MD -MP -MF $(DEPDIR)/stdio.Tpo -c -o stdio.obj `if test -f '$(srcdir)/../lib/isc/unix/stdio.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/stdio.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/stdio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stdio.Tpo $(DEPDIR)/stdio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/stdio.c' object='stdio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdio.obj `if test -f '$(srcdir)/../lib/isc/unix/stdio.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/stdio.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/stdio.c'; fi`
+
+stdtime.o: $(srcdir)/../lib/isc/unix/stdtime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdtime.o -MD -MP -MF $(DEPDIR)/stdtime.Tpo -c -o stdtime.o `test -f '$(srcdir)/../lib/isc/unix/stdtime.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/stdtime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stdtime.Tpo $(DEPDIR)/stdtime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/stdtime.c' object='stdtime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdtime.o `test -f '$(srcdir)/../lib/isc/unix/stdtime.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/stdtime.c
+
+stdtime.obj: $(srcdir)/../lib/isc/unix/stdtime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdtime.obj -MD -MP -MF $(DEPDIR)/stdtime.Tpo -c -o stdtime.obj `if test -f '$(srcdir)/../lib/isc/unix/stdtime.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/stdtime.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/stdtime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stdtime.Tpo $(DEPDIR)/stdtime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/stdtime.c' object='stdtime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdtime.obj `if test -f '$(srcdir)/../lib/isc/unix/stdtime.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/stdtime.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/stdtime.c'; fi`
+
+strerror.o: $(srcdir)/../lib/isc/unix/strerror.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strerror.o -MD -MP -MF $(DEPDIR)/strerror.Tpo -c -o strerror.o `test -f '$(srcdir)/../lib/isc/unix/strerror.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/strerror.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strerror.Tpo $(DEPDIR)/strerror.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/strerror.c' object='strerror.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strerror.o `test -f '$(srcdir)/../lib/isc/unix/strerror.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/strerror.c
+
+strerror.obj: $(srcdir)/../lib/isc/unix/strerror.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strerror.obj -MD -MP -MF $(DEPDIR)/strerror.Tpo -c -o strerror.obj `if test -f '$(srcdir)/../lib/isc/unix/strerror.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/strerror.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/strerror.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strerror.Tpo $(DEPDIR)/strerror.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/strerror.c' object='strerror.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strerror.obj `if test -f '$(srcdir)/../lib/isc/unix/strerror.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/strerror.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/strerror.c'; fi`
+
+task.o: $(srcdir)/../lib/isc/task.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT task.o -MD -MP -MF $(DEPDIR)/task.Tpo -c -o task.o `test -f '$(srcdir)/../lib/isc/task.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/task.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/task.Tpo $(DEPDIR)/task.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/task.c' object='task.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o task.o `test -f '$(srcdir)/../lib/isc/task.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/task.c
+
+task.obj: $(srcdir)/../lib/isc/task.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT task.obj -MD -MP -MF $(DEPDIR)/task.Tpo -c -o task.obj `if test -f '$(srcdir)/../lib/isc/task.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/task.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/task.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/task.Tpo $(DEPDIR)/task.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/task.c' object='task.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o task.obj `if test -f '$(srcdir)/../lib/isc/task.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/task.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/task.c'; fi`
+
+thread.o: $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT thread.o -MD -MP -MF $(DEPDIR)/thread.Tpo -c -o thread.o `test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/thread.Tpo $(DEPDIR)/thread.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c' object='thread.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o thread.o `test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c
+
+thread.obj: $(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT thread.obj -MD -MP -MF $(DEPDIR)/thread.Tpo -c -o thread.obj `if test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/thread.Tpo $(DEPDIR)/thread.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c' object='thread.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o thread.obj `if test -f '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/thread.c'; fi`
+
+time.o: $(srcdir)/../lib/isc/unix/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT time.o -MD -MP -MF $(DEPDIR)/time.Tpo -c -o time.o `test -f '$(srcdir)/../lib/isc/unix/time.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/time.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/time.Tpo $(DEPDIR)/time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/time.c' object='time.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o time.o `test -f '$(srcdir)/../lib/isc/unix/time.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/unix/time.c
+
+time.obj: $(srcdir)/../lib/isc/unix/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT time.obj -MD -MP -MF $(DEPDIR)/time.Tpo -c -o time.obj `if test -f '$(srcdir)/../lib/isc/unix/time.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/time.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/time.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/time.Tpo $(DEPDIR)/time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/unix/time.c' object='time.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o time.obj `if test -f '$(srcdir)/../lib/isc/unix/time.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/unix/time.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/unix/time.c'; fi`
+
+sha1.o: $(srcdir)/../lib/isc/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sha1.o -MD -MP -MF $(DEPDIR)/sha1.Tpo -c -o sha1.o `test -f '$(srcdir)/../lib/isc/sha1.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sha1.Tpo $(DEPDIR)/sha1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/sha1.c' object='sha1.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sha1.o `test -f '$(srcdir)/../lib/isc/sha1.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/sha1.c
+
+sha1.obj: $(srcdir)/../lib/isc/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sha1.obj -MD -MP -MF $(DEPDIR)/sha1.Tpo -c -o sha1.obj `if test -f '$(srcdir)/../lib/isc/sha1.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/sha1.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/sha1.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sha1.Tpo $(DEPDIR)/sha1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/sha1.c' object='sha1.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sha1.obj `if test -f '$(srcdir)/../lib/isc/sha1.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/sha1.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/sha1.c'; fi`
+
+sockaddr.o: $(srcdir)/../lib/isc/sockaddr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr.o -MD -MP -MF $(DEPDIR)/sockaddr.Tpo -c -o sockaddr.o `test -f '$(srcdir)/../lib/isc/sockaddr.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/sockaddr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sockaddr.Tpo $(DEPDIR)/sockaddr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/sockaddr.c' object='sockaddr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr.o `test -f '$(srcdir)/../lib/isc/sockaddr.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/sockaddr.c
+
+sockaddr.obj: $(srcdir)/../lib/isc/sockaddr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockaddr.obj -MD -MP -MF $(DEPDIR)/sockaddr.Tpo -c -o sockaddr.obj `if test -f '$(srcdir)/../lib/isc/sockaddr.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/sockaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/sockaddr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sockaddr.Tpo $(DEPDIR)/sockaddr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/sockaddr.c' object='sockaddr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockaddr.obj `if test -f '$(srcdir)/../lib/isc/sockaddr.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/sockaddr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/sockaddr.c'; fi`
+
+mutex.o: $(srcdir)/../lib/isc/pthreads/mutex.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mutex.o -MD -MP -MF $(DEPDIR)/mutex.Tpo -c -o mutex.o `test -f '$(srcdir)/../lib/isc/pthreads/mutex.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/pthreads/mutex.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mutex.Tpo $(DEPDIR)/mutex.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/pthreads/mutex.c' object='mutex.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mutex.o `test -f '$(srcdir)/../lib/isc/pthreads/mutex.c' || echo '$(srcdir)/'`$(srcdir)/../lib/isc/pthreads/mutex.c
+
+mutex.obj: $(srcdir)/../lib/isc/pthreads/mutex.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mutex.obj -MD -MP -MF $(DEPDIR)/mutex.Tpo -c -o mutex.obj `if test -f '$(srcdir)/../lib/isc/pthreads/mutex.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/pthreads/mutex.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/pthreads/mutex.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mutex.Tpo $(DEPDIR)/mutex.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/../lib/isc/pthreads/mutex.c' object='mutex.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mutex.obj `if test -f '$(srcdir)/../lib/isc/pthreads/mutex.c'; then $(CYGPATH_W) '$(srcdir)/../lib/isc/pthreads/mutex.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../lib/isc/pthreads/mutex.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
@@ -1015,26 +1341,15 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@@ -1046,15 +1361,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$unique; \
fi; \
fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@@ -1063,6 +1374,21 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -1098,10 +1424,12 @@ distdir: $(DISTFILES)
fi; \
done
check-am: all-am
-check: check-am
-all-am: Makefile $(LIBRARIES) $(HEADERS)
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LIBRARIES)
installdirs:
-install: install-am
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
@@ -1111,13 +1439,19 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
@@ -1126,6 +1460,7 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
@@ -1184,7 +1519,7 @@ maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
@@ -1197,25 +1532,81 @@ ps-am:
uninstall-am:
-.MAKE: ../util/ansi2knr install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstLIBRARIES ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-kr \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
-
-
-../include/des.h:
- touch ../include/des.h
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+$(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
+ @[ -f $@ ] || \
+ cp $(top_srcdir)/deps-ver $@
+ @[ -w $@ ] || \
+ chmod ug+w $@
+ @cmp $(top_srcdir)/deps-ver $@ > /dev/null || ( \
+ $(MAKE) $(AM_MAKEFLAGS) clean && \
+ echo -n "Prior $(subdir)/$(DEPDIR) version " && \
+ cat $@ && \
+ rm -rf $(DEPDIR) && \
+ mkdir $(DEPDIR) && \
+ case "$(top_builddir)" in \
+ .) \
+ ./config.status Makefile depfiles \
+ ;; \
+ *) \
+ cd "$(top_builddir)" && \
+ ./config.status $(subdir)/Makefile depfiles && \
+ cd $(subdir) \
+ ;; \
+ esac && \
+ echo -n "Cleaned $(subdir)/$(DEPDIR) version " && \
+ cat $(top_srcdir)/deps-ver \
+ )
+ cp $(top_srcdir)/deps-ver $@
+
+.deps-ver: $(top_srcdir)/deps-ver
+ @[ ! -d $(DEPDIR) ] || $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/deps-ver
+ @touch $@
+
+#
+# depsver.mf included in Makefile.am for directories with .deps
+#
+# When building in the same directory with sources that change over
+# time, such as when tracking using bk, the .deps files can become
+# stale with respect to moved, deleted, or superceded headers. Most
+# commonly, this would exhibit as make reporting a failure to make a
+# header file which is no longer in the location given. To address
+# this issue, we use a deps-ver file which is updated with each change
+# that breaks old .deps files. A copy of deps-ver is made into
+# $(DEPDIR) if not already present. If $(DEPDIR)/deps-ver is present
+# with different contents than deps-ver, we make clean to ensure all
+# .o files built before the incompatible change are rebuilt along with
+# their updated .deps files, then remove $(DEPDIR) and recreate it as
+# empty stubs.
+#
+# It is normal when configured with --disable-dependency-tracking for
+# the DEPDIR to not have been created. For this reason, we use the
+# intermediate target .deps-ver, which invokes make recursively if
+# DEPDIR exists.
+#
+# If you modify depsver.mf, please make the changes to the master
+# copy, the one in sntp is copied by the bootstrap script from it.
+#
+# This comment block follows rather than leads the related code so that
+# it stays with it in the generated Makefile.in and Makefile.
+#
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/contrib/ntp/libntp/a_md5encrypt.c b/contrib/ntp/libntp/a_md5encrypt.c
index e1ea37c..ffabc47 100644
--- a/contrib/ntp/libntp/a_md5encrypt.c
+++ b/contrib/ntp/libntp/a_md5encrypt.c
@@ -1,13 +1,6 @@
/*
- * MD5 interface for rsaref2.0
- *
- * These routines implement an interface for the RSA Laboratories
- * implementation of the Message Digest 5 (MD5) algorithm. This
- * algorithm is included in the rsaref2.0 package available from RSA in
- * the US and foreign countries. Further information is available at
- * www.rsa.com.
+ * digest support for NTP, MD5 and with OpenSSL more
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -15,90 +8,130 @@
#include "ntp_fp.h"
#include "ntp_string.h"
#include "ntp_stdlib.h"
-
-/* Disable the openssl md5 includes, because they'd clash with ours. */
-/* #define NO_MD5 */
-/* #define OPENSSL_NO_MD5 */
-#undef OPENSSL
-
#include "ntp.h"
-#include "global.h"
-#include "ntp_md5.h"
+#include "ntp_md5.h" /* provides OpenSSL digest API */
/*
- * MD5authencrypt - generate MD5 message authenticator
+ * MD5authencrypt - generate message digest
*
- * Returns length of authenticator field.
+ * Returns length of MAC including key ID and digest.
*/
int
MD5authencrypt(
- u_char *key, /* key pointer */
+ int type, /* hash algorithm */
+ u_char *key, /* key pointer */
u_int32 *pkt, /* packet pointer */
- int length /* packet length */
+ int length /* packet length */
)
{
- MD5_CTX md5;
- u_char digest[16];
+ u_char digest[EVP_MAX_MD_SIZE];
+ u_int len;
+ EVP_MD_CTX ctx;
/*
- * MD5 with key identifier concatenated with packet.
+ * Compute digest of key concatenated with packet. Note: the
+ * key type and digest type have been verified when the key
+ * was creaded.
*/
- MD5Init(&md5);
- MD5Update(&md5, key, (u_int)cache_keylen);
- MD5Update(&md5, (u_char *)pkt, (u_int)length);
- MD5Final(digest, &md5);
- memmove((u_char *)pkt + length + 4, digest, 16);
- return (16 + 4);
+ INIT_SSL();
+#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL
+ if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) {
+ msyslog(LOG_ERR,
+ "MAC encrypt: digest init failed");
+ return (0);
+ }
+#else
+ EVP_DigestInit(&ctx, EVP_get_digestbynid(type));
+#endif
+ EVP_DigestUpdate(&ctx, key, cache_secretsize);
+ EVP_DigestUpdate(&ctx, (u_char *)pkt, (u_int)length);
+ EVP_DigestFinal(&ctx, digest, &len);
+ memmove((u_char *)pkt + length + 4, digest, len);
+ return (len + 4);
}
/*
* MD5authdecrypt - verify MD5 message authenticator
*
- * Returns one if authenticator valid, zero if invalid.
+ * Returns one if digest valid, zero if invalid.
*/
int
MD5authdecrypt(
- u_char *key, /* key pointer */
- u_int32 *pkt, /* packet pointer */
- int length, /* packet length */
- int size /* MAC size */
+ int type, /* hash algorithm */
+ u_char *key, /* key pointer */
+ u_int32 *pkt, /* packet pointer */
+ int length, /* packet length */
+ int size /* MAC size */
)
{
- MD5_CTX md5;
- u_char digest[16];
+ u_char digest[EVP_MAX_MD_SIZE];
+ u_int len;
+ EVP_MD_CTX ctx;
/*
- * MD5 with key identifier concatenated with packet.
+ * Compute digest of key concatenated with packet. Note: the
+ * key type and digest type have been verified when the key
+ * was created.
*/
- MD5Init(&md5);
- MD5Update(&md5, key, (u_int)cache_keylen);
- MD5Update(&md5, (u_char *)pkt, (u_int)length);
- MD5Final(digest, &md5);
- if (size != 16 + 4)
+ INIT_SSL();
+#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL
+ if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) {
+ msyslog(LOG_ERR,
+ "MAC decrypt: digest init failed");
return (0);
- return (!memcmp(digest, (char *)pkt + length + 4, 16));
+ }
+#else
+ EVP_DigestInit(&ctx, EVP_get_digestbynid(type));
+#endif
+ EVP_DigestUpdate(&ctx, key, cache_secretsize);
+ EVP_DigestUpdate(&ctx, (u_char *)pkt, (u_int)length);
+ EVP_DigestFinal(&ctx, digest, &len);
+ if ((u_int)size != len + 4) {
+ msyslog(LOG_ERR,
+ "MAC decrypt: MAC length error");
+ return (0);
+ }
+ return !memcmp(digest, (char *)pkt + length + 4, len);
}
/*
* Calculate the reference id from the address. If it is an IPv4
* address, use it as is. If it is an IPv6 address, do a md5 on
* it and use the bottom 4 bytes.
+ * The result is in network byte order.
*/
u_int32
-addr2refid(struct sockaddr_storage *addr)
+addr2refid(sockaddr_u *addr)
{
- MD5_CTX md5;
- u_char digest[16];
- u_int32 addr_refid;
+ u_char digest[20];
+ u_int32 addr_refid;
+ EVP_MD_CTX ctx;
+ u_int len;
+
+ if (IS_IPV4(addr))
+ return (NSRCADR(addr));
- if (addr->ss_family == AF_INET)
- return (GET_INADDR(*addr));
+ INIT_SSL();
+
+#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL
+ EVP_MD_CTX_init(&ctx);
+#ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
+ /* MD5 is not used as a crypto hash here. */
+ EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+#endif
+ if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL)) {
+ msyslog(LOG_ERR,
+ "MD5 init failed");
+ exit(1);
+ }
+#else
+ EVP_DigestInit(&ctx, EVP_md5());
+#endif
- MD5Init(&md5);
- MD5Update(&md5, (u_char *)&GET_INADDR6(*addr),
+ EVP_DigestUpdate(&ctx, (u_char *)PSOCK_ADDR6(addr),
sizeof(struct in6_addr));
- MD5Final(digest, &md5);
- memcpy(&addr_refid, digest, 4);
+ EVP_DigestFinal(&ctx, digest, &len);
+ memcpy(&addr_refid, digest, sizeof(addr_refid));
return (addr_refid);
}
diff --git a/contrib/ntp/libntp/atoint.c b/contrib/ntp/libntp/atoint.c
index 46cd96d..9da8c13 100644
--- a/contrib/ntp/libntp/atoint.c
+++ b/contrib/ntp/libntp/atoint.c
@@ -1,6 +1,7 @@
/*
* atoint - convert an ascii string to a signed long, with error checking
*/
+#include <config.h>
#include <sys/types.h>
#include <ctype.h>
@@ -34,7 +35,7 @@ atoint(
u = 0;
while (*cp != '\0') {
- if (!isdigit((int)*cp))
+ if (!isdigit((unsigned char)*cp))
return 0;
if (u > 214748364 || (u == 214748364 && *cp > oflow_digit))
return 0; /* overflow */
diff --git a/contrib/ntp/libntp/atolfp.c b/contrib/ntp/libntp/atolfp.c
index ff50947..9a2f691 100644
--- a/contrib/ntp/libntp/atolfp.c
+++ b/contrib/ntp/libntp/atolfp.c
@@ -1,11 +1,13 @@
/*
* atolfp - convert an ascii string to an l_fp number
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
#include "ntp_fp.h"
#include "ntp_string.h"
+#include "ntp_assert.h"
/*
* Powers of 10
@@ -38,6 +40,8 @@ atolfp(
int isneg;
static const char *digits = "0123456789";
+ REQUIRE(str != NULL);
+
isneg = 0;
dec_i = dec_f = 0;
ndec = 0;
@@ -48,7 +52,7 @@ atolfp(
*
* [spaces][-|+][digits][.][digits][spaces|\n|\0]
*/
- while (isspace((int)*cp))
+ while (isspace((unsigned char)*cp))
cp++;
if (*cp == '-') {
@@ -59,7 +63,7 @@ atolfp(
if (*cp == '+')
cp++;
- if (*cp != '.' && !isdigit((int)*cp))
+ if (*cp != '.' && !isdigit((unsigned char)*cp))
return 0;
while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
@@ -68,7 +72,7 @@ atolfp(
cp++;
}
- if (*cp != '\0' && !isspace((int)*cp)) {
+ if (*cp != '\0' && !isspace((unsigned char)*cp)) {
if (*cp++ != '.')
return 0;
@@ -80,10 +84,10 @@ atolfp(
cp++;
}
- while (isdigit((int)*cp))
+ while (isdigit((unsigned char)*cp))
cp++;
- if (*cp != '\0' && !isspace((int)*cp))
+ if (*cp != '\0' && !isspace((unsigned char)*cp))
return 0;
}
diff --git a/contrib/ntp/libntp/atouint.c b/contrib/ntp/libntp/atouint.c
index c25e3a0..0a61639 100644
--- a/contrib/ntp/libntp/atouint.c
+++ b/contrib/ntp/libntp/atouint.c
@@ -1,33 +1,40 @@
-/*
- * atouint - convert an ascii string to an unsigned long, with error checking
- */
+#include <config.h>
#include <sys/types.h>
#include <ctype.h>
#include "ntp_types.h"
#include "ntp_stdlib.h"
+/*
+ * atouint() - convert an ascii string representing a whole base 10
+ * number to u_long *uval, returning TRUE if successful.
+ * Does not modify *uval and returns FALSE if str is not
+ * a positive base10 integer or is too large for a u_int32.
+ * this function uses u_long but should use u_int32, and
+ * probably be renamed.
+ */
int
atouint(
const char *str,
u_long *uval
)
{
- register u_long u;
- register const char *cp;
+ u_long u;
+ const char *cp;
cp = str;
- if (*cp == '\0')
- return 0;
+ if ('\0' == *cp)
+ return 0;
u = 0;
- while (*cp != '\0') {
- if (!isdigit((int)*cp))
- return 0;
+ while ('\0' != *cp) {
+ if (!isdigit((unsigned char)*cp))
+ return 0;
if (u > 429496729 || (u == 429496729 && *cp >= '6'))
- return 0; /* overflow */
+ return 0; /* overflow */
+ /* hand-optimized u *= 10; */
u = (u << 3) + (u << 1);
- u += *cp++ - '0'; /* ascii dependent */
+ u += *cp++ - '0'; /* not '\0' */
}
*uval = u;
diff --git a/contrib/ntp/libntp/audio.c b/contrib/ntp/libntp/audio.c
index 8d2f7c2..726dfa9 100644
--- a/contrib/ntp/libntp/audio.c
+++ b/contrib/ntp/libntp/audio.c
@@ -67,8 +67,8 @@ static struct audio_info info; /* audio device info */
static int ctl_fd; /* audio control file descriptor */
#ifdef PCM_STYLE_SOUND
-static void audio_config_read P((int, char **, char **));
-static int mixer_name P((const char *, int));
+static void audio_config_read (int, const char **, const char **);
+static int mixer_name (const char *, int);
int
@@ -114,22 +114,25 @@ mixer_name(
static void
audio_config_read(
int unit,
- char **c_dev, /* Control device */
- char **i_dev /* input device */
+ const char **c_dev, /* Control device */
+ const char **i_dev /* input device */
)
{
FILE *fd;
char device[20], line[100], ab[100];
- sprintf(device, "%s%d", INIT_FILE, unit);
+ snprintf(device, sizeof(device), "%s%d", INIT_FILE, unit);
if ((fd = fopen(device, "r")) == NULL) {
printf("audio_config_read: <%s> NO\n", device);
- sprintf(device, "%s.%d", INIT_FILE, unit);
+ snprintf(device, sizeof(device), "%s.%d", INIT_FILE,
+ unit);
if ((fd = fopen(device, "r")) == NULL) {
printf("audio_config_read: <%s> NO\n", device);
- sprintf(device, "%s.%d", INIT_FILE, unit);
+ snprintf(device, sizeof(device), "%s",
+ INIT_FILE);
if ((fd = fopen(device, "r")) == NULL) {
- printf("audio_config_read: <%s> NO\n", device);
+ printf("audio_config_read: <%s> NO\n",
+ device);
return;
}
}
@@ -145,12 +148,12 @@ audio_config_read(
/* Remove any trailing spaces */
for (i = strlen(line);
- i > 0 && isascii((int)line[i - 1]) && isspace((int)line[i - 1]);
+ i > 0 && isascii((unsigned char)line[i - 1]) && isspace((unsigned char)line[i - 1]);
)
line[--i] = '\0';
/* Remove leading space */
- for (cc = line; *cc && isascii((int)*cc) && isspace((int)*cc); cc++)
+ for (cc = line; *cc && isascii((unsigned char)*cc) && isspace((unsigned char)*cc); cc++)
continue;
/* Stop if nothing left */
@@ -159,33 +162,33 @@ audio_config_read(
/* Uppercase the command and find the arg */
for (ca = cc; *ca; ca++) {
- if (isascii((int)*ca)) {
- if (islower((int)*ca)) {
- *ca = toupper(*ca);
- } else if (isspace((int)*ca) || (*ca == '='))
+ if (isascii((unsigned char)*ca)) {
+ if (islower((unsigned char)*ca)) {
+ *ca = toupper((unsigned char)*ca);
+ } else if (isspace((unsigned char)*ca) || (*ca == '='))
break;
}
}
/* Remove space (and possible =) leading the arg */
- for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++)
+ for (; *ca && isascii((unsigned char)*ca) && (isspace((unsigned char)*ca) || (*ca == '=')); ca++)
continue;
- if (!strncmp(cc, "IDEV", (size_t) 4)) {
- sscanf(ca, "%s", ab);
- strcpy(cf_i_dev, ab);
+ if (!strncmp(cc, "IDEV", 4) &&
+ 1 == sscanf(ca, "%99s", ab)) {
+ strlcpy(cf_i_dev, ab, sizeof(cf_i_dev));
printf("idev <%s>\n", ab);
- } else if (!strncmp(cc, "CDEV", (size_t) 4)) {
- sscanf(ca, "%s", ab);
- strcpy(cf_c_dev, ab);
+ } else if (!strncmp(cc, "CDEV", 4) &&
+ 1 == sscanf(ca, "%99s", ab)) {
+ strlcpy(cf_c_dev, ab, sizeof(cf_c_dev));
printf("cdev <%s>\n", ab);
- } else if (!strncmp(cc, "AGC", (size_t) 3)) {
- sscanf(ca, "%s", ab);
- strcpy(cf_agc, ab);
+ } else if (!strncmp(cc, "AGC", 3) &&
+ 1 == sscanf(ca, "%99s", ab)) {
+ strlcpy(cf_agc, ab, sizeof(cf_agc));
printf("agc <%s> %d\n", ab, i);
- } else if (!strncmp(cc, "MONITOR", (size_t) 7)) {
- sscanf(ca, "%s", ab);
- strcpy(cf_monitor, ab);
+ } else if (!strncmp(cc, "MONITOR", 7) &&
+ 1 == sscanf(ca, "%99s", ab)) {
+ strlcpy(cf_monitor, ab, sizeof(cf_monitor));
printf("monitor <%s> %d\n", ab, mixer_name(ab, -1));
}
}
@@ -207,7 +210,7 @@ audio_config_read(
*/
int
audio_init(
- char *dname, /* device name */
+ const char *dname, /* device name */
int bufsiz, /* buffer size */
int unit /* device unit (0-3) */
)
@@ -224,7 +227,7 @@ audio_init(
#endif
int fd;
int rval;
- char *actl =
+ const char *actl =
#ifdef PCM_STYLE_SOUND
actl_dev
#else
@@ -233,7 +236,7 @@ audio_init(
;
#ifdef PCM_STYLE_SOUND
- (void)sprintf(actl_dev, ACTL_DEV, unit);
+ snprintf(actl_dev, sizeof(actl_dev), ACTL_DEV, unit);
audio_config_read(unit, &actl, &dname);
/* If we have values for cf_c_dev or cf_i_dev, use them. */
@@ -244,18 +247,21 @@ audio_init(
#endif
/*
- * Open audio device. Do not complain if not there.
+ * Open audio device
*/
fd = open(dname, O_RDWR | O_NONBLOCK, 0777);
- if (fd < 0)
+ if (fd < 0) {
+ msyslog(LOG_ERR, "audio_init: %s %m", dname);
return (fd);
+ }
/*
* Open audio control device.
*/
ctl_fd = open(actl, O_RDWR);
if (ctl_fd < 0) {
- msyslog(LOG_ERR, "audio_init: invalid control device <%s>\n", actl);
+ msyslog(LOG_ERR, "audio_init: invalid control device <%s>",
+ actl);
close(fd);
return(ctl_fd);
}
@@ -310,10 +316,11 @@ audio_init(
printf("SOUND_MIXER_READ_RECMASK: %s\n", strerror(errno));
/* validate and set any specified config file stuff */
- if (*cf_agc) {
+ if (cf_agc[0] != '\0') {
int i;
- i = mixer_name(cf_agc, devmask);
+ /* recmask */
+ i = mixer_name(cf_agc, recmask);
if (i >= 0)
agc = MIXER_WRITE(i);
else
@@ -321,7 +328,7 @@ audio_init(
cf_agc, recmask);
}
- if (*cf_monitor) {
+ if (cf_monitor[0] != '\0') {
int i;
/* devmask */
@@ -342,7 +349,7 @@ audio_init(
# endif /* HAVE_SYS_AUDIOIO_H */
rval = ioctl(ctl_fd, (int)AUDIO_SETINFO, (char *)&info);
if (rval < 0) {
- msyslog(LOG_ERR, "audio: invalid control device parameters\n");
+ msyslog(LOG_ERR, "audio: invalid control device parameters");
close(ctl_fd);
close(fd);
return(rval);
@@ -370,28 +377,31 @@ audio_gain(
#ifdef PCM_STYLE_SOUND
int l, r;
- rval = 0;
+# ifdef GCC
+ rval = 0; /* GCC thinks rval is used uninitialized */
+# endif
r = l = 100 * gain / 255; /* Normalize to 0-100 */
# ifdef DEBUG
if (debug > 1)
printf("audio_gain: gain %d/%d\n", gain, l);
# endif
+#if 0 /* not a good idea to do this; connector wiring dependency */
/* figure out what channel(s) to use. just nuke right for now. */
r = 0 ; /* setting to zero nicely mutes the channel */
-
+#endif
l |= r << 8;
- if ( cf_agc )
- rval = ioctl(ctl_fd, agc, &l);
- else
- if (port == 2) {
- rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_LINE, &l);
- } else {
- rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_MIC, &l);
- }
- if (rval == -1) {
+ if (cf_agc[0] != '\0')
+ rval = ioctl(ctl_fd, agc, &l);
+ else
+ rval = ioctl(ctl_fd
+ , (2 == port)
+ ? SOUND_MIXER_WRITE_LINE
+ : SOUND_MIXER_WRITE_MIC
+ , &l);
+ if (-1 == rval) {
printf("audio_gain: agc write: %s\n", strerror(errno));
- return (rval);
+ return rval;
}
if (o_mongain != mongain) {
@@ -401,11 +411,12 @@ audio_gain(
printf("audio_gain: mongain %d/%d\n", mongain, l);
# endif
l |= r << 8;
- if ( cf_monitor )
- rval = ioctl(ctl_fd, monitor, &l );
- else
- rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_VOLUME, &l);
- if (rval == -1) {
+ if (cf_monitor[0] != '\0')
+ rval = ioctl(ctl_fd, monitor, &l );
+ else
+ rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_VOLUME,
+ &l);
+ if (-1 == rval) {
printf("audio_gain: mongain write: %s\n",
strerror(errno));
return (rval);
diff --git a/contrib/ntp/libntp/authkeys.c b/contrib/ntp/libntp/authkeys.c
index 1c95444..667ca29 100644
--- a/contrib/ntp/libntp/authkeys.c
+++ b/contrib/ntp/libntp/authkeys.c
@@ -1,17 +1,17 @@
/*
* authkeys.c - routines to manage the storage of authentication keys
*/
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#include <math.h>
#include <stdio.h>
-#include "ntp_types.h"
-#include "ntp_fp.h"
#include "ntp.h"
+#include "ntp_fp.h"
#include "ntpd.h"
+#include "ntp_lists.h"
#include "ntp_string.h"
#include "ntp_malloc.h"
#include "ntp_stdlib.h"
@@ -19,30 +19,57 @@
/*
* Structure to store keys in in the hash table.
*/
+typedef struct savekey symkey;
+
struct savekey {
- struct savekey *next;
- union {
- long bogon; /* Make sure nonempty */
- u_char MD5_key[32]; /* MD5 key */
- } k;
- keyid_t keyid; /* key identifier */
- u_short flags; /* flags that wave */
- u_long lifetime; /* remaining lifetime */
- int keylen; /* key length */
+ symkey * hlink; /* next in hash bucket */
+ DECL_DLIST_LINK(symkey, llink); /* for overall & free lists */
+ u_char * secret; /* shared secret */
+ u_long lifetime; /* remaining lifetime */
+ keyid_t keyid; /* key identifier */
+ u_short type; /* OpenSSL digest NID */
+ u_short secretsize; /* secret octets */
+ u_short flags; /* KEY_ flags that wave */
};
+/* define the payload region of symkey beyond the list pointers */
+#define symkey_payload secret
+
#define KEY_TRUSTED 0x001 /* this key is trusted */
-#define KEY_MD5 0x200 /* this is a MD5 type key */
+#ifdef DEBUG
+typedef struct symkey_alloc_tag symkey_alloc;
+
+struct symkey_alloc_tag {
+ symkey_alloc * link;
+ void * mem; /* enable free() atexit */
+};
+
+symkey_alloc * authallocs;
+#endif /* DEBUG */
+
+static inline u_short auth_log2(double x);
+static void auth_resize_hashtable(void);
+static void allocsymkey(symkey **, keyid_t, u_short,
+ u_short, u_long, u_short, u_char *);
+static void freesymkey(symkey *, symkey **);
+#ifdef DEBUG
+static void free_auth_mem(void);
+#endif
+
+symkey key_listhead; /* list of all in-use keys */;
/*
* The hash table. This is indexed by the low order bits of the
* keyid. We make this fairly big for potentially busy servers.
*/
-#define HASHSIZE 64
-#define HASHMASK ((HASHSIZE)-1)
-#define KEYHASH(keyid) ((keyid) & HASHMASK)
+#define DEF_AUTHHASHSIZE 64
+//#define HASHMASK ((HASHSIZE)-1)
+#define KEYHASH(keyid) ((keyid) & authhashmask)
-struct savekey *key_hash[HASHSIZE];
+int authhashdisabled;
+u_short authhashbuckets = DEF_AUTHHASHSIZE;
+u_short authhashmask = DEF_AUTHHASHSIZE - 1;
+symkey **key_hash;
u_long authkeynotfound; /* keys not found */
u_long authkeylookups; /* calls to lookup keys */
@@ -54,20 +81,21 @@ u_long authencryptions; /* calls to encrypt */
u_long authdecryptions; /* calls to decrypt */
/*
- * Storage for free key structures. We malloc() such things but
+ * Storage for free symkey structures. We malloc() such things but
* never free them.
*/
-struct savekey *authfreekeys;
+symkey *authfreekeys;
int authnumfreekeys;
-#define MEMINC 12 /* number of new free ones to get */
+#define MEMINC 16 /* number of new free ones to get */
/*
* The key cache. We cache the last key we looked at here.
*/
keyid_t cache_keyid; /* key identifier */
-u_char *cache_key; /* key pointer */
-u_int cache_keylen; /* key length */
+u_char *cache_secret; /* secret */
+u_short cache_secretsize; /* secret length */
+int cache_type; /* OpenSSL digest NID */
u_short cache_flags; /* flags that wave */
@@ -77,10 +105,213 @@ u_short cache_flags; /* flags that wave */
void
init_auth(void)
{
+ size_t newalloc;
+
/*
* Initialize hash table and free list
*/
- memset((char *)key_hash, 0, sizeof key_hash);
+ newalloc = authhashbuckets * sizeof(key_hash[0]);
+
+ key_hash = erealloc(key_hash, newalloc);
+ memset(key_hash, '\0', newalloc);
+
+ INIT_DLIST(key_listhead, llink);
+
+#ifdef DEBUG
+ atexit(&free_auth_mem);
+#endif
+}
+
+
+/*
+ * free_auth_mem - assist in leak detection by freeing all dynamic
+ * allocations from this module.
+ */
+#ifdef DEBUG
+static void
+free_auth_mem(void)
+{
+ symkey * sk;
+ symkey_alloc * alloc;
+ symkey_alloc * next_alloc;
+
+ while (NULL != (sk = HEAD_DLIST(key_listhead, llink))) {
+ freesymkey(sk, &key_hash[KEYHASH(sk->keyid)]);
+ }
+ free(key_hash);
+ key_hash = NULL;
+ cache_keyid = 0;
+ cache_flags = 0;
+ for (alloc = authallocs; alloc != NULL; alloc = next_alloc) {
+ next_alloc = alloc->link;
+ free(alloc->mem);
+ }
+ authfreekeys = NULL;
+ authnumfreekeys = 0;
+}
+#endif /* DEBUG */
+
+
+/*
+ * auth_moremem - get some more free key structures
+ */
+void
+auth_moremem(
+ int keycount
+ )
+{
+ symkey * sk;
+ int i;
+#ifdef DEBUG
+ void * base;
+ symkey_alloc * allocrec;
+# define MOREMEM_EXTRA_ALLOC (sizeof(*allocrec))
+#else
+# define MOREMEM_EXTRA_ALLOC (0)
+#endif
+
+ i = (keycount > 0)
+ ? keycount
+ : MEMINC;
+ sk = emalloc_zero(i * sizeof(*sk) + MOREMEM_EXTRA_ALLOC);
+#ifdef DEBUG
+ base = sk;
+#endif
+ authnumfreekeys += i;
+
+ for (; i > 0; i--, sk++) {
+ LINK_SLIST(authfreekeys, sk, llink.f);
+ }
+
+#ifdef DEBUG
+ allocrec = (void *)sk;
+ allocrec->mem = base;
+ LINK_SLIST(authallocs, allocrec, link);
+#endif
+}
+
+
+/*
+ * auth_prealloc_symkeys
+ */
+void
+auth_prealloc_symkeys(
+ int keycount
+ )
+{
+ int allocated;
+ int additional;
+
+ allocated = authnumkeys + authnumfreekeys;
+ additional = keycount - allocated;
+ if (additional > 0)
+ auth_moremem(additional);
+ auth_resize_hashtable();
+}
+
+
+static inline u_short
+auth_log2(double x)
+{
+ return (u_short)(log10(x) / log10(2));
+}
+
+
+/*
+ * auth_resize_hashtable
+ *
+ * Size hash table to average 4 or fewer entries per bucket initially,
+ * within the bounds of at least 4 and no more than 15 bits for the hash
+ * table index. Populate the hash table.
+ */
+static void
+auth_resize_hashtable(void)
+{
+ u_long totalkeys;
+ u_short hashbits;
+ u_short hash;
+ size_t newalloc;
+ symkey * sk;
+
+ totalkeys = authnumkeys + authnumfreekeys;
+ hashbits = auth_log2(totalkeys / 4.0) + 1;
+ hashbits = max(4, hashbits);
+ hashbits = min(15, hashbits);
+
+ authhashbuckets = 1 << hashbits;
+ authhashmask = authhashbuckets - 1;
+ newalloc = authhashbuckets * sizeof(key_hash[0]);
+
+ key_hash = erealloc(key_hash, newalloc);
+ memset(key_hash, '\0', newalloc);
+
+ ITER_DLIST_BEGIN(key_listhead, sk, llink, symkey)
+ hash = KEYHASH(sk->keyid);
+ LINK_SLIST(key_hash[hash], sk, hlink);
+ ITER_DLIST_END()
+}
+
+
+/*
+ * allocsymkey - common code to allocate and link in symkey
+ *
+ * secret must be allocated with a free-compatible allocator. It is
+ * owned by the referring symkey structure, and will be free()d by
+ * freesymkey().
+ */
+static void
+allocsymkey(
+ symkey ** bucket,
+ keyid_t id,
+ u_short flags,
+ u_short type,
+ u_long lifetime,
+ u_short secretsize,
+ u_char * secret
+ )
+{
+ symkey * sk;
+
+ if (authnumfreekeys < 1)
+ auth_moremem(-1);
+ UNLINK_HEAD_SLIST(sk, authfreekeys, llink.f);
+ DEBUG_ENSURE(sk != NULL);
+ sk->keyid = id;
+ sk->flags = flags;
+ sk->type = type;
+ sk->secretsize = secretsize;
+ sk->secret = secret;
+ sk->lifetime = lifetime;
+ LINK_SLIST(*bucket, sk, hlink);
+ LINK_TAIL_DLIST(key_listhead, sk, llink);
+ authnumfreekeys--;
+ authnumkeys++;
+}
+
+
+/*
+ * freesymkey - common code to remove a symkey and recycle its entry.
+ */
+static void
+freesymkey(
+ symkey * sk,
+ symkey ** bucket
+ )
+{
+ symkey * unlinked;
+
+ if (sk->secret != NULL) {
+ memset(sk->secret, '\0', sk->secretsize);
+ free(sk->secret);
+ }
+ UNLINK_SLIST(unlinked, *bucket, sk, hlink, symkey);
+ DEBUG_ENSURE(sk == unlinked);
+ UNLINK_DLIST(sk, llink);
+ memset((char *)sk + offsetof(symkey, symkey_payload), '\0',
+ sizeof(*sk) - offsetof(symkey, symkey_payload));
+ LINK_SLIST(authfreekeys, sk, llink.f);
+ authnumkeys--;
+ authnumfreekeys++;
}
@@ -89,104 +320,100 @@ init_auth(void)
*/
struct savekey *
auth_findkey(
- keyid_t keyno
+ keyid_t id
)
{
- struct savekey *sk;
+ symkey * sk;
- sk = key_hash[KEYHASH(keyno)];
- while (sk != 0) {
- if (keyno == sk->keyid)
- return (sk);
-
- sk = sk->next;
+ for (sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
+ if (id == sk->keyid) {
+ return sk;
+ }
}
- return (0);
+
+ return NULL;
}
/*
- * auth_havekey - return one if the key is known
+ * auth_havekey - return TRUE if the key id is zero or known
*/
int
auth_havekey(
- keyid_t keyno
+ keyid_t id
)
{
- struct savekey *sk;
-
- if (keyno == 0 || (keyno == cache_keyid))
- return (1);
+ symkey * sk;
- sk = key_hash[KEYHASH(keyno)];
- while (sk != 0) {
- if (keyno == sk->keyid)
- return (1);
+ if (0 == id || cache_keyid == id) {
+ return TRUE;
+ }
- sk = sk->next;
+ for (sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
+ if (id == sk->keyid) {
+ return TRUE;
+ }
}
- return (0);
+
+ return FALSE;
}
/*
- * authhavekey - return one and cache the key, if known and trusted.
+ * authhavekey - return TRUE and cache the key, if zero or both known
+ * and trusted.
*/
int
authhavekey(
- keyid_t keyno
+ keyid_t id
)
{
- struct savekey *sk;
+ symkey * sk;
authkeylookups++;
- if (keyno == 0 || keyno == cache_keyid)
- return (1);
+ if (0 == id || cache_keyid == id) {
+ return TRUE;
+ }
+ /*
+ * Seach the bin for the key. If found and the key type
+ * is zero, somebody marked it trusted without specifying
+ * a key or key type. In this case consider the key missing.
+ */
authkeyuncached++;
- sk = key_hash[KEYHASH(keyno)];
- while (sk != 0) {
- if (keyno == sk->keyid)
- break;
- sk = sk->next;
+ for (sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
+ if (id == sk->keyid) {
+ if (0 == sk->type) {
+ authkeynotfound++;
+ return FALSE;
+ }
+ break;
+ }
}
- if (sk == 0) {
+
+ /*
+ * If the key is not found, or if it is found but not trusted,
+ * the key is not considered found.
+ */
+ if (NULL == sk) {
authkeynotfound++;
- return (0);
- } else if (!(sk->flags & KEY_TRUSTED)) {
+ return FALSE;
+ }
+ if (!(KEY_TRUSTED & sk->flags)) {
authnokey++;
- return (0);
+ return FALSE;
}
+
+ /*
+ * The key is found and trusted. Initialize the key cache.
+ */
cache_keyid = sk->keyid;
+ cache_type = sk->type;
cache_flags = sk->flags;
- if (sk->flags & KEY_MD5) {
- cache_key = sk->k.MD5_key;
- cache_keylen = sk->keylen;
- return (1);
- }
- return (0);
-}
+ cache_secret = sk->secret;
+ cache_secretsize = sk->secretsize;
-
-/*
- * auth_moremem - get some more free key structures
- */
-int
-auth_moremem(void)
-{
- struct savekey *sk;
- int i;
-
- sk = (struct savekey *)calloc(MEMINC, sizeof(struct savekey));
- if (sk == 0)
- return (0);
-
- for (i = MEMINC; i > 0; i--) {
- sk->next = authfreekeys;
- authfreekeys = sk++;
- }
- authnumfreekeys += MEMINC;
- return (authnumfreekeys);
+ return TRUE;
}
@@ -195,32 +422,41 @@ auth_moremem(void)
*/
void
authtrust(
- keyid_t keyno,
- u_long trust
+ keyid_t id,
+ u_long trust
)
{
- struct savekey *sk;
+ symkey ** bucket;
+ symkey * sk;
+ u_long lifetime;
-#ifdef DEBUG
- if (debug > 2)
- printf("authtrust: keyid %08x life %lu\n", keyno, trust);
-#endif
- sk = key_hash[KEYHASH(keyno)];
- while (sk != 0) {
- if (keyno == sk->keyid)
- break;
- sk = sk->next;
+ /*
+ * Search bin for key; if it does not exist and is untrusted,
+ * forget it.
+ */
+ bucket = &key_hash[KEYHASH(id)];
+ for (sk = *bucket; sk != NULL; sk = sk->hlink) {
+ if (id == sk->keyid)
+ break;
}
-
- if (sk == 0 && !trust)
+ if (!trust && NULL == sk)
return;
-
- if (sk != 0) {
- if (cache_keyid == keyno) {
+
+ /*
+ * There are two conditions remaining. Either it does not
+ * exist and is to be trusted or it does exist and is or is
+ * not to be trusted.
+ */
+ if (sk != NULL) {
+ if (cache_keyid == id) {
cache_flags = 0;
cache_keyid = 0;
}
+ /*
+ * Key exists. If it is to be trusted, say so and
+ * update its lifetime.
+ */
if (trust > 0) {
sk->flags |= KEY_TRUSTED;
if (trust > 1)
@@ -230,40 +466,21 @@ authtrust(
return;
}
- sk->flags &= ~KEY_TRUSTED; {
- struct savekey *skp;
-
- skp = key_hash[KEYHASH(keyno)];
- if (skp == sk) {
- key_hash[KEYHASH(keyno)] = sk->next;
- } else {
- while (skp->next != sk)
- skp = skp->next;
- skp->next = sk->next;
- }
- authnumkeys--;
-
- sk->next = authfreekeys;
- authfreekeys = sk;
- authnumfreekeys++;
- }
+ /* No longer trusted, return it to the free list. */
+ freesymkey(sk, bucket);
return;
}
- if (authnumfreekeys == 0)
- if (auth_moremem() == 0)
- return;
-
- sk = authfreekeys;
- authfreekeys = sk->next;
- authnumfreekeys--;
-
- sk->keyid = keyno;
- sk->flags = KEY_TRUSTED;
- sk->next = key_hash[KEYHASH(keyno)];
- key_hash[KEYHASH(keyno)] = sk;
- authnumkeys++;
- return;
+ /*
+ * keyid is not present, but the is to be trusted. We allocate
+ * a new key, but do not specify a key type or secret.
+ */
+ if (trust > 1) {
+ lifetime = current_time + trust;
+ } else {
+ lifetime = 0;
+ }
+ allocsymkey(bucket, id, KEY_TRUSTED, 0, lifetime, 0, NULL);
}
@@ -272,157 +489,153 @@ authtrust(
*/
int
authistrusted(
- keyid_t keyno
+ keyid_t keyno
)
{
- struct savekey *sk;
+ symkey * sk;
+ symkey ** bucket;
if (keyno == cache_keyid)
- return ((cache_flags & KEY_TRUSTED) != 0);
+ return !!(KEY_TRUSTED & cache_flags);
authkeyuncached++;
- sk = key_hash[KEYHASH(keyno)];
- while (sk != 0) {
+ bucket = &key_hash[KEYHASH(keyno)];
+ for (sk = *bucket; sk != NULL; sk = sk->hlink) {
if (keyno == sk->keyid)
- break;
- sk = sk->next;
+ break;
}
- if (sk == 0) {
+ if (NULL == sk || !(KEY_TRUSTED & sk->flags)) {
authkeynotfound++;
- return (0);
- } else if (!(sk->flags & KEY_TRUSTED)) {
- authkeynotfound++;
- return (0);
+ return FALSE;
}
- return (1);
+ return TRUE;
}
void
MD5auth_setkey(
keyid_t keyno,
+ int keytype,
const u_char *key,
- const int len
+ size_t len
)
{
- struct savekey *sk;
+ symkey * sk;
+ symkey ** bucket;
+ u_char * secret;
+ size_t secretsize;
+ DEBUG_ENSURE(keytype <= USHRT_MAX);
+ DEBUG_ENSURE(len < 4 * 1024);
/*
* See if we already have the key. If so just stick in the
* new value.
*/
- sk = key_hash[KEYHASH(keyno)];
- while (sk != 0) {
+ bucket = &key_hash[KEYHASH(keyno)];
+ for (sk = *bucket; sk != NULL; sk = sk->hlink) {
if (keyno == sk->keyid) {
- strncpy((char *)sk->k.MD5_key, (const char *)key,
- sizeof(sk->k.MD5_key));
- if ((sk->keylen = len) > sizeof(sk->k.MD5_key))
- sk->keylen = sizeof(sk->k.MD5_key);
-
- sk->flags |= KEY_MD5;
+ /* TALOS-CAN-0054: make sure we have a new buffer! */
+ if (NULL != sk->secret) {
+ memset(sk->secret, 0, sk->secretsize);
+ free(sk->secret);
+ }
+ sk->secret = emalloc(len);
+ sk->type = (u_short)keytype;
+ secretsize = len;
+ sk->secretsize = (u_short)secretsize;
+#ifndef DISABLE_BUG1243_FIX
+ memcpy(sk->secret, key, secretsize);
+#else
+ strlcpy((char *)sk->secret, (const char *)key,
+ secretsize);
+#endif
if (cache_keyid == keyno) {
cache_flags = 0;
cache_keyid = 0;
}
return;
}
- sk = sk->next;
}
/*
* Need to allocate new structure. Do it.
*/
- if (authnumfreekeys == 0) {
- if (auth_moremem() == 0)
- return;
- }
-
- sk = authfreekeys;
- authfreekeys = sk->next;
- authnumfreekeys--;
+ secretsize = len;
+ secret = emalloc(secretsize);
+#ifndef DISABLE_BUG1243_FIX
+ memcpy(secret, key, secretsize);
+#else
+ strlcpy((char *)secret, (const char *)key, secretsize);
+#endif
+ allocsymkey(bucket, keyno, 0, (u_short)keytype, 0,
+ (u_short)secretsize, secret);
+#ifdef DEBUG
+ if (debug >= 4) {
+ size_t j;
+
+ printf("auth_setkey: key %d type %d len %d ", (int)keyno,
+ keytype, (int)secretsize);
+ for (j = 0; j < secretsize; j++)
+ printf("%02x", secret[j]);
+ printf("\n");
+ }
+#endif
+}
- strncpy((char *)sk->k.MD5_key, (const char *)key,
- sizeof(sk->k.MD5_key));
- if ((sk->keylen = len) > sizeof(sk->k.MD5_key))
- sk->keylen = sizeof(sk->k.MD5_key);
- sk->keyid = keyno;
- sk->flags = KEY_MD5;
- sk->lifetime = 0;
- sk->next = key_hash[KEYHASH(keyno)];
- key_hash[KEYHASH(keyno)] = sk;
- authnumkeys++;
- return;
-}
-
/*
- * auth_delkeys - delete all known keys, in preparation for rereading
- * the keys file (presumably)
+ * auth_delkeys - delete non-autokey untrusted keys, and clear all info
+ * except the trusted bit of non-autokey trusted keys, in
+ * preparation for rereading the keys file.
*/
void
auth_delkeys(void)
{
- struct savekey *sk;
- struct savekey **skp;
- int i;
+ symkey * sk;
+
+ ITER_DLIST_BEGIN(key_listhead, sk, llink, symkey)
+ if (sk->keyid > NTP_MAXKEY) { /* autokey */
+ continue;
+ }
- for (i = 0; i < HASHSIZE; i++) {
- skp = &(key_hash[i]);
- sk = key_hash[i];
/*
- * Leave autokey keys alone.
+ * Don't lose info as to which keys are trusted. Make
+ * sure there are no dangling pointers!
*/
- while (sk != 0 && sk->keyid <= NTP_MAXKEY) {
- /*
- * Don't lose info as to which keys are trusted.
- */
- if (sk->flags & KEY_TRUSTED) {
- skp = &(sk->next);
- memset(&sk->k, 0, sizeof(sk->k));
- sk->lifetime = 0;
- sk->keylen = 0;
- sk = sk->next;
- } else {
- *skp = sk->next;
- authnumkeys--;
- sk->next = authfreekeys;
- authfreekeys = sk;
- authnumfreekeys++;
- sk = *skp;
+ if (KEY_TRUSTED & sk->flags) {
+ if (sk->secret != NULL) {
+ memset(sk->secret, 0, sk->secretsize);
+ free(sk->secret);
+ sk->secret = NULL; /* TALOS-CAN-0054 */
}
+ sk->secretsize = 0;
+ sk->lifetime = 0;
+ } else {
+ freesymkey(sk, &key_hash[KEYHASH(sk->keyid)]);
}
- }
+ ITER_DLIST_END()
}
+
/*
* auth_agekeys - delete keys whose lifetimes have expired
*/
void
auth_agekeys(void)
{
- struct savekey *sk;
- struct savekey *skp;
- int i;
-
- for (i = 0; i < HASHSIZE; i++) {
- sk = skp = key_hash[i];
- while (sk != 0) {
- skp = sk->next;
- if (sk->lifetime > 0 && current_time >
- sk->lifetime) {
- authtrust(sk->keyid, 0);
- authkeyexpired++;
- }
- sk = skp;
+ symkey * sk;
+
+ ITER_DLIST_BEGIN(key_listhead, sk, llink, symkey)
+ if (sk->lifetime > 0 && current_time > sk->lifetime) {
+ freesymkey(sk, &key_hash[KEYHASH(sk->keyid)]);
+ authkeyexpired++;
}
- }
-#ifdef DEBUG
- if (debug)
- printf("auth_agekeys: at %lu keys %lu expired %lu\n",
- current_time, authnumkeys, authkeyexpired);
-#endif
+ ITER_DLIST_END()
+ DPRINTF(1, ("auth_agekeys: at %lu keys %lu expired %lu\n",
+ current_time, authnumkeys, authkeyexpired));
}
+
/*
* authencrypt - generate message authenticator
*
@@ -430,12 +643,11 @@ auth_agekeys(void)
*/
int
authencrypt(
- keyid_t keyno,
- u_int32 *pkt,
- int length
+ keyid_t keyno,
+ u_int32 * pkt,
+ int length
)
-{
-
+{\
/*
* A zero key identifier means the sender has not verified
* the last message was correctly authenticated. The MAC
@@ -443,46 +655,40 @@ authencrypt(
*/
authencryptions++;
pkt[length / 4] = htonl(keyno);
- if (keyno == 0) {
- return (4);
+ if (0 == keyno) {
+ return 4;
+ }
+ if (!authhavekey(keyno)) {
+ return 0;
}
- if (!authhavekey(keyno))
- return (0);
-
- if (cache_flags & KEY_MD5)
- return (MD5authencrypt(cache_key, pkt, length));
- return (0);
+ return MD5authencrypt(cache_type, cache_secret, pkt, length);
}
+
/*
* authdecrypt - verify message authenticator
*
- * Returns one if authenticator valid, zero if invalid or key not found.
+ * Returns TRUE if authenticator valid, FALSE if invalid or not found.
*/
int
authdecrypt(
- keyid_t keyno,
- u_int32 *pkt,
- int length,
- int size
+ keyid_t keyno,
+ u_int32 * pkt,
+ int length,
+ int size
)
{
-
/*
* A zero key identifier means the sender has not verified
- * the last message was correctly authenticated. Nevertheless,
- * the authenticator itself is considered valid.
+ * the last message was correctly authenticated. For our
+ * purpose this is an invalid authenticator.
*/
authdecryptions++;
- if (keyno == 0)
- return (0);
-
- if (!authhavekey(keyno) || size < 4)
- return (0);
-
- if (cache_flags & KEY_MD5)
- return (MD5authdecrypt(cache_key, pkt, length, size));
+ if (0 == keyno || !authhavekey(keyno) || size < 4) {
+ return FALSE;
+ }
- return (0);
+ return MD5authdecrypt(cache_type, cache_secret, pkt, length,
+ size);
}
diff --git a/contrib/ntp/libntp/authreadkeys.c b/contrib/ntp/libntp/authreadkeys.c
index 22020f3..1c4c07c 100644
--- a/contrib/ntp/libntp/authreadkeys.c
+++ b/contrib/ntp/libntp/authreadkeys.c
@@ -1,6 +1,7 @@
/*
* authreadkeys.c - routines to support the reading of the key file
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
@@ -9,20 +10,20 @@
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
-/*
- * Arbitrary long string of ASCII characters.
- */
-#define KEY_TYPE_MD5 4
+#ifdef OPENSSL
+#include "openssl/objects.h"
+#include "openssl/evp.h"
+#endif /* OPENSSL */
/* Forwards */
-static char *nexttok P((char **));
+static char *nexttok (char **);
/*
* nexttok - basic internal tokenizing routine
*/
static char *
nexttok(
- char **str
+ char **str
)
{
register char *cp;
@@ -34,7 +35,7 @@ nexttok(
* Space past white space
*/
while (*cp == ' ' || *cp == '\t')
- cp++;
+ cp++;
/*
* Save this and space to end of token
@@ -42,25 +43,59 @@ nexttok(
starttok = cp;
while (*cp != '\0' && *cp != '\n' && *cp != ' '
&& *cp != '\t' && *cp != '#')
- cp++;
+ cp++;
/*
* If token length is zero return an error, else set end of
* token to zero and return start.
*/
if (starttok == cp)
- return 0;
+ return NULL;
if (*cp == ' ' || *cp == '\t')
- *cp++ = '\0';
+ *cp++ = '\0';
else
- *cp = '\0';
+ *cp = '\0';
*str = cp;
return starttok;
}
+/* TALOS-CAN-0055: possibly DoS attack by setting the key file to the
+ * log file. This is hard to prevent (it would need to check two files
+ * to be the same on the inode level, which will not work so easily with
+ * Windows or VMS) but we can avoid the self-amplification loop: We only
+ * log the first 5 errors, silently ignore the next 10 errors, and give
+ * up when when we have found more than 15 errors.
+ *
+ * This avoids the endless file iteration we will end up with otherwise,
+ * and also avoids overflowing the log file.
+ *
+ * Nevertheless, once this happens, the keys are gone since this would
+ * require a save/swap strategy that is not easy to apply due to the
+ * data on global/static level.
+ */
+
+static const size_t nerr_loglimit = 5u;
+static const size_t nerr_maxlimit = 15;
+
+static void log_maybe(size_t*, const char*, ...) NTP_PRINTF(2, 3);
+
+static void
+log_maybe(
+ size_t *pnerr,
+ const char *fmt ,
+ ...)
+{
+ va_list ap;
+ if (++(*pnerr) <= nerr_loglimit) {
+ va_start(ap, fmt);
+ mvsyslog(LOG_ERR, fmt, ap);
+ va_end(ap);
+ }
+}
+
/*
* authreadkeys - (re)read keys from a file.
*/
@@ -69,21 +104,26 @@ authreadkeys(
const char *file
)
{
- FILE *fp;
- char *line;
- char *token;
- u_long keyno;
- int keytype;
- char buf[512]; /* lots of room for line */
-
+ FILE *fp;
+ char *line;
+ char *token;
+ keyid_t keyno;
+ int keytype;
+ char buf[512]; /* lots of room for line */
+ u_char keystr[32]; /* Bug 2537 */
+ size_t len;
+ size_t j;
+ size_t nerr;
/*
* Open file. Complain and return if it can't be opened.
*/
fp = fopen(file, "r");
if (fp == NULL) {
- msyslog(LOG_ERR, "can't open key file %s: %m", file);
- return 0;
+ msyslog(LOG_ERR, "authreadkeys: file %s: %m",
+ file);
+ return (0);
}
+ INIT_SSL();
/*
* Remove all existing keys
@@ -93,70 +133,128 @@ authreadkeys(
/*
* Now read lines from the file, looking for key entries
*/
+ nerr = 0;
while ((line = fgets(buf, sizeof buf, fp)) != NULL) {
+ if (nerr > nerr_maxlimit)
+ break;
token = nexttok(&line);
- if (token == 0)
- continue;
+ if (token == NULL)
+ continue;
/*
* First is key number. See if it is okay.
*/
keyno = atoi(token);
if (keyno == 0) {
- msyslog(LOG_ERR,
- "cannot change keyid 0, key entry `%s' ignored",
- token);
+ log_maybe(&nerr,
+ "authreadkeys: cannot change key %s",
+ token);
continue;
}
if (keyno > NTP_MAXKEY) {
- msyslog(LOG_ERR,
- "keyid's > %d reserved for autokey, key entry `%s' ignored",
- NTP_MAXKEY, token);
+ log_maybe(&nerr,
+ "authreadkeys: key %s > %d reserved for Autokey",
+ token, NTP_MAXKEY);
continue;
}
/*
- * Next is keytype. See if that is all right.
+ * Next is keytype. See if that is all right.
*/
token = nexttok(&line);
- if (token == 0) {
- msyslog(LOG_ERR,
- "no key type for key number %ld, entry ignored",
- keyno);
+ if (token == NULL) {
+ log_maybe(&nerr,
+ "authreadkeys: no key type for key %d",
+ keyno);
+ continue;
+ }
+#ifdef OPENSSL
+ /*
+ * The key type is the NID used by the message digest
+ * algorithm. There are a number of inconsistencies in
+ * the OpenSSL database. We attempt to discover them
+ * here and prevent use of inconsistent data later.
+ */
+ keytype = keytype_from_text(token, NULL);
+ if (keytype == 0) {
+ log_maybe(&nerr,
+ "authreadkeys: invalid type for key %d",
+ keyno);
continue;
}
- switch (*token) {
- case 'M':
- case 'm':
- keytype = KEY_TYPE_MD5; break;
- default:
- msyslog(LOG_ERR,
- "invalid key type for key number %ld, entry ignored",
- keyno);
+ if (EVP_get_digestbynid(keytype) == NULL) {
+ log_maybe(&nerr,
+ "authreadkeys: no algorithm for key %d",
+ keyno);
continue;
}
+#else /* !OPENSSL follows */
/*
- * Finally, get key and insert it
+ * The key type is unused, but is required to be 'M' or
+ * 'm' for compatibility.
+ */
+ if (!(*token == 'M' || *token == 'm')) {
+ log_maybe(&nerr,
+ "authreadkeys: invalid type for key %d",
+ keyno);
+ continue;
+ }
+ keytype = KEY_TYPE_MD5;
+#endif /* !OPENSSL */
+
+ /*
+ * Finally, get key and insert it. If it is longer than 20
+ * characters, it is a binary string encoded in hex;
+ * otherwise, it is a text string of printable ASCII
+ * characters.
*/
token = nexttok(&line);
- if (token == 0) {
- msyslog(LOG_ERR,
- "no key for number %ld entry, entry ignored",
- keyno);
+ if (token == NULL) {
+ log_maybe(&nerr,
+ "authreadkeys: no key for key %d", keyno);
+ continue;
+ }
+ len = strlen(token);
+ if (len <= 20) { /* Bug 2537 */
+ MD5auth_setkey(keyno, keytype, (u_char *)token, len);
} else {
- switch(keytype) {
- case KEY_TYPE_MD5:
- if (!authusekey(keyno, keytype,
- (u_char *)token))
- msyslog(LOG_ERR,
- "format/parity error for MD5 key %ld, not used",
- keyno);
- break;
+ char hex[] = "0123456789abcdef";
+ u_char temp;
+ char *ptr;
+ size_t jlim;
+
+ jlim = min(len, 2 * sizeof(keystr));
+ for (j = 0; j < jlim; j++) {
+ ptr = strchr(hex, tolower((unsigned char)token[j]));
+ if (ptr == NULL)
+ break; /* abort decoding */
+ temp = (u_char)(ptr - hex);
+ if (j & 1)
+ keystr[j / 2] |= temp;
+ else
+ keystr[j / 2] = temp << 4;
+ }
+ if (j < jlim) {
+ log_maybe(&nerr,
+ "authreadkeys: invalid hex digit for key %d",
+ keyno);
+ continue;
}
+ MD5auth_setkey(keyno, keytype, keystr, jlim / 2);
}
}
- (void) fclose(fp);
- return 1;
+ fclose(fp);
+ if (nerr > nerr_maxlimit) {
+ msyslog(LOG_ERR,
+ "authreadkeys: emergency break after %u errors",
+ nerr);
+ return (0);
+ } else if (nerr > nerr_loglimit) {
+ msyslog(LOG_ERR,
+ "authreadkeys: found %u more error(s)",
+ nerr - nerr_loglimit);
+ }
+ return (1);
}
diff --git a/contrib/ntp/libntp/authusekey.c b/contrib/ntp/libntp/authusekey.c
index 40dd373..c1d0813 100644
--- a/contrib/ntp/libntp/authusekey.c
+++ b/contrib/ntp/libntp/authusekey.c
@@ -1,6 +1,7 @@
/*
* authusekey - decode a key from ascii and use it
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
@@ -15,9 +16,6 @@
* high order bit of each byte a parity bit. "Ascii" means a 1-to-8
* character string whose ascii representation is used as the key.
*/
-
-#define KEY_TYPE_MD5 4
-
int
authusekey(
keyid_t keyno,
@@ -25,23 +23,12 @@ authusekey(
const u_char *str
)
{
- const u_char *cp;
int len;
- cp = str;
- len = strlen((const char *)cp);
- if (len == 0)
- return 0;
-
- switch(keytype) {
- case KEY_TYPE_MD5:
- MD5auth_setkey(keyno, str, (int)strlen((const char *)str));
- break;
-
- default:
- /* Oh, well */
+ len = strlen((const char *)str);
+ if (0 == len)
return 0;
- }
+ MD5auth_setkey(keyno, keytype, str, len);
return 1;
}
diff --git a/contrib/ntp/libntp/strerror.c b/contrib/ntp/libntp/bsd_strerror.c
index 9d8ae8e..5ace9aa 100644
--- a/contrib/ntp/libntp/strerror.c
+++ b/contrib/ntp/libntp/bsd_strerror.c
@@ -39,9 +39,10 @@ strerror(
static char ebuf[20];
if ((unsigned int)errnum < sys_nerr)
- return(sys_errlist[errnum]);
- (void)sprintf(ebuf, "Unknown error: %d", errnum);
- return(ebuf);
+ return sys_errlist[errnum];
+ snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", errnum);
+
+ return ebuf;
}
#else
int strerror_bs;
diff --git a/contrib/ntp/libntp/buftvtots.c b/contrib/ntp/libntp/buftvtots.c
index bfceb35..a77e9f7 100644
--- a/contrib/ntp/libntp/buftvtots.c
+++ b/contrib/ntp/libntp/buftvtots.c
@@ -9,8 +9,9 @@
#endif
#include "ntp_fp.h"
#include "ntp_string.h"
-#include "ntp_unixtime.h"
+#include "timevalops.h"
+#ifndef SYS_WINNT
int
buftvtots(
const char *bufp,
@@ -27,9 +28,11 @@ buftvtots(
/*
* and use it
*/
- ts->l_ui = tv.tv_sec + (u_long)JAN_1970;
- if (tv.tv_usec > 999999)
- return 0;
- TVUTOTSF(tv.tv_usec, ts->l_uf);
- return 1;
+ if (tv.tv_usec > MICROSECONDS - 1)
+ return FALSE;
+
+ *ts = tval_stamp_to_lfp(tv);
+
+ return TRUE;
}
+#endif /* !SYS_WINNT */
diff --git a/contrib/ntp/libntp/caljulian.c b/contrib/ntp/libntp/caljulian.c
index 71123df..4a30603 100644
--- a/contrib/ntp/libntp/caljulian.c
+++ b/contrib/ntp/libntp/caljulian.c
@@ -1,146 +1,41 @@
/*
* caljulian - determine the Julian date from an NTP time.
+ *
+ * (Note: since we use the GREGORIAN calendar, this should be renamed to
+ * 'calgregorian' eventually...)
*/
+#include <config.h>
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_calendar.h"
-#include "ntp_stdlib.h"
-#include "ntp_fp.h"
-#if 0
-/*
- * calmonthtab - days-in-the-month table
- */
-static u_short calmonthtab[11] = {
- JAN,
- FEB,
- MAR,
- APR,
- MAY,
- JUN,
- JUL,
- AUG,
- SEP,
- OCT,
- NOV
-};
+#if !(defined(ISC_CHECK_ALL) || defined(ISC_CHECK_NONE) || \
+ defined(ISC_CHECK_ENSURE) || defined(ISC_CHECK_INSIST) || \
+ defined(ISC_CHECK_INVARIANT))
+# define ISC_CHECK_ALL
+#endif
+
+#include "ntp_assert.h"
void
caljulian(
- u_long ntptime,
- register struct calendar *jt
+ uint32_t ntp,
+ struct calendar * jt
)
{
- u_long ntp_day;
- u_long minutes;
- /*
- * Absolute, zero-adjusted Christian era day, starting from the
- * mythical day 12/1/1 BC
- */
- u_long acez_day;
-
- u_long d400; /* Days into a Gregorian cycle */
- u_long d100; /* Days into a normal century */
- u_long d4; /* Days into a 4-year cycle */
- u_long n400; /* # of Gregorian cycles */
- u_long n100; /* # of normal centuries */
- u_long n4; /* # of 4-year cycles */
- u_long n1; /* # of years into a leap year */
- /* cycle */
+ vint64 vlong;
+ ntpcal_split split;
+
+
+ INSIST(NULL != jt);
/*
- * Do the easy stuff first: take care of hh:mm:ss, ignoring leap
- * seconds
+ * Unfold ntp time around current time into NTP domain. Split
+ * into days and seconds, shift days into CE domain and
+ * process the parts.
*/
- jt->second = (u_char)(ntptime % SECSPERMIN);
- minutes = ntptime / SECSPERMIN;
- jt->minute = (u_char)(minutes % MINSPERHR);
- jt->hour = (u_char)((minutes / MINSPERHR) % HRSPERDAY);
-
- /*
- * Find the day past 1900/01/01 00:00 UTC
- */
- ntp_day = ntptime / SECSPERDAY;
- acez_day = DAY_NTP_STARTS + ntp_day - 1;
- n400 = acez_day/GREGORIAN_CYCLE_DAYS;
- d400 = acez_day%GREGORIAN_CYCLE_DAYS;
- n100 = d400 / GREGORIAN_NORMAL_CENTURY_DAYS;
- d100 = d400 % GREGORIAN_NORMAL_CENTURY_DAYS;
- n4 = d100 / GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
- d4 = d100 % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
- n1 = d4 / DAYSPERYEAR;
-
- /*
- * Calculate the year and year-of-day
- */
- jt->yearday = (u_short)(1 + d4%DAYSPERYEAR);
- jt->year = (u_short)(400*n400 + 100*n100 + n4*4 + n1);
-
- if (n100 == 4 || n1 == 4)
- {
- /*
- * If the cycle year ever comes out to 4, it must be December 31st
- * of a leap year.
- */
- jt->month = 12;
- jt->monthday = 31;
- jt->yearday = 366;
- }
- else
- {
- /*
- * Else, search forwards through the months to get the right month
- * and date.
- */
- int monthday;
-
- jt->year++;
- monthday = jt->yearday;
-
- for (jt->month=0;jt->month<11; jt->month++)
- {
- int t;
-
- t = monthday - calmonthtab[jt->month];
- if (jt->month == 1 && is_leapyear(jt->year))
- t--;
-
- if (t > 0)
- monthday = t;
- else
- break;
- }
- jt->month++;
- jt->monthday = (u_char) monthday;
- }
-}
-#else
-
-/* Updated 2003-12-30 TMa
-
- Uses common code with the *prettydate functions to convert an ntp
- seconds count into a calendar date.
- Will handle ntp epoch wraparound as long as the underlying os/library
- does so for the unix epoch, i.e. works after 2038.
-*/
-
-void
-caljulian(
- u_long ntptime,
- register struct calendar *jt
- )
-{
- struct tm *tm;
-
- tm = ntp2unix_tm(ntptime, 0);
-
- jt->hour = (u_char) tm->tm_hour;
- jt->minute = (u_char) tm->tm_min;
- jt->month = (u_char) (tm->tm_mon + 1);
- jt->monthday = (u_char) tm->tm_mday;
- jt->second = (u_char) tm->tm_sec;
- jt->year = (u_short) (tm->tm_year + 1900);
- jt->yearday = (u_short) (tm->tm_yday + 1); /* Assumes tm_yday starts with day 0! */
+ vlong = ntpcal_ntp_to_ntp(ntp, NULL);
+ split = ntpcal_daysplit(&vlong);
+ ntpcal_daysplit_to_date(jt, &split, DAY_NTP_STARTS);
}
-#endif
diff --git a/contrib/ntp/libntp/caltontp.c b/contrib/ntp/libntp/caltontp.c
index 9ec1064..808c94c 100644
--- a/contrib/ntp/libntp/caltontp.c
+++ b/contrib/ntp/libntp/caltontp.c
@@ -1,42 +1,68 @@
/*
* caltontp - convert a date to an NTP time
*/
+#include <config.h>
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
+#include "ntp_assert.h"
+#include "ntp_unixtime.h"
-u_long
+/*
+ * Juergen Perlinger, 2008-11-12
+ * Add support for full calendar calculatios. If the day-of-year is provided
+ * (that is, not zero) it will be used instead of month and day-of-month;
+ * otherwise a full turn through the calendar calculations will be taken.
+ *
+ * I know that Harlan Stenn likes to see assertions in production code, and I
+ * agree there, but it would be a tricky thing here. The algorithm is quite
+ * capable of producing sensible answers even to seemingly weird inputs: the
+ * date <any year here>-03-00, the 0.th March of the year, will be automtically
+ * treated as the last day of February, no matter whether the year is a leap
+ * year or not. So adding constraints is merely for the benefit of the callers,
+ * because the only thing we can check for consistency is our input, produced
+ * by somebody else.
+ *
+ * BTW: A total roundtrip using 'caljulian' would be a quite shaky thing:
+ * Because of the truncation of the NTP time stamp to 32 bits and the epoch
+ * unfolding around the current time done by 'caljulian' the roundtrip does
+ * *not* necessarily reproduce the input, especially if the time spec is more
+ * than 68 years off from the current time...
+ */
+
+uint32_t
caltontp(
- register const struct calendar *jt
+ const struct calendar *jt
)
{
- u_long ace_days; /* absolute Christian Era days */
- u_long ntp_days;
- int prior_years;
- u_long ntp_time;
-
- /*
- * First convert today's date to absolute days past 12/1/1 BC
- */
- prior_years = jt->year-1;
- ace_days = jt->yearday /* days this year */
- +(DAYSPERYEAR*prior_years) /* plus days in previous years */
- +(prior_years/4) /* plus prior years's leap days */
- -(prior_years/100) /* minus leapless century years */
- +(prior_years/400); /* plus leapful Gregorian yrs */
+ int32_t eraday; /* CE Rata Die number */
+ vint64 ntptime;/* resulting NTP time */
+
+ REQUIRE(jt != NULL);
- /*
- * Subtract out 1/1/1900, the beginning of the NTP epoch
- */
- ntp_days = ace_days - DAY_NTP_STARTS;
+ REQUIRE(jt->month <= 13); /* permit month 0..13! */
+ REQUIRE(jt->monthday <= 32);
+ REQUIRE(jt->yearday <= 366);
+ REQUIRE(jt->hour <= 24);
+ REQUIRE(jt->minute <= MINSPERHR);
+ REQUIRE(jt->second <= SECSPERMIN);
- /*
- * Do the obvious:
- */
- ntp_time =
- ntp_days*SECSPERDAY+SECSPERMIN*(MINSPERHR*jt->hour + jt->minute);
+ /*
+ * First convert the date to he corresponding RataDie
+ * number. If yearday is not zero, assume that it contains a
+ * useable value and avoid all calculations involving month
+ * and day-of-month. Do a full evaluation otherwise.
+ */
+ if (jt->yearday)
+ eraday = ntpcal_year_to_ystart(jt->year)
+ + jt->yearday - 1;
+ else
+ eraday = ntpcal_date_to_rd(jt);
- return ntp_time;
+ ntptime = ntpcal_dayjoin(eraday - DAY_NTP_STARTS,
+ ntpcal_etime_to_seconds(jt->hour, jt->minute,
+ jt->second));
+ return ntptime.d_s.lo;
}
diff --git a/contrib/ntp/libntp/calyearstart.c b/contrib/ntp/libntp/calyearstart.c
index 0f7ca4f..9e3f58f 100644
--- a/contrib/ntp/libntp/calyearstart.c
+++ b/contrib/ntp/libntp/calyearstart.c
@@ -2,21 +2,87 @@
* calyearstart - determine the NTP time at midnight of January 1 in
* the year of the given date.
*/
+#include <config.h>
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
+#include "ntp_assert.h"
-u_long
-calyearstart(u_long ntp_time)
+/*
+ * Juergen Perlinger, 2010-05-02
+ *
+ * Redone in terms of the calendar functions. It's rather simple:
+ * - expand the NTP time stamp
+ * - split into days and seconds since midnight, dropping the partial day
+ * - get full number of days before year start in NTP epoch
+ * - convert to seconds, truncated to 32 bits.
+ */
+u_int32
+calyearstart(u_int32 ntptime, const time_t *pivot)
+{
+ u_int32 ndays; /* elapsed days since NTP starts */
+ vint64 vlong;
+ ntpcal_split split;
+
+ vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
+ split = ntpcal_daysplit(&vlong);
+ ndays = ntpcal_rd_to_ystart(split.hi + DAY_NTP_STARTS)
+ - DAY_NTP_STARTS;
+
+ return (u_int32)(ndays * SECSPERDAY);
+}
+
+/*
+ * calmonthstart - get NTP time at midnight of the first day of the
+ * current month.
+ */
+u_int32
+calmonthstart(u_int32 ntptime, const time_t *pivot)
+{
+ u_int32 ndays; /* elapsed days since NTP starts */
+ vint64 vlong;
+ ntpcal_split split;
+
+ vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
+ split = ntpcal_daysplit(&vlong);
+ ndays = ntpcal_rd_to_mstart(split.hi + DAY_NTP_STARTS)
+ - DAY_NTP_STARTS;
+
+ return (u_int32)(ndays * SECSPERDAY);
+}
+
+/*
+ * calweekstart - get NTP time at midnight of the last monday on or
+ * before the current date.
+ */
+u_int32
+calweekstart(u_int32 ntptime, const time_t *pivot)
+{
+ u_int32 ndays; /* elapsed days since NTP starts */
+ vint64 vlong;
+ ntpcal_split split;
+
+ vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
+ split = ntpcal_daysplit(&vlong);
+ ndays = ntpcal_weekday_le(split.hi + DAY_NTP_STARTS, CAL_MONDAY)
+ - DAY_NTP_STARTS;
+
+ return (u_int32)(ndays * SECSPERDAY);
+}
+
+/*
+ * caldaystart - get NTP time at midnight of the current day.
+ */
+u_int32
+caldaystart(u_int32 ntptime, const time_t *pivot)
{
- struct calendar jt;
-
- caljulian(ntp_time,&jt);
- jt.yearday = 1;
- jt.monthday = 1;
- jt.month = 1;
- jt.hour = jt.minute = jt.second = 0;
- return caltontp(&jt);
+ vint64 vlong;
+ ntpcal_split split;
+
+ vlong = ntpcal_ntp_to_ntp(ntptime, pivot);
+ split = ntpcal_daysplit(&vlong);
+
+ return ntptime - split.lo;
}
diff --git a/contrib/ntp/libntp/clocktime.c b/contrib/ntp/libntp/clocktime.c
index 371859c..c1a3ba0 100644
--- a/contrib/ntp/libntp/clocktime.c
+++ b/contrib/ntp/libntp/clocktime.c
@@ -2,131 +2,148 @@
* clocktime - compute the NTP date from a day of year, hour, minute
* and second.
*/
+#include <config.h>
#include "ntp_fp.h"
#include "ntp_unixtime.h"
#include "ntp_stdlib.h"
+#include "ntp_calendar.h"
/*
- * Hacks to avoid excercising the multiplier. I have no pride.
+ * We check that the time be within CLOSETIME seconds of the receive
+ * time stamp. This is about 4 hours, which hopefully should be wide
+ * enough to collect most data, while close enough to keep things from
+ * getting confused.
*/
-#define MULBY10(x) (((x)<<3) + ((x)<<1))
-#define MULBY60(x) (((x)<<6) - ((x)<<2)) /* watch overflow */
-#define MULBY24(x) (((x)<<4) + ((x)<<3))
+#define CLOSETIME (4u*60u*60u)
/*
- * Two days, in seconds.
+ * Since we try to match years, the result of a full search will not
+ * change when we are already less than a half year from the receive
+ * time stamp. Since the length of a year is variable we use a
+ * slightly narrower limit; this might require a full evaluation near
+ * the edge, but will make sure we always get the correct result.
*/
-#define TWODAYS (2*24*60*60)
+#define NEARTIME (182u * SECSPERDAY)
/*
- * We demand that the time be within CLOSETIME seconds of the receive
- * time stamp. This is about 4 hours, which hopefully should be
- * wide enough to collect most data, while close enough to keep things
- * from getting confused.
+ * local calendar helpers
*/
-#define CLOSETIME (4*60*60)
-
+static int32 ntp_to_year(u_int32);
+static u_int32 year_to_ntp(int32);
+/*
+ * Take a time spec given as day-of-year, hour, minute and second as
+ * well as a GMT offset in hours and convert it to a NTP time stamp in
+ * '*ts_ui'. The value will be in the range (rec_ui-0.5yrs) to
+ * (rec_ui+0.5yrs). A hint for the current start-of-year will be
+ * read from '*yearstart'.
+ *
+ * On return '*ts_ui' will always the best matching solution, and
+ * '*yearstart' will receive the associated start-of-year.
+ *
+ * The function will tell if the result in 'ts_ui' is in CLOSETIME
+ * (+/-4hrs) around the receive time by returning a non-zero value.
+ *
+ * Note: The function puts no constraints on the value ranges for the
+ * time specification, but evaluates the effective seconds in
+ * 32-bit arithmetic.
+ */
int
clocktime(
- int yday,
- int hour,
- int minute,
- int second,
- int tzoff,
- u_long rec_ui,
- u_long *yearstart,
- u_int32 *ts_ui
- )
+ int yday , /* day-of-year */
+ int hour , /* hour of day */
+ int minute , /* minute of hour */
+ int second , /* second of minute */
+ int tzoff , /* hours west of GMT */
+ u_int32 rec_ui , /* pivot value */
+ u_long *yearstart, /* cached start-of-year, should be fixed to u_int32 */
+ u_int32 *ts_ui ) /* effective time stamp */
{
- register long tmp;
- register u_long date;
- register u_long yst;
-
+ u_int32 ystt[3]; /* year start */
+ u_int32 test[3]; /* result time stamp */
+ u_int32 diff[3]; /* abs difference to receive */
+ int32 y, tmp, idx, min;
+
/*
- * Compute the offset into the year in seconds. Note that
+ * Compute the offset into the year in seconds. Note that
* this could come out to be a negative number.
*/
- tmp = (long)(MULBY24((yday-1)) + hour + tzoff);
- tmp = MULBY60(tmp) + (long)minute;
- tmp = MULBY60(tmp) + (long)second;
-
+ tmp = ((int32)second +
+ SECSPERMIN * ((int32)minute +
+ MINSPERHR * ((int32)hour + (int32)tzoff +
+ HRSPERDAY * ((int32)yday - 1))));
/*
- * Initialize yearstart, if necessary.
+ * Based on the cached year start, do a first attempt. Be
+ * happy and return if this gets us better than NEARTIME to
+ * the receive time stamp. Do this only if the cached year
+ * start is not zero, which will not happen after 1900 for the
+ * next few thousand years.
*/
- yst = *yearstart;
- if (yst == 0) {
- yst = calyearstart(rec_ui);
- *yearstart = yst;
+ if (*yearstart) {
+ /* -- get time stamp of potential solution */
+ test[0] = (u_int32)(*yearstart) + tmp;
+ /* -- calc absolute difference to receive time */
+ diff[0] = test[0] - rec_ui;
+ if (diff[0] >= 0x80000000u)
+ diff[0] = ~diff[0] + 1;
+ /* -- can't get closer if diff < NEARTIME */
+ if (diff[0] < NEARTIME) {
+ *ts_ui = test[0];
+ return diff[0] < CLOSETIME;
+ }
}
/*
- * Now the fun begins. We demand that the received clock time
- * be within CLOSETIME of the receive timestamp, but
- * there is uncertainty about the year the timestamp is in.
- * Use the current year start for the first check, this should
- * work most of the time.
+ * Now the dance begins. Based on the receive time stamp and
+ * the seconds offset in 'tmp', we make an educated guess
+ * about the year to start with. This takes us on the spot
+ * with a fuzz of +/-1 year.
+ *
+ * We calculate the effective timestamps for the three years
+ * around the guess and select the entry with the minimum
+ * absolute difference to the receive time stamp.
*/
- date = (u_long)(tmp + (long)yst);
- if (date < (rec_ui + CLOSETIME) &&
- date > (rec_ui - CLOSETIME)) {
- *ts_ui = date;
- return 1;
+ y = ntp_to_year(rec_ui - tmp);
+ for (idx = 0; idx < 3; idx++) {
+ /* -- get year start of potential solution */
+ ystt[idx] = year_to_ntp(y + idx - 1);
+ /* -- get time stamp of potential solution */
+ test[idx] = ystt[idx] + tmp;
+ /* -- calc absolute difference to receive time */
+ diff[idx] = test[idx] - rec_ui;
+ if (diff[idx] >= 0x80000000u)
+ diff[idx] = ~diff[idx] + 1;
}
+ /* -*- assume current year fits best, then search best fit */
+ for (min = 1, idx = 0; idx < 3; idx++)
+ if (diff[idx] < diff[min])
+ min = idx;
+ /* -*- store results and update year start */
+ *ts_ui = test[min];
+ *yearstart = ystt[min];
- /*
- * Trouble. Next check is to see if the year rolled over and, if
- * so, try again with the new year's start.
- */
- yst = calyearstart(rec_ui);
- if (yst != *yearstart) {
- date = (u_long)((long)yst + tmp);
- *ts_ui = date;
- if (date < (rec_ui + CLOSETIME) &&
- date > (rec_ui - CLOSETIME)) {
- *yearstart = yst;
- return 1;
- }
- }
+ /* -*- tell if we could get into CLOSETIME*/
+ return diff[min] < CLOSETIME;
+}
- /*
- * Here we know the year start matches the current system
- * time. One remaining possibility is that the time code
- * is in the year previous to that of the system time. This
- * is only worth checking if the receive timestamp is less
- * than a couple of days into the new year.
- */
- if ((rec_ui - yst) < TWODAYS) {
- yst = calyearstart(yst - TWODAYS);
- if (yst != *yearstart) {
- date = (u_long)(tmp + (long)yst);
- if (date < (rec_ui + CLOSETIME) &&
- date > (rec_ui - CLOSETIME)) {
- *yearstart = yst;
- *ts_ui = date;
- return 1;
- }
- }
- }
+static int32
+ntp_to_year(
+ u_int32 ntp)
+{
+ vint64 t;
+ ntpcal_split s;
- /*
- * One last possibility is that the time stamp is in the year
- * following the year the system is in. Try this one before
- * giving up.
- */
- yst = calyearstart(rec_ui + TWODAYS);
- if (yst != *yearstart) {
- date = (u_long)((long)yst + tmp);
- if (date < (rec_ui + CLOSETIME) &&
- date > (rec_ui - CLOSETIME)) {
- *yearstart = yst;
- *ts_ui = date;
- return 1;
- }
- }
+ t = ntpcal_ntp_to_ntp(ntp, NULL);
+ s = ntpcal_daysplit(&t);
+ s = ntpcal_split_eradays(s.hi + DAY_NTP_STARTS - 1, NULL);
+ return s.hi + 1;
+}
- /*
- * Give it up.
- */
- return 0;
+static u_int32
+year_to_ntp(
+ int32 year)
+{
+ u_int32 days;
+ days = ntpcal_days_in_years(year-1) - DAY_NTP_STARTS + 1;
+ return days * SECSPERDAY;
}
diff --git a/contrib/ntp/libntp/clocktypes.c b/contrib/ntp/libntp/clocktypes.c
index d7dc4ee..de7f6b4 100644
--- a/contrib/ntp/libntp/clocktypes.c
+++ b/contrib/ntp/libntp/clocktypes.c
@@ -1,6 +1,7 @@
/*
* Data for pretty printing clock types
*/
+#include <config.h>
#include <stdio.h>
#include "ntp_fp.h"
@@ -68,8 +69,8 @@ struct clktype clktypes[] = {
"MSF_ARCRON" },
{ REFCLK_SHM, "Clock attached thru shared Memory (28)",
"SHM" },
- { REFCLK_PALISADE, "Trimble Navigation Palisade GPS (29)",
- "GPS_PALISADE" },
+ { REFCLK_PALISADE, "Trimble Navigation Palisade GPS (29)",
+ "GPS_PALISADE" },
{ REFCLK_ONCORE, "Motorola UT Oncore GPS (30)",
"GPS_ONCORE" },
{ REFCLK_GPS_JUPITER, "Rockwell Jupiter GPS (31)",
@@ -78,7 +79,7 @@ struct clktype clktypes[] = {
"CHRONOLOG" },
{ REFCLK_DUMBCLOCK, "Dumb generic hh:mm:ss local clock (33)",
"DUMBCLOCK" },
- { REFCLK_ULINK, "Ultralink M320 WWVB receiver (34)",
+ { REFCLK_ULINK, "Ultralink M320 WWVB receiver (34)",
"ULINK_M320"},
{ REFCLK_PCF, "Conrad parallel port radio clock (35)",
"PCF"},
@@ -100,6 +101,10 @@ struct clktype clktypes[] = {
"GPS_RIPENCC" },
{ REFCLK_NEOCLOCK4X, "NeoClock4X DCF77 / TDF receiver (44)",
"NEOCLK4X"},
+ { REFCLK_TSYNCPCI, "Spectracom TSYNC PCI timing board (45)",
+ "PCI_TSYNC"},
+ { REFCLK_GPSDJSON, "GPSD JSON socket (46)",
+ "GPSD_JSON"},
{ -1, "", "" }
};
@@ -112,7 +117,7 @@ clockname(
for (clk = clktypes; clk->code != -1; clk++) {
if (num == clk->code)
- return (clk->abbrev);
+ return (clk->abbrev);
}
return (NULL);
}
diff --git a/contrib/ntp/libntp/decodenetnum.c b/contrib/ntp/libntp/decodenetnum.c
index 746c855..35b908f 100644
--- a/contrib/ntp/libntp/decodenetnum.c
+++ b/contrib/ntp/libntp/decodenetnum.c
@@ -1,39 +1,86 @@
/*
* decodenetnum - return a net number (this is crude, but careful)
*/
+#include <config.h>
#include <sys/types.h>
#include <ctype.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+#include "ntp.h"
#include "ntp_stdlib.h"
+#include "ntp_assert.h"
+/*
+ * decodenetnum convert text IP address and port to sockaddr_u
+ *
+ * Returns 0 for failure, 1 for success.
+ */
int
decodenetnum(
const char *num,
- struct sockaddr_storage *netnum
+ sockaddr_u *netnum
)
{
struct addrinfo hints, *ai = NULL;
- register int err, i;
- register const char *cp;
+ int err;
+ u_short port;
+ const char *cp;
+ const char *port_str;
+ char *pp;
+ char *np;
char name[80];
- cp = num;
+ REQUIRE(num != NULL);
+
+ if (strlen(num) >= sizeof(name)) {
+ return 0;
+ }
- if (*cp == '[') {
- cp++;
- for (i = 0; *cp != ']'; cp++, i++)
- name[i] = *cp;
- name[i] = '\0';
- num = name;
+ port_str = NULL;
+ if ('[' != num[0]) {
+ /*
+ * to distinguish IPv6 embedded colons from a port
+ * specification on an IPv4 address, assume all
+ * legal IPv6 addresses have at least two colons.
+ */
+ pp = strchr(num, ':');
+ if (NULL == pp)
+ cp = num; /* no colons */
+ else if (NULL != strchr(pp + 1, ':'))
+ cp = num; /* two or more colons */
+ else { /* one colon */
+ strlcpy(name, num, sizeof(name));
+ cp = name;
+ pp = strchr(cp, ':');
+ *pp = '\0';
+ port_str = pp + 1;
+ }
+ } else {
+ cp = num + 1;
+ np = name;
+ while (*cp && ']' != *cp)
+ *np++ = *cp++;
+ *np = 0;
+ if (']' == cp[0] && ':' == cp[1] && '\0' != cp[2])
+ port_str = &cp[2];
+ cp = name;
}
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_flags = AI_NUMERICHOST;
- err = getaddrinfo(num, NULL, &hints, &ai);
+ ZERO(hints);
+ hints.ai_flags = Z_AI_NUMERICHOST;
+ err = getaddrinfo(cp, "ntp", &hints, &ai);
if (err != 0)
return 0;
- memcpy(netnum, (struct sockaddr_storage *)ai->ai_addr, ai->ai_addrlen);
+ INSIST(ai->ai_addrlen <= sizeof(*netnum));
+ ZERO(*netnum);
+ memcpy(netnum, ai->ai_addr, ai->ai_addrlen);
freeaddrinfo(ai);
+ if (NULL == port_str || 1 != sscanf(port_str, "%hu", &port))
+ port = NTP_PORT;
+ SET_PORT(netnum, port);
return 1;
}
diff --git a/contrib/ntp/libntp/dofptoa.c b/contrib/ntp/libntp/dofptoa.c
index 0f96909..758af2f 100644
--- a/contrib/ntp/libntp/dofptoa.c
+++ b/contrib/ntp/libntp/dofptoa.c
@@ -1,6 +1,7 @@
/*
* dofptoa - do the grunge work to convert an fp number to ascii
*/
+#include <config.h>
#include <stdio.h>
#include "ntp_fp.h"
@@ -32,7 +33,7 @@ dofptoa(
/*
* Zero out the buffer
*/
- memset((char *)cbuf, 0, sizeof cbuf);
+ ZERO(cbuf);
/*
* Set the pointers to point at the first
@@ -116,3 +117,43 @@ dofptoa(
*bp = '\0';
return buf;
}
+
+
+char *
+fptoa(
+ s_fp fpv,
+ short ndec
+ )
+{
+ u_fp plusfp;
+ int neg;
+
+ neg = (fpv < 0);
+ if (neg) {
+ plusfp = (u_fp)(-fpv);
+ } else {
+ plusfp = (u_fp)fpv;
+ }
+
+ return dofptoa(plusfp, neg, ndec, FALSE);
+}
+
+
+char *
+fptoms(
+ s_fp fpv,
+ short ndec
+ )
+{
+ u_fp plusfp;
+ int neg;
+
+ neg = (fpv < 0);
+ if (neg) {
+ plusfp = (u_fp)(-fpv);
+ } else {
+ plusfp = (u_fp)fpv;
+ }
+
+ return dofptoa(plusfp, neg, ndec, TRUE);
+}
diff --git a/contrib/ntp/libntp/dolfptoa.c b/contrib/ntp/libntp/dolfptoa.c
index f68679c..07ead95 100644
--- a/contrib/ntp/libntp/dolfptoa.c
+++ b/contrib/ntp/libntp/dolfptoa.c
@@ -1,6 +1,7 @@
/*
* dolfptoa - do the grunge work of converting an l_fp number to decimal
*/
+#include <config.h>
#include <stdio.h>
#include "ntp_fp.h"
@@ -10,20 +11,17 @@
char *
dolfptoa(
- u_long fpi,
- u_long fpv,
+ u_int32 fpi,
+ u_int32 fpv,
int neg,
short ndec,
int msec
)
{
- register u_char *cp, *cpend;
- register u_long lwork;
- register int dec;
+ u_char *cp, *cpend, *cpdec;
+ int dec;
u_char cbuf[24];
- u_char *cpdec;
- char *buf;
- char *bp;
+ char *buf, *bp;
/*
* Get a string buffer before starting
@@ -33,113 +31,81 @@ dolfptoa(
/*
* Zero the character buffer
*/
- memset((char *) cbuf, 0, sizeof(cbuf));
+ ZERO(cbuf);
/*
- * safeguard against sign extensions and other mishaps on 64 bit platforms
- * the code following is designed for and only for 32-bit inputs and
- * only 32-bit worth of input are supplied.
- */
- fpi &= 0xffffffff;
- fpv &= 0xffffffff;
-
- /*
- * Work on the integral part. This is biased by what I know
- * compiles fairly well for a 68000.
+ * Work on the integral part. This should work reasonable on
+ * all machines with 32 bit arithmetic. Please note that 32 bits
+ * can *always* be represented with at most 10 decimal digits,
+ * including a possible rounding from the fractional part.
*/
- cp = cpend = &cbuf[10];
- lwork = fpi;
- if (lwork & 0xffff0000) {
- register u_long lten = 10;
- register u_long ltmp;
-
- do {
- ltmp = lwork;
- lwork /= lten;
- ltmp -= (lwork << 3) + (lwork << 1);
- if (cp < cbuf) abort(); /* rather die a horrible death than trash the memory */
- *--cp = (u_char)ltmp;
- } while (lwork & 0xffff0000);
- }
- if (lwork != 0) {
- register u_short sten = 10;
- register u_short stmp;
- register u_short swork = (u_short)lwork;
-
- do {
- stmp = swork;
- swork = (u_short) (swork/sten);
- stmp = (u_short)(stmp - ((swork<<3) + (swork<<1)));
- if (cp < cbuf) abort(); /* rather die a horrible death than trash the memory */
- *--cp = (u_char)stmp;
- } while (swork != 0);
+ cp = cpend = cpdec = &cbuf[10];
+ for (dec = cp - cbuf; dec > 0 && fpi != 0; dec--) {
+ /* can add another digit */
+ u_int32 digit;
+
+ digit = fpi;
+ fpi /= 10U;
+ digit -= (fpi << 3) + (fpi << 1); /* i*10 */
+ *--cp = (u_char)digit;
}
/*
* Done that, now deal with the problem of the fraction. First
* determine the number of decimal places.
*/
+ dec = ndec;
+ if (dec < 0)
+ dec = 0;
if (msec) {
- dec = ndec + 3;
- if (dec < 3)
- dec = 3;
- cpdec = &cbuf[13];
- } else {
- dec = ndec;
- if (dec < 0)
- dec = 0;
- cpdec = &cbuf[10];
+ dec += 3;
+ cpdec += 3;
}
- if (dec > 12)
- dec = 12;
+ if ((size_t)dec > sizeof(cbuf) - (cpend - cbuf))
+ dec = sizeof(cbuf) - (cpend - cbuf);
/*
* If there's a fraction to deal with, do so.
*/
- if (fpv != 0) {
- l_fp work;
-
- work.l_ui = 0;
- work.l_uf = fpv;
- while (dec > 0) {
- l_fp ftmp;
-
- dec--;
- /*
- * The scheme here is to multiply the
- * fraction (0.1234...) by ten. This moves
- * a junk of BCD into the units part.
- * record that and iterate.
- */
- work.l_ui = 0;
- L_LSHIFT(&work);
- ftmp = work;
- L_LSHIFT(&work);
- L_LSHIFT(&work);
- L_ADD(&work, &ftmp);
- *cpend++ = (u_char)work.l_ui;
- if (work.l_uf == 0)
- break;
- if (cpend > (cbuf + sizeof(cbuf))) abort(); /* rather die a horrible death than trash the memory */
- }
-
+ for (/*NOP*/; dec > 0 && fpv != 0; dec--) {
+ u_int32 digit, tmph, tmpl;
+
/*
- * Rounding is rotten
+ * The scheme here is to multiply the fraction
+ * (0.1234...) by ten. This moves a junk of BCD into
+ * the units part. record that and iterate.
+ * multiply by shift/add in two dwords.
*/
- if (work.l_uf & 0x80000000) {
- register u_char *tp = cpend;
+ digit = 0;
+ M_LSHIFT(digit, fpv);
+ tmph = digit;
+ tmpl = fpv;
+ M_LSHIFT(digit, fpv);
+ M_LSHIFT(digit, fpv);
+ M_ADD(digit, fpv, tmph, tmpl);
+ *cpend++ = (u_char)digit;
+ }
+
+ /* decide whether to round or simply extend by zeros */
+ if (dec > 0) {
+ /* only '0' digits left -- just reposition end */
+ cpend += dec;
+ } else {
+ /* some bits remain in 'fpv'; do round */
+ u_char *tp = cpend;
+ int carry = ((fpv & 0x80000000) != 0);
- *(--tp) += 1;
- while (*tp >= 10) {
+ for (dec = tp - cbuf; carry && dec > 0; dec--) {
+ *--tp += 1;
+ if (*tp == 10)
*tp = 0;
- *(--tp) += 1;
- };
- if (tp < cp)
- cp = tp;
+ else
+ carry = FALSE;
}
- }
- cpend += dec;
+ if (tp < cp) /* rounding from 999 to 1000 or similiar? */
+ cp = tp;
+ }
/*
* We've now got the fraction in cbuf[], with cp pointing at
@@ -148,21 +114,18 @@ dolfptoa(
* Remove leading zeros, then format the number into the
* buffer.
*/
- while (cp < cpdec) {
- if (*cp != 0)
- break;
+ while (cp < cpdec && *cp == 0)
cp++;
- }
- if (cp == cpdec)
- --cp;
+ if (cp >= cpdec)
+ cp = cpdec - 1;
bp = buf;
if (neg)
- *bp++ = '-';
+ *bp++ = '-';
while (cp < cpend) {
if (cp == cpdec)
- *bp++ = '.';
- *bp++ = (char)(*cp++ + '0'); /* ascii dependent? */
+ *bp++ = '.';
+ *bp++ = (char)(*cp++) + '0';
}
*bp = '\0';
@@ -171,3 +134,41 @@ dolfptoa(
*/
return buf;
}
+
+
+char *
+mfptoa(
+ u_int32 fpi,
+ u_int32 fpf,
+ short ndec
+ )
+{
+ int isneg;
+
+ isneg = M_ISNEG(fpi);
+ if (isneg) {
+ M_NEG(fpi, fpf);
+ }
+
+ return dolfptoa(fpi, fpf, isneg, ndec, FALSE);
+}
+
+
+char *
+mfptoms(
+ u_int32 fpi,
+ u_int32 fpf,
+ short ndec
+ )
+{
+ int isneg;
+
+ isneg = M_ISNEG(fpi);
+ if (isneg) {
+ M_NEG(fpi, fpf);
+ }
+
+ return dolfptoa(fpi, fpf, isneg, ndec, TRUE);
+}
+
+
diff --git a/contrib/ntp/libntp/emalloc.c b/contrib/ntp/libntp/emalloc.c
index 2fe4c38..8b7ef99 100644
--- a/contrib/ntp/libntp/emalloc.c
+++ b/contrib/ntp/libntp/emalloc.c
@@ -1,48 +1,149 @@
/*
* emalloc - return new memory obtained from the system. Belch if none.
*/
+#include <config.h>
#include "ntp_types.h"
#include "ntp_malloc.h"
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
-#if defined SYS_WINNT && defined DEBUG
-#include <crtdbg.h>
-#endif
-#if defined SYS_WINNT && defined DEBUG
+/*
+ * When using the debug MS CRT allocator, each allocation stores the
+ * callsite __FILE__ and __LINE__, which is then displayed at process
+ * termination, to track down leaks. We don't want all of our
+ * allocations to show up as coming from emalloc.c, so we preserve the
+ * original callsite's source file and line using macros which pass
+ * __FILE__ and __LINE__ as parameters to these routines.
+ * Other debug malloc implementations can be used by defining
+ * EREALLOC_IMPL() as ports/winnt/include/config.h does.
+ */
void *
-debug_emalloc(
- u_int size,
- char *filename,
- int line
+ereallocz(
+ void * ptr,
+ size_t newsz,
+ size_t priorsz,
+ int zero_init
+#ifdef EREALLOC_CALLSITE /* ntp_malloc.h */
+ ,
+ const char * file,
+ int line
+#endif
)
{
- char *mem;
+ char * mem;
+ size_t allocsz;
+
+ if (0 == newsz)
+ allocsz = 1;
+ else
+ allocsz = newsz;
- if ((mem = (char *)_malloc_dbg(size, _NORMAL_BLOCK, filename, line)) == 0) {
- msyslog(LOG_ERR, "Exiting: No more memory!");
+ mem = EREALLOC_IMPL(ptr, allocsz, file, line);
+ if (NULL == mem) {
+ msyslog_term = TRUE;
+#ifndef EREALLOC_CALLSITE
+ msyslog(LOG_ERR, "fatal out of memory (%lu bytes)",
+ (u_long)newsz);
+#else
+ msyslog(LOG_ERR,
+ "fatal out of memory %s line %d (%lu bytes)",
+ file, line, (u_long)newsz);
+#endif
exit(1);
}
+
+ if (zero_init && newsz > priorsz)
+ zero_mem(mem + priorsz, newsz - priorsz);
+
return mem;
}
-#else
+/* oreallocarray.c is licensed under the following:
+ * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
void *
-emalloc(
- u_int size
+oreallocarray(
+ void *optr,
+ size_t nmemb,
+ size_t size
+#ifdef EREALLOC_CALLSITE /* ntp_malloc.h */
+ ,
+ const char * file,
+ int line
+#endif
)
{
- char *mem;
-
- if ((mem = (char *)malloc(size)) == 0) {
- msyslog(LOG_ERR, "Exiting: No more memory!");
+ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ nmemb > 0 && SIZE_MAX / nmemb < size) {
+#ifndef EREALLOC_CALLSITE
+ msyslog(LOG_ERR, "fatal allocation size overflow");
+#else
+ msyslog(LOG_ERR,
+ "fatal allocation size overflow %s line %d",
+ file, line);
+#endif
exit(1);
}
- return mem;
+#ifndef EREALLOC_CALLSITE
+ return ereallocz(optr, (size * nmemb), 0, FALSE);
+#else
+ return ereallocz(optr, (size * nmemb), 0, FALSE, file, line);
+#endif
}
+char *
+estrdup_impl(
+ const char * str
+#ifdef EREALLOC_CALLSITE
+ ,
+ const char * file,
+ int line
+#endif
+ )
+{
+ char * copy;
+ size_t bytes;
+ bytes = strlen(str) + 1;
+ copy = ereallocz(NULL, bytes, 0, FALSE
+#ifdef EREALLOC_CALLSITE
+ , file, line
#endif
+ );
+ memcpy(copy, str, bytes);
+
+ return copy;
+}
+
+
+#if 0
+#ifndef EREALLOC_CALLSITE
+void *
+emalloc(size_t newsz)
+{
+ return ereallocz(NULL, newsz, 0, FALSE);
+}
+#endif
+#endif
+
diff --git a/contrib/ntp/libntp/findconfig.c b/contrib/ntp/libntp/findconfig.c
index ecf6a4b..1785ff7 100644
--- a/contrib/ntp/libntp/findconfig.c
+++ b/contrib/ntp/libntp/findconfig.c
@@ -22,13 +22,13 @@ FindConfig(
struct utsname unamebuf;
/* All keyed by initial target being a directory */
- (void) strcpy(result, base);
+ strlcpy(result, base, sizeof(result));
if (stat(result, &sbuf) == 0) {
if (S_ISDIR(sbuf.st_mode)) {
/* First choice is my hostname */
if (gethostname(hostname, BUFSIZ) >= 0) {
- (void) sprintf(result, "%s/%s", base, hostname);
+ snprintf(result, sizeof(result), "%s/%s", base, hostname);
if (stat(result, &sbuf) == 0) {
goto outahere;
} else {
@@ -39,17 +39,19 @@ FindConfig(
cp = unamebuf.machine + 5;
else
cp = unamebuf.machine;
- (void) sprintf(result, "%s/default.%s", base, cp);
+ snprintf(result, sizeof(result), "%s/default.%s", base, cp);
if (stat(result, &sbuf) == 0) {
goto outahere;
} else {
/* Last choice is just default */
- (void) sprintf(result, "%s/default", base);
+ snprintf(result, sizeof(result), "%s/default", base);
if (stat(result, &sbuf) == 0) {
goto outahere;
} else {
- (void) strcpy(result, "/not/found");
+ strlcpy(result,
+ "/not/found",
+ sizeof(result));
}
}
}
diff --git a/contrib/ntp/libntp/fptoa.c b/contrib/ntp/libntp/fptoa.c
deleted file mode 100644
index 025ad21..0000000
--- a/contrib/ntp/libntp/fptoa.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * fptoa - return an asciized representation of an s_fp number
- */
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-
-char *
-fptoa(
- s_fp fpv,
- short ndec
- )
-{
- u_fp plusfp;
- int neg;
-
- if (fpv < 0) {
- plusfp = (u_fp)(-fpv);
- neg = 1;
- } else {
- plusfp = (u_fp)fpv;
- neg = 0;
- }
-
- return dofptoa(plusfp, neg, ndec, 0);
-}
diff --git a/contrib/ntp/libntp/fptoms.c b/contrib/ntp/libntp/fptoms.c
deleted file mode 100644
index 0bfca55..0000000
--- a/contrib/ntp/libntp/fptoms.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * fptoms - return an asciized s_fp number in milliseconds
- */
-#include "ntp_fp.h"
-
-char *
-fptoms(
- s_fp fpv,
- short ndec
- )
-{
- u_fp plusfp;
- int neg;
-
- if (fpv < 0) {
- plusfp = (u_fp)(-fpv);
- neg = 1;
- } else {
- plusfp = (u_fp)fpv;
- neg = 0;
- }
-
- return dofptoa(plusfp, neg, ndec, 1);
-}
diff --git a/contrib/ntp/libntp/getopt.c b/contrib/ntp/libntp/getopt.c
index 7b344f0..63c82fa 100644
--- a/contrib/ntp/libntp/getopt.c
+++ b/contrib/ntp/libntp/getopt.c
@@ -13,6 +13,7 @@
/*LINTLIBRARY*/
+#include <config.h>
#include <stdio.h>
#include "ntp_stdlib.h"
diff --git a/contrib/ntp/libntp/hextoint.c b/contrib/ntp/libntp/hextoint.c
index 0d774eb..980a43f 100644
--- a/contrib/ntp/libntp/hextoint.c
+++ b/contrib/ntp/libntp/hextoint.c
@@ -2,6 +2,7 @@
* hextoint - convert an ascii string in hex to an unsigned
* long, with error checking
*/
+#include <config.h>
#include <ctype.h>
#include "ntp_stdlib.h"
@@ -9,7 +10,7 @@
int
hextoint(
const char *str,
- u_long *ival
+ u_long *pu
)
{
register u_long u;
@@ -18,22 +19,24 @@ hextoint(
cp = str;
if (*cp == '\0')
- return 0;
+ return 0;
u = 0;
while (*cp != '\0') {
- if (!isxdigit((int)*cp))
- return 0;
- if (u >= 0x10000000)
- return 0; /* overflow */
+ if (!isxdigit((unsigned char)*cp))
+ return 0;
+ if (u & 0xF0000000)
+ return 0; /* overflow */
u <<= 4;
- if (*cp <= '9') /* very ascii dependent */
- u += *cp++ - '0';
- else if (*cp >= 'a')
- u += *cp++ - 'a' + 10;
+ if ('0' <= *cp && *cp <= '9')
+ u += *cp++ - '0';
+ else if ('a' <= *cp && *cp <= 'f')
+ u += *cp++ - 'a' + 10;
+ else if ('A' <= *cp && *cp <= 'F')
+ u += *cp++ - 'A' + 10;
else
- u += *cp++ - 'A' + 10;
+ return 0;
}
- *ival = u;
+ *pu = u;
return 1;
}
diff --git a/contrib/ntp/libntp/hextolfp.c b/contrib/ntp/libntp/hextolfp.c
index d0b6243..2bff929 100644
--- a/contrib/ntp/libntp/hextolfp.c
+++ b/contrib/ntp/libntp/hextolfp.c
@@ -1,6 +1,7 @@
/*
* hextolfp - convert an ascii hex string to an l_fp number
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
@@ -29,7 +30,7 @@ hextolfp(
*
* [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0]
*/
- while (isspace((int)*cp))
+ while (isspace((unsigned char)*cp))
cp++;
cpstart = cp;
@@ -58,7 +59,7 @@ hextolfp(
if ((cp - cpstart) < 8 || ind == NULL)
return 0;
- if (*cp != '\0' && !isspace((int)*cp))
+ if (*cp != '\0' && !isspace((unsigned char)*cp))
return 0;
lfp->l_ui = dec_i;
diff --git a/contrib/ntp/libntp/humandate.c b/contrib/ntp/libntp/humandate.c
index 630c871..d9d5e89 100644
--- a/contrib/ntp/libntp/humandate.c
+++ b/contrib/ntp/libntp/humandate.c
@@ -1,62 +1,60 @@
/*
- * humandate - convert an NTP (or the current) time to something readable
+ * humandate.c - convert an NTP (or the current) time to something readable
*/
+#include <config.h>
#include <stdio.h>
+
#include "ntp_fp.h"
#include "ntp_unixtime.h" /* includes <sys/time.h> and <time.h> */
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
-static const char *months[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-static const char *days[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
-};
-
-char *
-humandate(
- u_long ntptime
- )
-{
- char *bp;
- struct tm *tm;
- tm = ntp2unix_tm(ntptime, 1);
+/* This is used in msyslog.c; we don't want to clutter up the log with
+ the year and day of the week, etc.; just the minimal date and time. */
+const char *
+humanlogtime(void)
+{
+ char * bp;
+ time_t cursec;
+ struct tm * tm;
+
+ cursec = time(NULL);
+ tm = localtime(&cursec);
if (!tm)
- return "--- --- -- ---- --:--:--";
+ return "-- --- --:--:--";
LIB_GETBUF(bp);
- (void) sprintf(bp, "%s, %s %2d %4d %2d:%02d:%02d",
- days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday,
- 1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
-
+ snprintf(bp, LIB_BUFLENGTH, "%2d %s %02d:%02d:%02d",
+ tm->tm_mday, months[tm->tm_mon],
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+
return bp;
}
-/* This is used in msyslog.c; we don't want to clutter up the log with
- the year and day of the week, etc.; just the minimal date and time. */
-
-char *
-humanlogtime(void)
+/*
+ * humantime() -- like humanlogtime() but without date, and with the
+ * time to display given as an argument.
+ */
+const char *
+humantime(
+ time_t cursec
+ )
{
- char *bp;
- time_t cursec = time((time_t *) 0);
- struct tm *tm;
+ char * bp;
+ struct tm * tm;
tm = localtime(&cursec);
if (!tm)
- return "-- --- --:--:--";
+ return "--:--:--";
LIB_GETBUF(bp);
- (void) sprintf(bp, "%2d %s %02d:%02d:%02d",
- tm->tm_mday, months[tm->tm_mon],
- tm->tm_hour, tm->tm_min, tm->tm_sec);
+ snprintf(bp, LIB_BUFLENGTH, "%02d:%02d:%02d",
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
return bp;
}
diff --git a/contrib/ntp/libntp/icom.c b/contrib/ntp/libntp/icom.c
index 280667e..2e95db5 100644
--- a/contrib/ntp/libntp/icom.c
+++ b/contrib/ntp/libntp/icom.c
@@ -5,67 +5,98 @@
* distribution. The only function provided is to load the radio
* frequency. All other parameters must be manually set before use.
*/
-#include "icom.h"
+#include <config.h>
+#include <ntp_stdlib.h>
+#include <ntp_tty.h>
+#include <l_stdlib.h>
+#include <icom.h>
+
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
-#include "ntp_tty.h"
-#include "l_stdlib.h"
-/*
- * Scraps
- */
-#define BMAX 50 /* max command length */
-#define DICOM /dev/icom/ /* ICOM port link */
+#ifdef SYS_WINNT
+#undef write /* ports/winnt/include/config.h: #define write _write */
+extern int async_write(int, const void *, unsigned int);
+#define write(fd, data, octets) async_write(fd, data, octets)
+#endif
/*
- * FSA definitions
+ * Packet routines
+ *
+ * These routines send a packet and receive the response. If an error
+ * (collision) occurs on transmit, the packet is resent. If an error
+ * occurs on receive (timeout), all input to the terminating FI is
+ * discarded and the packet is resent. If the maximum number of retries
+ * is not exceeded, the program returns the number of octets in the user
+ * buffer; otherwise, it returns zero.
+ *
+ * ICOM frame format
+ *
+ * Frames begin with a two-octet preamble PR-PR followyd by the
+ * transceiver address RE, controller address TX, control code CN, zero
+ * or more data octets DA (depending on command), and terminator FI.
+ * Since the bus is bidirectional, every octet output is echoed on
+ * input. Every valid frame sent is answered with a frame in the same
+ * format, but with the RE and TX fields interchanged. The CN field is
+ * set to NAK if an error has occurred. Otherwise, the data are returned
+ * in this and following DA octets. If no data are returned, the CN
+ * octet is set to ACK.
+ *
+ * +------+------+------+------+------+--//--+------+
+ * | PR | PR | RE | TX | CN | DA | FI |
+ * +------+------+------+------+------+--//--+------+
*/
-#define S_IDLE 0 /* idle */
-#define S_HDR 1 /* header */
-#define S_TX 2 /* address */
-#define S_DATA 3 /* data */
-#define S_ERROR 4 /* error */
-
/*
- * Local function prototypes
+ * Scraps
*/
-static void doublefreq P((double, u_char *, int));
-static int sndpkt P((int, int, u_char *, u_char *));
-static int sndoctet P((int, int));
-static int rcvoctet P((int));
+#define DICOM /dev/icom/ /* ICOM port link */
/*
- * Local variables
+ * Local function prototypes
*/
-static int flags; /* trace flags */
-static int state; /* fsa state */
+static void doublefreq (double, u_char *, int);
/*
* icom_freq(fd, ident, freq) - load radio frequency
+ *
+ * returns:
+ * 0 (ok)
+ * -1 (error)
+ * 1 (short write to device)
*/
int
-icom_freq( /* returns 0 (ok), EIO (error) */
+icom_freq(
int fd, /* file descriptor */
int ident, /* ICOM radio identifier */
double freq /* frequency (MHz) */
)
{
- u_char cmd[BMAX], rsp[BMAX];
+ u_char cmd[] = {PAD, PR, PR, 0, TX, V_SFREQ, 0, 0, 0, 0, FI,
+ FI};
int temp;
- cmd[0] = V_SFREQ;
+ int rc;
+
+ cmd[3] = (char)ident;
if (ident == IC735)
temp = 4;
else
temp = 5;
- doublefreq(freq * 1e6, &cmd[1], temp);
- temp = sndpkt(fd, ident, cmd, rsp);
- if (temp < 1 || rsp[0] != ACK)
- return (EIO);
- return (0);
+ doublefreq(freq * 1e6, &cmd[6], temp);
+ rc = write(fd, cmd, temp + 7);
+ if (rc == -1) {
+ msyslog(LOG_ERR, "icom_freq: write() failed: %m");
+ return -1;
+ } else if (rc != temp + 7) {
+ msyslog(LOG_ERR, "icom_freq: only wrote %d of %d bytes.",
+ rc, temp+7);
+ return 1;
+ }
+
+ return 0;
}
@@ -80,10 +111,10 @@ doublefreq( /* returns void */
)
{
int i;
- char s1[11];
+ char s1[16];
char *y;
- sprintf(s1, " %10.0f", freq);
+ snprintf(s1, sizeof(s1), " %10.0f", freq);
y = s1 + 10;
i = 0;
while (*y != ' ') {
@@ -91,40 +122,13 @@ doublefreq( /* returns void */
x[i] = x[i] | ((*y-- & 0x0f) << 4);
i++;
}
- for (; i < len; i++)
+ for ( ; i < len; i++)
x[i] = 0;
x[i] = FI;
}
-
-/*
- * Packet routines
- *
- * These routines send a packet and receive the response. If an error
- * (collision) occurs on transmit, the packet is resent. If an error
- * occurs on receive (timeout), all input to the terminating FI is
- * discarded and the packet is resent. If the maximum number of retries
- * is not exceeded, the program returns the number of octets in the user
- * buffer; otherwise, it returns zero.
- *
- * ICOM frame format
- *
- * Frames begin with a two-octet preamble PR-PR followyd by the
- * transceiver address RE, controller address TX, control code CN, zero
- * or more data octets DA (depending on command), and terminator FI.
- * Since the bus is bidirectional, every octet output is echoed on
- * input. Every valid frame sent is answered with a frame in the same
- * format, but with the RE and TX fields interchanged. The CN field is
- * set to NAK if an error has occurred. Otherwise, the data are returned
- * in this and following DA octets. If no data are returned, the CN
- * octet is set to ACK.
- *
- * +------+------+------+------+------+--//--+------+
- * | PR | PR | RE | TX | CN | DA | FI |
- * +------+------+------+------+------+--//--+------+
- */
/*
- * icom_open() - open and initialize serial interface
+ * icom_init() - open and initialize serial interface
*
* This routine opens the serial interface for raw transmission; that
* is, character-at-a-time, no stripping, checking or monkeying with the
@@ -133,193 +137,42 @@ doublefreq( /* returns void */
*/
int
icom_init(
- char *device, /* device name/link */
+ const char *device, /* device name/link */
int speed, /* line speed */
int trace /* trace flags */ )
{
TTY ttyb;
int fd;
+ int rc;
+ int saved_errno;
- flags = trace;
- fd = open(device, O_RDWR, 0777);
+ fd = tty_open(device, O_RDWR, 0777);
if (fd < 0)
- return (fd);
-
- tcgetattr(fd, &ttyb);
+ return -1;
+
+ rc = tcgetattr(fd, &ttyb);
+ if (rc < 0) {
+ saved_errno = errno;
+ close(fd);
+ errno = saved_errno;
+ return -1;
+ }
ttyb.c_iflag = 0; /* input modes */
ttyb.c_oflag = 0; /* output modes */
- ttyb.c_cflag = IBAUD|CS8|CREAD|CLOCAL; /* control modes */
+ ttyb.c_cflag = IBAUD|CS8|CLOCAL; /* control modes (no read) */
ttyb.c_lflag = 0; /* local modes */
ttyb.c_cc[VMIN] = 0; /* min chars */
ttyb.c_cc[VTIME] = 5; /* receive timeout */
cfsetispeed(&ttyb, (u_int)speed);
cfsetospeed(&ttyb, (u_int)speed);
- tcsetattr(fd, TCSANOW, &ttyb);
- return (fd);
-}
-
-
-/*
- * sndpkt(r, x, y) - send packet and receive response
- *
- * This routine sends a command frame, which consists of all except the
- * preamble octets PR-PR. It then listens for the response frame and
- * returns the payload to the caller. The routine checks for correct
- * response header format; that is, the length of the response vector
- * returned to the caller must be at least 2 and the RE and TX octets
- * must be interchanged; otherwise, the operation is retried up to
- * the number of times specified in a global variable.
- *
- * The trace function, which is enabled by the P_TRACE bit of the global
- * flags variable, prints all characters received or echoed on the bus
- * preceded by a T (transmit) or R (receive). The P_ERMSG bit of the
- * flags variable enables printing of bus error messages.
- *
- * Note that the first octet sent is a PAD in order to allow time for
- * the radio to flush its receive buffer after sending the previous
- * response. Even with this precaution, some of the older radios
- * occasionally fail to receive a command and it has to be sent again.
- */
-static int
-sndpkt( /* returns octet count */
- int fd, /* file descriptor */
- int r, /* radio address */
- u_char *cmd, /* command vector */
- u_char *rsp /* response vector */
- )
-{
- int i, j, temp;
-
- (void)tcflush(fd, TCIOFLUSH);
- for (i = 0; i < RETRY; i++) {
- state = S_IDLE;
-
- /*
- * Transmit packet.
- */
- if (flags & P_TRACE)
- printf("icom T:");
- sndoctet(fd, PAD); /* send header */
- sndoctet(fd, PR);
- sndoctet(fd, PR);
- sndoctet(fd, r);
- sndoctet(fd, TX);
- for (j = 0; j < BMAX; j++) { /* send body */
- if (sndoctet(fd, cmd[j]) == FI)
- break;
- }
- while (rcvoctet(fd) != FI); /* purge echos */
- if (cmd[0] == V_FREQT || cmd[0] == V_MODET)
- return (0); /* shortcut for broadcast */
-
- /*
- * Receive packet. First, delete all characters
- * preceeding a PR, then discard all PRs. Check that the
- * RE and TX fields are correctly interchanged, then
- * copy the remaining data and FI to the user buffer.
- */
- if (flags & P_TRACE)
- printf("\nicom R:");
- j = 0;
- while ((temp = rcvoctet(fd)) != FI) {
- switch (state) {
-
- case S_IDLE:
- if (temp != PR)
- continue;
- state = S_HDR;
- break;
-
- case S_HDR:
- if (temp == PR) {
- continue;
- } else if (temp != TX) {
- if (flags & P_ERMSG)
- printf(
- "icom: TX error\n");
- state = S_ERROR;
- }
- state = S_TX;
- break;
-
- case S_TX:
- if (temp != r) {
- if (flags & P_ERMSG)
- printf(
- "icom: RE error\n");
- state = S_ERROR;
- }
- state = S_DATA;
- break;
-
- case S_DATA:
- if (j >= BMAX ) {
- if (flags & P_ERMSG)
- printf(
- "icom: buffer overrun\n");
- state = S_ERROR;
- j = 0;
- }
- rsp[j++] = (u_char)temp;
- break;
-
- case S_ERROR:
- break;
- }
- }
- if (flags & P_TRACE)
- printf("\n");
- if (j > 0) {
- rsp[j++] = FI;
- return (j);
- }
+ rc = tcsetattr(fd, TCSANOW, &ttyb);
+ if (rc < 0) {
+ saved_errno = errno;
+ close(fd);
+ errno = saved_errno;
+ return -1;
}
- if (flags & P_ERMSG)
- printf("icom: retries exceeded\n");
- return (0);
-}
-
-
-/*
- * Interface routines
- *
- * These routines read and write octets on the bus. In case of receive
- * timeout a FI code is returned. In case of output collision (echo
- * does not match octet sent), the remainder of the collision frame
- * (including the trailing FI) is discarded.
- */
-/*
- * sndoctet(fd, x) - send octet
- */
-static int
-sndoctet( /* returns octet */
- int fd, /* file descriptor */
- int x /* octet */
- )
-{
- u_char y;
-
- y = (u_char)x;
- write(fd, &y, 1);
- return (x);
-}
-
-
-/*
- * rcvoctet(fd) - receive octet
- */
-static int
-rcvoctet( /* returns octet */
- int fd /* file descriptor */
- )
-{
- u_char y;
-
- if (read(fd, &y, 1) < 1)
- y = FI; /* come here if timeout */
- if (flags & P_TRACE && y != PAD)
- printf(" %02x", y);
- return (y);
+ return (fd);
}
/* end program */
diff --git a/contrib/ntp/libntp/inttoa.c b/contrib/ntp/libntp/inttoa.c
deleted file mode 100644
index f270733..0000000
--- a/contrib/ntp/libntp/inttoa.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * inttoa - return an asciized signed integer
- */
-#include <stdio.h>
-
-#include "lib_strbuf.h"
-#include "ntp_stdlib.h"
-
-char *
-inttoa(
- long ival
- )
-{
- register char *buf;
-
- LIB_GETBUF(buf);
-
- (void) sprintf(buf, "%ld", (long)ival);
- return buf;
-}
diff --git a/contrib/ntp/libntp/iosignal.c b/contrib/ntp/libntp/iosignal.c
index 19a6e96..8749a23 100644
--- a/contrib/ntp/libntp/iosignal.c
+++ b/contrib/ntp/libntp/iosignal.c
@@ -45,7 +45,14 @@
#include "iosignal.h"
#if defined(HAVE_SIGNALED_IO)
+static RETSIGTYPE sigio_handler (int);
+
+/* consistency safegurad to catch BLOCK/UNBLOCK oversights */
static int sigio_block_count = 0;
+
+/* main inputhandler to be called on SIGIO */
+static input_handler_t *input_handler_callback = NULL;
+
# if defined(HAVE_SIGACTION)
/*
* If sigaction() is used for signal handling and a signal is
@@ -59,40 +66,11 @@ static int sigio_block_count = 0;
*/
static int sigio_handler_active = 0;
# endif
-extern void input_handler P((l_fp *));
/*
* SIGPOLL and SIGIO ROUTINES.
*/
- /*
- * Some systems (MOST) define SIGPOLL == SIGIO, others SIGIO == SIGPOLL, and
- * a few have separate SIGIO and SIGPOLL signals. This code checks for the
- * SIGIO == SIGPOLL case at compile time.
- * Do not define USE_SIGPOLL or USE_SIGIO.
- * these are interal only to iosignal.c!
- */
-# if defined(USE_SIGPOLL)
-# undef USE_SIGPOLL
-# endif
-# if defined(USE_SIGIO)
-# undef USE_SIGIO
-# endif
-
-# if defined(USE_TTY_SIGPOLL) || defined(USE_UDP_SIGPOLL)
-# define USE_SIGPOLL
-# endif
-
-# if !defined(USE_TTY_SIGPOLL) || !defined(USE_UDP_SIGPOLL)
-# define USE_SIGIO
-# endif
-
-# if defined(USE_SIGIO) && defined(USE_SIGPOLL)
-# if SIGIO == SIGPOLL
-# define USE_SIGIO
-# undef USE_SIGPOLL
-# endif /* SIGIO == SIGPOLL */
-# endif /* USE_SIGIO && USE_SIGIO */
/*
@@ -128,7 +106,7 @@ init_clock_sig(
pgrp = getpid();
if (ioctl(rio->fd, FIOSSAIOOWN, (char *)&pgrp) == -1)
{
- msyslog(LOG_ERR, "ioctl(FIOSSAIOOWN) fails for clock I/O: %m");
+ msyslog(LOG_ERR, "ioctl(FIOSSAIOOWN) fails for clock I/O: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
@@ -138,14 +116,14 @@ init_clock_sig(
*/
if (ioctl(rio->fd, FIOSNBIO, (char *)&on) == -1)
{
- msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails for clock I/O: %m");
+ msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails for clock I/O: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
if (ioctl(rio->fd, FIOSSAIOSTAT, (char *)&on) == -1)
{
- msyslog(LOG_ERR, "ioctl(FIOSSAIOSTAT) fails for clock I/O: %m");
+ msyslog(LOG_ERR, "ioctl(FIOSSAIOSTAT) fails for clock I/O: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
@@ -232,7 +210,7 @@ init_socket_sig(
if (ioctl(fd, I_SETSIG, S_INPUT) < 0)
{
msyslog(LOG_ERR,
- "init_socket_sig: ioctl(I_SETSIG, S_INPUT) failed: %m");
+ "init_socket_sig: ioctl(I_SETSIG, S_INPUT) failed: %m - EXITING");
exit(1);
}
}
@@ -246,7 +224,7 @@ init_socket_sig(
# if defined(FIOASYNC)
if (ioctl(fd, FIOASYNC, (char *)&on) == -1)
{
- msyslog(LOG_ERR, "ioctl(FIOASYNC) fails: %m");
+ msyslog(LOG_ERR, "ioctl(FIOASYNC) fails: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
@@ -256,13 +234,13 @@ init_socket_sig(
if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
{
- msyslog(LOG_ERR, "fcntl(F_GETFL) fails: %m");
+ msyslog(LOG_ERR, "fcntl(F_GETFL) fails: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
if (fcntl(fd, F_SETFL, flags|FASYNC) < 0)
{
- msyslog(LOG_ERR, "fcntl(...|FASYNC) fails: %m");
+ msyslog(LOG_ERR, "fcntl(...|FASYNC) fails: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
@@ -280,21 +258,21 @@ init_socket_sig(
# if defined(SIOCSPGRP)
if (ioctl(fd, SIOCSPGRP, (char *)&pgrp) == -1)
{
- msyslog(LOG_ERR, "ioctl(SIOCSPGRP) fails: %m");
+ msyslog(LOG_ERR, "ioctl(SIOCSPGRP) fails: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
# elif defined(FIOSETOWN)
if (ioctl(fd, FIOSETOWN, (char*)&pgrp) == -1)
{
- msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails: %m");
+ msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
# elif defined(F_SETOWN)
if (fcntl(fd, F_SETOWN, pgrp) == -1)
{
- msyslog(LOG_ERR, "fcntl(F_SETOWN) fails: %m");
+ msyslog(LOG_ERR, "fcntl(F_SETOWN) fails: %m - EXITING");
exit(1);
/*NOTREACHED*/
}
@@ -305,7 +283,7 @@ init_socket_sig(
# endif /* USE_UDP_SIGPOLL */
}
-RETSIGTYPE
+static RETSIGTYPE
sigio_handler(
int sig
)
@@ -321,7 +299,8 @@ sigio_handler(
msyslog(LOG_ERR, "sigio_handler: sigio_handler_active != 1");
# endif
- (void)input_handler(&ts);
+ INSIST(input_handler_callback != NULL);
+ (*input_handler_callback)(&ts);
# if defined(HAVE_SIGACTION)
sigio_handler_active--;
@@ -337,8 +316,13 @@ sigio_handler(
*/
# ifdef HAVE_SIGACTION
void
-set_signal(void)
+set_signal(input_handler_t *input)
{
+ INSIST(input != NULL);
+
+ input_handler_callback = input;
+
+ using_sigio = TRUE;
# ifdef USE_SIGIO
(void) signal_no_reset(SIGIO, sigio_handler);
# endif
@@ -507,8 +491,13 @@ block_sigio(void)
}
void
-set_signal(void)
+set_signal(input_handler_t *input)
{
+ INSIST(input != NULL);
+
+ input_handler_callback = input;
+
+ using_sigio = TRUE;
(void) signal_no_reset(SIGIO, sigio_handler);
}
diff --git a/contrib/ntp/libntp/lib_strbuf.c b/contrib/ntp/libntp/lib_strbuf.c
index 315070f..76f7016 100644
--- a/contrib/ntp/libntp/lib_strbuf.c
+++ b/contrib/ntp/libntp/lib_strbuf.c
@@ -1,16 +1,28 @@
/*
* lib_strbuf - library string storage
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <isc/net.h>
+#include <isc/result.h>
+
+#include "ntp_fp.h"
#include "ntp_stdlib.h"
#include "lib_strbuf.h"
+
/*
* Storage declarations
*/
-char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH];
-int lib_nextbuf;
-int lib_inited = 0;
+int debug;
+libbufstr lib_stringbuf[LIB_NUMBUF];
+int lib_nextbuf;
+int ipv4_works;
+int ipv6_works;
+int lib_inited;
+
/*
* initialization routine. Might be needed if the code is ROMized.
@@ -18,6 +30,10 @@ int lib_inited = 0;
void
init_lib(void)
{
- lib_nextbuf = 0;
- lib_inited = 1;
+ if (lib_inited)
+ return;
+ ipv4_works = (ISC_R_SUCCESS == isc_net_probeipv4());
+ ipv6_works = (ISC_R_SUCCESS == isc_net_probeipv6());
+ init_systime();
+ lib_inited = TRUE;
}
diff --git a/contrib/ntp/libntp/lib_strbuf.h b/contrib/ntp/libntp/lib_strbuf.h
deleted file mode 100644
index 5aa0eb0..0000000
--- a/contrib/ntp/libntp/lib_strbuf.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * lib_strbuf.h - definitions for routines which use the common string buffers
- */
-
-#include <ntp_types.h>
-
-/*
- * Sizes of things
- */
-#define LIB_NUMBUFS 200
-#define LIB_BUFLENGTH 80
-
-/*
- * Macro to get a pointer to the next buffer
- */
-#define LIB_GETBUF(buf) \
- do { \
- if (!lib_inited) \
- init_lib(); \
- buf = &lib_stringbuf[lib_nextbuf][0]; \
- if (++lib_nextbuf >= LIB_NUMBUFS) \
- lib_nextbuf = 0; \
- memset(buf, 0, LIB_BUFLENGTH); \
- } while (0)
-
-extern char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH];
-extern int lib_nextbuf;
-extern int lib_inited;
diff --git a/contrib/ntp/libntp/machines.c b/contrib/ntp/libntp/machines.c
index c8e4e07..7a29ac0 100644
--- a/contrib/ntp/libntp/machines.c
+++ b/contrib/ntp/libntp/machines.c
@@ -8,10 +8,13 @@
#include "config.h"
#endif
+#include "ntp.h"
#include "ntp_machine.h"
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
#include "ntp_unixtime.h"
+#include "lib_strbuf.h"
+#include "ntp_debug.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -37,7 +40,7 @@ struct hostent *gethostbyname(char *name)
{
struct hostent *host1;
h_errno = 0; /* we are always successful!!! */
- host1 = (struct hostent *) malloc (sizeof(struct hostent));
+ host1 = (struct hostent *) emalloc (sizeof(struct hostent));
host1->h_name = name;
host1->h_addrtype = AF_INET;
host1->h_aliases = name;
@@ -51,7 +54,7 @@ struct hostent *gethostbyaddr(char *name, int size, int addr_type)
{
struct hostent *host1;
h_errno = 0; /* we are always successful!!! */
- host1 = (struct hostent *) malloc (sizeof(struct hostent));
+ host1 = (struct hostent *) emalloc (sizeof(struct hostent));
host1->h_name = name;
host1->h_addrtype = AF_INET;
host1->h_aliases = name;
@@ -63,7 +66,7 @@ struct hostent *gethostbyaddr(char *name, int size, int addr_type)
struct servent *getservbyname (char *name, char *type)
{
struct servent *serv1;
- serv1 = (struct servent *) malloc (sizeof(struct servent));
+ serv1 = (struct servent *) emalloc (sizeof(struct servent));
serv1->s_name = "ntp"; /* official service name */
serv1->s_aliases = NULL; /* alias list */
serv1->s_port = 123; /* port # */
@@ -409,7 +412,20 @@ return 0;
}
#endif /* MPE */
-const char *set_tod_using = "UNKNOWN";
+#define SET_TOD_UNDETERMINED 0
+#define SET_TOD_CLOCK_SETTIME 1
+#define SET_TOD_SETTIMEOFDAY 2
+#define SET_TOD_STIME 3
+
+const char * const set_tod_used[] = {
+ "undetermined",
+ "clock_settime",
+ "settimeofday",
+ "stime"
+};
+
+pset_tod_using set_tod_using = NULL;
+
int
ntp_set_tod(
@@ -417,37 +433,35 @@ ntp_set_tod(
void *tzp
)
{
- int rc = -1;
+ static int tod;
+ int rc;
+ int saved_errno;
-#ifdef DEBUG
- if (debug)
- printf("In ntp_set_tod\n");
-#endif
+ TRACE(1, ("In ntp_set_tod\n"));
+ rc = -1;
+ saved_errno = 0;
#ifdef HAVE_CLOCK_SETTIME
- if (rc) {
+ if (rc && (SET_TOD_CLOCK_SETTIME == tod || !tod)) {
struct timespec ts;
- set_tod_using = "clock_settime";
/* Convert timeval to timespec */
ts.tv_sec = tvp->tv_sec;
ts.tv_nsec = 1000 * tvp->tv_usec;
errno = 0;
rc = clock_settime(CLOCK_REALTIME, &ts);
-#ifdef DEBUG
- if (debug) {
- printf("ntp_set_tod: %s: %d: %s\n",
- set_tod_using, rc, strerror(errno));
- }
-#endif
+ saved_errno = errno;
+ TRACE(1, ("ntp_set_tod: clock_settime: %d %m\n", rc));
+ if (!tod && !rc)
+ tod = SET_TOD_CLOCK_SETTIME;
+
}
#endif /* HAVE_CLOCK_SETTIME */
#ifdef HAVE_SETTIMEOFDAY
- if (rc) {
+ if (rc && (SET_TOD_SETTIMEOFDAY == tod || !tod)) {
struct timeval adjtv;
- set_tod_using = "settimeofday";
/*
* Some broken systems don't reset adjtime() when the
* clock is stepped.
@@ -456,37 +470,39 @@ ntp_set_tod(
adjtime(&adjtv, NULL);
errno = 0;
rc = SETTIMEOFDAY(tvp, tzp);
-#ifdef DEBUG
- if (debug) {
- printf("ntp_set_tod: %s: %d: %s\n",
- set_tod_using, rc, strerror(errno));
- }
-#endif
+ saved_errno = errno;
+ TRACE(1, ("ntp_set_tod: settimeofday: %d %m\n", rc));
+ if (!tod && !rc)
+ tod = SET_TOD_SETTIMEOFDAY;
}
#endif /* HAVE_SETTIMEOFDAY */
#ifdef HAVE_STIME
- if (rc) {
+ if (rc && (SET_TOD_STIME == tod || !tod)) {
long tp = tvp->tv_sec;
- set_tod_using = "stime";
errno = 0;
rc = stime(&tp); /* lie as bad as SysVR4 */
-#ifdef DEBUG
- if (debug) {
- printf("ntp_set_tod: %s: %d: %s\n",
- set_tod_using, rc, strerror(errno));
- }
-#endif
+ saved_errno = errno;
+ TRACE(1, ("ntp_set_tod: stime: %d %m\n", rc));
+ if (!tod && !rc)
+ tod = SET_TOD_STIME;
}
#endif /* HAVE_STIME */
- if (rc)
- set_tod_using = "Failed!";
-#ifdef DEBUG
- if (debug) {
- printf("ntp_set_tod: Final result: %s: %d: %s\n",
- set_tod_using, rc, strerror(errno));
+
+ errno = saved_errno; /* for %m below */
+ TRACE(1, ("ntp_set_tod: Final result: %s: %d %m\n",
+ set_tod_used[tod], rc));
+ /*
+ * Say how we're setting the time of day
+ */
+ if (!rc && NULL != set_tod_using) {
+ (*set_tod_using)(set_tod_used[tod]);
+ set_tod_using = NULL;
}
-#endif
+
+ if (rc)
+ errno = saved_errno;
+
return rc;
}
@@ -509,19 +525,9 @@ getpass(const char * prompt)
}
password[i] = '\0';
+ fputc('\n', stderr);
+ fflush(stderr);
+
return password;
}
#endif /* SYS_WINNT */
-
-#if !defined(HAVE_MEMSET)
-void
-ntp_memset(
- char *a,
- int x,
- int c
- )
-{
- while (c-- > 0)
- *a++ = (char) x;
-}
-#endif /*POSIX*/
diff --git a/contrib/ntp/libntp/md5c.c b/contrib/ntp/libntp/md5c.c
deleted file mode 100644
index 07eec6c..0000000
--- a/contrib/ntp/libntp/md5c.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- rights reserved.
-
- License to copy and use this software is granted provided that it
- is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- Algorithm" in all material mentioning or referencing this software
- or this function.
-
- License is also granted to make and use derivative works provided
- that such works are identified as "derived from the RSA Data
- Security, Inc. MD5 Message-Digest Algorithm" in all material
- mentioning or referencing the derived work.
-
- RSA Data Security, Inc. makes no representations concerning either
- the merchantability of this software or the suitability of this
- software for any particular purpose. It is provided "as is"
- without express or implied warranty of any kind.
-
- These notices must be retained in any copies of any part of this
- documentation and/or software.
- */
-
-#include "global.h"
-#ifndef HAVE_MD5INIT
-#include "ntp_md5.h"
-
-/* Constants for MD5Transform routine.
- */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, unsigned char *, unsigned int));
-static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
-static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
-
-static unsigned char PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* F, G, H and I are basic MD5 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-/* ROTATE_LEFT rotates x left n bits.
- */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
- Rotation is separate from addition to prevent recomputation.
- */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-/* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
-void
-MD5Init(
- MD5_CTX *context /* context */
- )
-{
- context->count[0] = context->count[1] = 0;
-
- /* Load magic initialization constants.
- */
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
-}
-
-/* MD5 block update operation. Continues an MD5 message-digest
- operation, processing another message block, and updating the
- context.
- */
-void
-MD5Update (
- MD5_CTX *context, /* context */
- unsigned char *input, /* input block */
- unsigned int inputLen /* length of input block */
- )
-{
- unsigned int i, idx, partLen;
-
- /* Compute number of bytes mod 64 */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
-
- partLen = 64 - idx;
-
- /* Transform as many times as possible.
- */
- if (inputLen >= partLen) {
- MD5_memcpy
- ((POINTER)&context->buffer[idx], (POINTER)input, partLen);
- MD5Transform (context->state, context->buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, &input[i]);
-
- idx = 0;
- }
- else
- i = 0;
-
- /* Buffer remaining input */
- MD5_memcpy
- ((POINTER)&context->buffer[idx], (POINTER)&input[i],
- inputLen-i);
-}
-
-/* MD5 finalization. Ends an MD5 message-digest operation, writing the
- the message digest and zeroizing the context.
- */
-void
-MD5Final (
- unsigned char digest[16], /* message digest */
- MD5_CTX *context /* context */
- )
-{
- unsigned char bits[8];
- unsigned int idx, padLen;
-
- /* Save number of bits */
- Encode (bits, context->count, 8);
-
- /* Pad out to 56 mod 64.
- */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (idx < 56) ? (56 - idx) : (120 - idx);
- MD5Update (context, PADDING, padLen);
-
- /* Append length (before padding) */
- MD5Update (context, bits, 8);
-
- /* Store state in digest */
- Encode (digest, context->state, 16);
-
- /* Zeroize sensitive information.
- */
- MD5_memset ((POINTER)context, 0, sizeof (*context));
-}
-
-/* MD5 basic transformation. Transforms state based on block.
- */
-static void
-MD5Transform (
- UINT4 state[4],
- unsigned char block[64]
- )
-{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information.
- */
- MD5_memset ((POINTER)x, 0, sizeof (x));
-}
-
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
- */
-static void
-Encode (
- unsigned char *output,
- UINT4 *input,
- unsigned int len
- )
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
-}
-
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
- */
-static void
-Decode (
- UINT4 *output,
- unsigned char *input,
- unsigned int len
- )
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
- (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
-}
-
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
-static void
-MD5_memcpy (
- POINTER output,
- POINTER input,
- unsigned int len
- )
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- output[i] = input[i];
-}
-
-/* Note: Replace "for loop" with standard memset if possible.
- */
-static void
-MD5_memset (
- POINTER output,
- int value,
- unsigned int len
- )
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *)output)[i] = (char)value;
-}
-#else
-int md5_bs;
-#endif
diff --git a/contrib/ntp/libntp/memmove.c b/contrib/ntp/libntp/memmove.c
deleted file mode 100644
index 8ccc4b1..0000000
--- a/contrib/ntp/libntp/memmove.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifndef HAVE_MEMMOVE
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#include <string.h>
-
-#include "l_stdlib.h"
-
-/*
- * sizeof(word) MUST BE A POWER OF TWO
- * SO THAT wmask BELOW IS ALL ONES
- */
-typedef int word; /* "word" used for optimal copy speed */
-
-#define wsize sizeof(word)
-#define wmask (wsize - 1)
-
-/*
- * Copy a block of memory, handling overlap.
- * This is the routine that actually implements
- * (the portable versions of) bcopy, memcpy, and memmove.
- */
-void *
-memmove(
- void *dst0,
- const void *src0,
- register size_t length
- )
-{
- register char *dst = dst0;
- register const char *src = src0;
- register size_t t;
-
- if (length == 0 || dst == src) /* nothing to do */
- goto done;
-
- /*
- * Macros: loop-t-times; and loop-t-times, t>0
- */
-#define TLOOP(s) if (t) TLOOP1(s)
-#define TLOOP1(s) do { s; } while (--t)
-
- if ((unsigned long)dst < (unsigned long)src) {
- /*
- * Copy forward.
- */
- t = (int)src; /* only need low bits */
- if ((t | (int)dst) & wmask) {
- /*
- * Try to align operands. This cannot be done
- * unless the low bits match.
- */
- if ((t ^ (int)dst) & wmask || length < wsize)
- t = length;
- else
- t = wsize - (t & wmask);
- length -= t;
- TLOOP1(*dst++ = *src++);
- }
- /*
- * Copy whole words, then mop up any trailing bytes.
- */
- t = length / wsize;
- TLOOP(*(word *)dst = *(const word *)src; src += wsize;
- dst += wsize);
- t = length & wmask;
- TLOOP(*dst++ = *src++);
- } else {
- /*
- * Copy backwards. Otherwise essentially the same.
- * Alignment works as before, except that it takes
- * (t&wmask) bytes to align, not wsize-(t&wmask).
- */
- src += length;
- dst += length;
- t = (int)src;
- if ((t | (int)dst) & wmask) {
- if ((t ^ (int)dst) & wmask || length <= wsize)
- t = length;
- else
- t &= wmask;
- length -= t;
- TLOOP1(*--dst = *--src);
- }
- t = length / wsize;
- TLOOP(src -= wsize; dst -= wsize;
- *(word *)dst = *(const word *)src);
- t = length & wmask;
- TLOOP(*--dst = *--src);
- }
- done:
- return (dst0);
-}
-#else
-int memmove_bs;
-#endif
diff --git a/contrib/ntp/libntp/mfptoa.c b/contrib/ntp/libntp/mfptoa.c
deleted file mode 100644
index 6450b2c..0000000
--- a/contrib/ntp/libntp/mfptoa.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * mfptoa - Return an asciized representation of a signed long fp number
- */
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-
-char *
-mfptoa(
- u_long fpi,
- u_long fpf,
- short ndec
- )
-{
- int isneg;
-
- if (M_ISNEG(fpi, fpf)) {
- isneg = 1;
- M_NEG(fpi, fpf);
- } else
- isneg = 0;
-
- return dolfptoa(fpi, fpf, isneg, ndec, 0);
-}
diff --git a/contrib/ntp/libntp/mfptoms.c b/contrib/ntp/libntp/mfptoms.c
deleted file mode 100644
index d2bfd71..0000000
--- a/contrib/ntp/libntp/mfptoms.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * mfptoms - Return an asciized signed long fp number in milliseconds
- */
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-
-char *
-mfptoms(
- u_long fpi,
- u_long fpf,
- short ndec
- )
-{
- int isneg;
-
- if (M_ISNEG(fpi, fpf)) {
- isneg = 1;
- M_NEG(fpi, fpf);
- } else
- isneg = 0;
-
- return dolfptoa(fpi, fpf, isneg, ndec, 1);
-}
diff --git a/contrib/ntp/libntp/mktime.c b/contrib/ntp/libntp/mktime.c
index 91be600..50d2a08 100644
--- a/contrib/ntp/libntp/mktime.c
+++ b/contrib/ntp/libntp/mktime.c
@@ -59,9 +59,14 @@
* by hand. Sorry about that.
*/
+#include <config.h>
#include "ntp_machine.h"
-#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM)
+#if !defined(HAVE_MKTIME) || ( !defined(HAVE_TIMEGM) && defined(WANT_TIMEGM) )
+
+#if SIZEOF_TIME_T >= 8
+#error libntp supplied mktime()/timegm() do not support 64-bit time_t
+#endif
#ifndef DSTMINUTES
#define DSTMINUTES 60
@@ -226,9 +231,9 @@ time2(
t = (t < 0) ? 0 : ((time_t) 1 << bits);
for ( ; ; ) {
if (usezn)
- mytm = *localtime(&t);
+ mytm = *localtime(&t);
else
- mytm = *gmtime(&t);
+ mytm = *gmtime(&t);
dir = tmcomp(&mytm, &yourtm);
if (dir != 0) {
if (bits-- < 0)
@@ -284,6 +289,7 @@ mktime(
}
#endif /* !HAVE_MKTIME */
+#ifdef WANT_TIMEGM
#ifndef HAVE_TIMEGM
time_t
timegm(
@@ -301,3 +307,4 @@ timegm(
return WRONG;
}
#endif /* !HAVE_TIMEGM */
+#endif /* WANT_TIMEGM */
diff --git a/contrib/ntp/libntp/modetoa.c b/contrib/ntp/libntp/modetoa.c
index 405aef8..6f13d20 100644
--- a/contrib/ntp/libntp/modetoa.c
+++ b/contrib/ntp/libntp/modetoa.c
@@ -1,6 +1,7 @@
/*
* modetoa - return an asciized mode
*/
+#include <config.h>
#include <stdio.h>
#include "lib_strbuf.h"
@@ -8,11 +9,11 @@
const char *
modetoa(
- int mode
+ size_t mode
)
{
char *bp;
- static const char *modestrings[] = {
+ static const char * const modestrings[] = {
"unspec",
"sym_active",
"sym_passive",
@@ -24,9 +25,9 @@ modetoa(
"bclient",
};
- if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
+ if (mode >= COUNTOF(modestrings)) {
LIB_GETBUF(bp);
- (void)sprintf(bp, "mode#%d", mode);
+ snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode);
return bp;
}
diff --git a/contrib/ntp/libntp/mstolfp.c b/contrib/ntp/libntp/mstolfp.c
index e4e909d..828b14c 100644
--- a/contrib/ntp/libntp/mstolfp.c
+++ b/contrib/ntp/libntp/mstolfp.c
@@ -1,6 +1,7 @@
/*
* mstolfp - convert an ascii string in milliseconds to an l_fp number
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
@@ -31,7 +32,7 @@ mstolfp(
*/
bp = buf;
cp = str;
- while (isspace((int)*cp))
+ while (isspace((unsigned char)*cp))
cp++;
if (*cp == '-') {
@@ -39,7 +40,7 @@ mstolfp(
cp++;
}
- if (*cp != '.' && !isdigit((int)*cp))
+ if (*cp != '.' && !isdigit((unsigned char)*cp))
return 0;
@@ -47,7 +48,7 @@ mstolfp(
* Search forward for the decimal point or the end of the string.
*/
cpdec = cp;
- while (isdigit((int)*cpdec))
+ while (isdigit((unsigned char)*cpdec))
cpdec++;
/*
@@ -85,7 +86,7 @@ mstolfp(
if (*cp == '.') {
cp++;
- while (isdigit((int)*cp))
+ while (isdigit((unsigned char)*cp))
*bp++ = (char)*cp++;
}
*bp = '\0';
@@ -94,7 +95,7 @@ mstolfp(
* Check to make sure the string is properly terminated. If
* so, give the buffer to the decoding routine.
*/
- if (*cp != '\0' && !isspace((int)*cp))
+ if (*cp != '\0' && !isspace((unsigned char)*cp))
return 0;
return atolfp(buf, lfp);
}
diff --git a/contrib/ntp/libntp/msutotsf.c b/contrib/ntp/libntp/msutotsf.c
deleted file mode 100644
index eb3babe..0000000
--- a/contrib/ntp/libntp/msutotsf.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * msutotsf - tables for converting from a subsecond millisecond value
- * to a time stamp fraction.
- */
-#include <sys/types.h>
-
-#include "ntp_types.h"
-
-/*
- * Index each of these tables with five bits of the (less than) 10
- * bit millisecond value. Note that the tables are rounded (not
- * truncated). The error in the result will thus be +-1 low order
- * bit in the time stamp fraction.
- */
-u_long msutotsflo[32] = {
- 0x00000000, 0x00418937, 0x0083126f, 0x00c49ba6,
- 0x010624dd, 0x0147ae14, 0x0189374c, 0x01cac083,
- 0x020c49ba, 0x024dd2f2, 0x028f5c29, 0x02d0e560,
- 0x03126e98, 0x0353f7cf, 0x03958106, 0x03d70a3d,
- 0x04189375, 0x045a1cac, 0x049ba5e3, 0x04dd2f1b,
- 0x051eb852, 0x05604189, 0x05a1cac1, 0x05e353f8,
- 0x0624dd2f, 0x06666666, 0x06a7ef9e, 0x06e978d5,
- 0x072b020c, 0x076c8b44, 0x07ae147b, 0x07ef9db2
-};
-
-u_long msutotsfhi[32] = {
- 0x00000000, 0x083126e9, 0x10624dd3, 0x189374bc,
- 0x20c49ba6, 0x28f5c28f, 0x3126e979, 0x39581062,
- 0x4189374c, 0x49ba5e35, 0x51eb851f, 0x5a1cac08,
- 0x624dd2f2, 0x6a7ef9db, 0x72b020c5, 0x7ae147ae,
- 0x83126e98, 0x8b439581, 0x9374bc6a, 0x9ba5e354,
- 0xa3d70a3d, 0xac083127, 0xb4395810, 0xbc6a7efa,
- 0xc49ba5e3, 0xcccccccd, 0xd4fdf3b6, 0xdd2f1aa0,
- 0xe5604189, 0xed916873, 0xf5c28f5c, 0xfdf3b646
-};
diff --git a/contrib/ntp/libntp/msyslog.c b/contrib/ntp/libntp/msyslog.c
index fe4d979..cc8868f 100644
--- a/contrib/ntp/libntp/msyslog.c
+++ b/contrib/ntp/libntp/msyslog.c
@@ -9,198 +9,576 @@
# include <config.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-
#include <stdio.h>
-#include "ntp_types.h"
#include "ntp_string.h"
+#include "ntp.h"
+#include "ntp_debug.h"
#include "ntp_syslog.h"
-#include "ntp_stdlib.h"
#ifdef SYS_WINNT
# include <stdarg.h>
# include "..\ports\winnt\libntp\messages.h"
#endif
-int syslogit = 1;
-FILE *syslog_file = NULL;
+int syslogit = TRUE;
+int msyslog_term = FALSE; /* duplicate to stdout/err */
+int msyslog_term_pid = TRUE;
+int msyslog_include_timestamp = TRUE;
+FILE * syslog_file;
+char * syslog_fname;
+char * syslog_abs_fname;
-u_long ntp_syslogmask = ~ (u_long) 0;
+/* libntp default ntp_syslogmask is all bits lit */
+#define INIT_NTP_SYSLOGMASK ~(u_int32)0
+u_int32 ntp_syslogmask = INIT_NTP_SYSLOGMASK;
-#ifdef SYS_WINNT
-static char separator = '\\';
-#else
-static char separator = '/';
-#endif /* SYS_WINNT */
-extern char *progname;
+extern char const * progname;
/* Declare the local functions */
-void addto_syslog P((int, char *));
-void format_errmsg P((char *, int, const char *, int));
-
-
-/*
- * This routine adds the contents of a buffer to the log
- */
-void
-addto_syslog(int level, char * buf)
-{
- char *prog;
- FILE *out_file = syslog_file;
+void addto_syslog (int, const char *);
+#ifndef VSNPRINTF_PERCENT_M
+void format_errmsg (char *, size_t, const char *, int);
-#if !defined(VMS) && !defined (SYS_VXWORKS)
- if (syslogit)
- syslog(level, "%s", buf);
- else
-#endif /* VMS && SYS_VXWORKS*/
- {
- out_file = syslog_file ? syslog_file: level <= LOG_ERR ? stderr : stdout;
- /* syslog() provides the timestamp, so if we're not using
- syslog, we must provide it. */
- prog = strrchr(progname, separator);
- if (prog == NULL)
- prog = progname;
- else
- prog++;
- (void) fprintf(out_file, "%s ", humanlogtime ());
- (void) fprintf(out_file, "%s[%d]: %s", prog, (int)getpid(), buf);
- fflush (out_file);
- }
-#if DEBUG
- if (debug && out_file != stdout && out_file != stderr)
- printf("addto_syslog: %s\n", buf);
-#endif
-}
+/* format_errmsg() is under #ifndef VSNPRINTF_PERCENT_M above */
void
-format_errmsg(char *nfmt, int lennfmt, const char *fmt, int errval)
+format_errmsg(
+ char * nfmt,
+ size_t lennfmt,
+ const char * fmt,
+ int errval
+ )
{
- register char c;
- register char *n;
- register const char *f;
-
- char *err;
+ char errmsg[256];
+ char c;
+ char *n;
+ const char *f;
+ size_t len;
n = nfmt;
f = fmt;
- while ((c = *f++) != '\0' && n < (nfmt+lennfmt - 2)) {
+ while ((c = *f++) != '\0' && n < (nfmt + lennfmt - 1)) {
if (c != '%') {
*n++ = c;
continue;
}
if ((c = *f++) != 'm') {
*n++ = '%';
+ if ('\0' == c)
+ break;
*n++ = c;
continue;
}
- err = 0;
- err = strerror(errval);
+ errno_to_str(errval, errmsg, sizeof(errmsg));
+ len = strlen(errmsg);
+
/* Make sure we have enough space for the error message */
- if ((n + strlen(err)) < (nfmt + lennfmt -2)) {
- strcpy(n, err);
- n += strlen(err);
+ if ((n + len) < (nfmt + lennfmt - 1)) {
+ memcpy(n, errmsg, len);
+ n += len;
}
}
-#if !defined(VMS)
- if (!syslogit)
-#endif /* VMS */
- *n++ = '\n';
*n = '\0';
}
+#endif /* VSNPRINTF_PERCENT_M */
+
/*
- * The externally called functions are defined here
- * but share the internal function above to fetch
- * any error message strings, This is done so that we can
- * have two different functions to perform the logging
- * since Windows gets it's error information from different
- * places depending on whether or not it's network I/O.
- * msyslog() is for general use while netsyslog() is for
- * network I/O functions. They are virtually identical
- * in implementation.
+ * errno_to_str() - a thread-safe strerror() replacement.
+ * Hides the varied signatures of strerror_r().
+ * For Windows, we have:
+ * #define errno_to_str isc_strerror
*/
+#ifndef errno_to_str
+void
+errno_to_str(
+ int err,
+ char * buf,
+ size_t bufsiz
+ )
+{
+# if defined(STRERROR_R_CHAR_P) || !HAVE_DECL_STRERROR_R
+ char * pstatic;
+
+ buf[0] = '\0';
+# ifdef STRERROR_R_CHAR_P
+ pstatic = strerror_r(err, buf, bufsiz);
+# else
+ pstatic = strerror(err);
+# endif
+ if (NULL == pstatic && '\0' == buf[0])
+ snprintf(buf, bufsiz, "%s(%d): errno %d",
+# ifdef STRERROR_R_CHAR_P
+ "strerror_r",
+# else
+ "strerror",
+# endif
+ err, errno);
+ /* protect against believing an int return is a pointer */
+ else if (pstatic != buf && pstatic > (char *)bufsiz)
+ strlcpy(buf, pstatic, bufsiz);
+# else
+ int rc;
+
+ rc = strerror_r(err, buf, bufsiz);
+ if (rc < 0)
+ snprintf(buf, bufsiz, "strerror_r(%d): errno %d",
+ err, errno);
+# endif
+}
+#endif /* errno_to_str */
+
+
+/*
+ * addto_syslog()
+ * This routine adds the contents of a buffer to the syslog or an
+ * application-specific logfile.
+ */
+void
+addto_syslog(
+ int level,
+ const char * msg
+ )
+{
+ static char const * prevcall_progname;
+ static char const * prog;
+ const char nl[] = "\n";
+ const char empty[] = "";
+ FILE * term_file;
+ int log_to_term;
+ int log_to_file;
+ int pid;
+ const char * nl_or_empty;
+ const char * human_time;
+
+ /* setup program basename static var prog if needed */
+ if (progname != prevcall_progname) {
+ prevcall_progname = progname;
+ prog = strrchr(progname, DIR_SEP);
+ if (prog != NULL)
+ prog++;
+ else
+ prog = progname;
+ }
+
+ log_to_term = msyslog_term;
+ log_to_file = FALSE;
+#if !defined(VMS) && !defined(SYS_VXWORKS)
+ if (syslogit)
+ syslog(level, "%s", msg);
+ else
+#endif
+ if (syslog_file != NULL)
+ log_to_file = TRUE;
+ else
+ log_to_term = TRUE;
+#if DEBUG
+ if (debug > 0)
+ log_to_term = TRUE;
+#endif
+ if (!(log_to_file || log_to_term))
+ return;
+
+ /* syslog() adds the timestamp, name, and pid */
+ if (msyslog_include_timestamp)
+ human_time = humanlogtime();
+ else /* suppress gcc pot. uninit. warning */
+ human_time = NULL;
+ if (msyslog_term_pid || log_to_file)
+ pid = getpid();
+ else /* suppress gcc pot. uninit. warning */
+ pid = -1;
+
+ /* syslog() adds trailing \n if not present */
+ if ('\n' != msg[strlen(msg) - 1])
+ nl_or_empty = nl;
+ else
+ nl_or_empty = empty;
+
+ if (log_to_term) {
+ term_file = (level <= LOG_ERR)
+ ? stderr
+ : stdout;
+ if (msyslog_include_timestamp)
+ fprintf(term_file, "%s ", human_time);
+ if (msyslog_term_pid)
+ fprintf(term_file, "%s[%d]: ", prog, pid);
+ fprintf(term_file, "%s%s", msg, nl_or_empty);
+ fflush(term_file);
+ }
+
+ if (log_to_file) {
+ if (msyslog_include_timestamp)
+ fprintf(syslog_file, "%s ", human_time);
+ fprintf(syslog_file, "%s[%d]: %s%s", prog, pid, msg,
+ nl_or_empty);
+ fflush(syslog_file);
+ }
+}
+
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
-void msyslog(int level, const char *fmt, ...)
-#else /* defined(__STDC__) || defined(HAVE_STDARG_H) */
- /*VARARGS*/
- void msyslog(va_alist)
- va_dcl
-#endif /* defined(__STDC__) || defined(HAVE_STDARG_H) */
+int
+mvsnprintf(
+ char * buf,
+ size_t bufsiz,
+ const char * fmt,
+ va_list ap
+ )
{
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
+#ifndef VSNPRINTF_PERCENT_M
+ char nfmt[256];
#else
- int level;
- const char *fmt;
+ const char * nfmt = fmt;
#endif
- va_list ap;
- char buf[1025], nfmt[256];
+ int errval;
/*
* Save the error value as soon as possible
*/
#ifdef SYS_WINNT
- int errval = GetLastError();
-#else
- int errval = errno;
-#endif
+ errval = GetLastError();
+ if (NO_ERROR == errval)
+#endif /* SYS_WINNT */
+ errval = errno;
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
- va_start(ap, fmt);
+#ifndef VSNPRINTF_PERCENT_M
+ format_errmsg(nfmt, sizeof(nfmt), fmt, errval);
#else
- va_start(ap);
-
- level = va_arg(ap, int);
- fmt = va_arg(ap, char *);
+ errno = errval;
#endif
- format_errmsg(nfmt, sizeof(nfmt), fmt, errval);
-
- vsnprintf(buf, sizeof(buf), nfmt, ap);
- addto_syslog(level, buf);
- va_end(ap);
+ return vsnprintf(buf, bufsiz, nfmt, ap);
}
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
-void netsyslog(int level, const char *fmt, ...)
-#else /* defined(__STDC__) || defined(HAVE_STDARG_H) */
- /*VARARGS*/
- void netsyslog(va_alist)
- va_dcl
-#endif /* defined(__STDC__) || defined(HAVE_STDARG_H) */
+
+
+int
+mvfprintf(
+ FILE * fp,
+ const char * fmt,
+ va_list ap
+ )
{
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
+#ifndef VSNPRINTF_PERCENT_M
+ char nfmt[256];
#else
- int level;
- const char *fmt;
+ const char * nfmt = fmt;
#endif
- va_list ap;
- char buf[1025], nfmt[256];
+ int errval;
/*
* Save the error value as soon as possible
*/
#ifdef SYS_WINNT
- int errval = WSAGetLastError();
+ errval = GetLastError();
+ if (NO_ERROR == errval)
+#endif /* SYS_WINNT */
+ errval = errno;
+
+#ifndef VSNPRINTF_PERCENT_M
+ format_errmsg(nfmt, sizeof(nfmt), fmt, errval);
#else
- int errval = errno;
+ errno = errval;
#endif
+ return vfprintf(fp, nfmt, ap);
+}
+
+
+int
+mfprintf(
+ FILE * fp,
+ const char * fmt,
+ ...
+ )
+{
+ va_list ap;
+ int rc;
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
va_start(ap, fmt);
-#else
- va_start(ap);
+ rc = mvfprintf(fp, fmt, ap);
+ va_end(ap);
- level = va_arg(ap, int);
- fmt = va_arg(ap, char *);
-#endif
- format_errmsg(nfmt, sizeof(nfmt), fmt, errval);
+ return rc;
+}
- vsnprintf(buf, sizeof(buf), nfmt, ap);
- addto_syslog(level, buf);
+
+int
+mprintf(
+ const char * fmt,
+ ...
+ )
+{
+ va_list ap;
+ int rc;
+
+ va_start(ap, fmt);
+ rc = mvfprintf(stdout, fmt, ap);
+ va_end(ap);
+
+ return rc;
+}
+
+
+int
+msnprintf(
+ char * buf,
+ size_t bufsiz,
+ const char * fmt,
+ ...
+ )
+{
+ va_list ap;
+ size_t rc;
+
+ va_start(ap, fmt);
+ rc = mvsnprintf(buf, bufsiz, fmt, ap);
+ va_end(ap);
+
+ return rc;
+}
+
+
+void
+msyslog(
+ int level,
+ const char * fmt,
+ ...
+ )
+{
+ char buf[1024];
+ va_list ap;
+
+ va_start(ap, fmt);
+ mvsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
+ addto_syslog(level, buf);
+}
+
+void
+mvsyslog(
+ int level,
+ const char * fmt,
+ va_list ap
+ )
+{
+ char buf[1024];
+ mvsnprintf(buf, sizeof(buf), fmt, ap);
+ addto_syslog(level, buf);
+}
+
+
+/*
+ * Initialize the logging
+ *
+ * Called once per process, including forked children.
+ */
+void
+init_logging(
+ const char * name,
+ u_int32 def_syslogmask,
+ int is_daemon
+ )
+{
+ static int was_daemon;
+ char * cp;
+ const char * pname;
+
+ /*
+ * ntpd defaults to only logging sync-category events, when
+ * NLOG() is used to conditionalize. Other libntp clients
+ * leave it alone so that all NLOG() conditionals will fire.
+ * This presumes all bits lit in ntp_syslogmask can't be
+ * configured via logconfig and all lit is thereby a sentinel
+ * that ntp_syslogmask is still at its default from libntp,
+ * keeping in mind this function is called in forked children
+ * where it has already been called in the parent earlier.
+ * Forked children pass 0 for def_syslogmask.
+ */
+ if (INIT_NTP_SYSLOGMASK == ntp_syslogmask &&
+ 0 != def_syslogmask)
+ ntp_syslogmask = def_syslogmask; /* set more via logconfig */
+
+ /*
+ * Logging. This may actually work on the gizmo board. Find a name
+ * to log with by using the basename
+ */
+ cp = strrchr(name, DIR_SEP);
+ if (NULL == cp)
+ pname = name;
+ else
+ pname = 1 + cp; /* skip DIR_SEP */
+ progname = estrdup(pname);
+#ifdef SYS_WINNT /* strip ".exe" */
+ cp = strrchr(progname, '.');
+ if (NULL != cp && !strcasecmp(cp, ".exe"))
+ *cp = '\0';
+#endif
+
+#if !defined(VMS)
+
+ if (is_daemon)
+ was_daemon = TRUE;
+# ifndef LOG_DAEMON
+ openlog(progname, LOG_PID);
+# else /* LOG_DAEMON */
+
+# ifndef LOG_NTP
+# define LOG_NTP LOG_DAEMON
+# endif
+ openlog(progname, LOG_PID | LOG_NDELAY, (was_daemon)
+ ? LOG_NTP
+ : 0);
+# ifdef DEBUG
+ if (debug)
+ setlogmask(LOG_UPTO(LOG_DEBUG));
+ else
+# endif /* DEBUG */
+ setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
+# endif /* LOG_DAEMON */
+#endif /* !VMS */
+}
+
+
+/*
+ * change_logfile()
+ *
+ * Used to change from syslog to a logfile, or from one logfile to
+ * another, and to reopen logfiles after forking. On systems where
+ * ntpd forks, deals with converting relative logfile paths to
+ * absolute (root-based) because we reopen logfiles after the current
+ * directory has changed.
+ */
+int
+change_logfile(
+ const char * fname,
+ int leave_crumbs
+ )
+{
+ FILE * new_file;
+ const char * log_fname;
+ char * abs_fname;
+#if !defined(SYS_WINNT) && !defined(SYS_VXWORKS) && !defined(VMS)
+ char curdir[512];
+ size_t cd_octets;
+ size_t octets;
+#endif /* POSIX */
+
+ REQUIRE(fname != NULL);
+ log_fname = fname;
+
+ /*
+ * In a forked child of a parent which is logging to a file
+ * instead of syslog, syslog_file will be NULL and both
+ * syslog_fname and syslog_abs_fname will be non-NULL.
+ * If we are given the same filename previously opened
+ * and it's still open, there's nothing to do here.
+ */
+ if (syslog_file != NULL && syslog_fname != NULL &&
+ 0 == strcmp(syslog_fname, log_fname))
+ return 0;
+
+ if (0 == strcmp(log_fname, "stderr")) {
+ new_file = stderr;
+ abs_fname = estrdup(log_fname);
+ } else if (0 == strcmp(log_fname, "stdout")) {
+ new_file = stdout;
+ abs_fname = estrdup(log_fname);
+ } else {
+ if (syslog_fname != NULL &&
+ 0 == strcmp(log_fname, syslog_fname))
+ log_fname = syslog_abs_fname;
+#if !defined(SYS_WINNT) && !defined(SYS_VXWORKS) && !defined(VMS)
+ if (log_fname != syslog_abs_fname &&
+ DIR_SEP != log_fname[0] &&
+ 0 != strcmp(log_fname, "stderr") &&
+ 0 != strcmp(log_fname, "stdout") &&
+ NULL != getcwd(curdir, sizeof(curdir))) {
+ cd_octets = strlen(curdir);
+ /* trim any trailing '/' */
+ if (cd_octets > 1 &&
+ DIR_SEP == curdir[cd_octets - 1])
+ cd_octets--;
+ octets = cd_octets;
+ octets += 1; /* separator '/' */
+ octets += strlen(log_fname);
+ octets += 1; /* NUL terminator */
+ abs_fname = emalloc(octets);
+ snprintf(abs_fname, octets, "%.*s%c%s",
+ (int)cd_octets, curdir, DIR_SEP,
+ log_fname);
+ } else
+#endif
+ abs_fname = estrdup(log_fname);
+ TRACE(1, ("attempting to open log %s\n", abs_fname));
+ new_file = fopen(abs_fname, "a");
+ }
+
+ if (NULL == new_file) {
+ free(abs_fname);
+ return -1;
+ }
+
+ /* leave a pointer in the old log */
+ if (leave_crumbs && (syslogit || log_fname != syslog_abs_fname))
+ msyslog(LOG_NOTICE, "switching logging to file %s",
+ abs_fname);
+
+ if (syslog_file != NULL &&
+ syslog_file != stderr && syslog_file != stdout &&
+ fileno(syslog_file) != fileno(new_file))
+ fclose(syslog_file);
+ syslog_file = new_file;
+ if (log_fname == syslog_abs_fname) {
+ free(abs_fname);
+ } else {
+ if (syslog_abs_fname != NULL &&
+ syslog_abs_fname != syslog_fname)
+ free(syslog_abs_fname);
+ if (syslog_fname != NULL)
+ free(syslog_fname);
+ syslog_fname = estrdup(log_fname);
+ syslog_abs_fname = abs_fname;
+ }
+ syslogit = FALSE;
+
+ return 0;
+}
+
+
+/*
+ * setup_logfile()
+ *
+ * Redirect logging to a file if requested with -l/--logfile or via
+ * ntp.conf logfile directive.
+ *
+ * This routine is invoked three different times in the sequence of a
+ * typical daemon ntpd with DNS lookups to do. First it is invoked in
+ * the original ntpd process, then again in the daemon after closing
+ * all descriptors. In both of those cases, ntp.conf has not been
+ * processed, so only -l/--logfile will trigger logfile redirection in
+ * those invocations. Finally, if DNS names are resolved, the worker
+ * child invokes this routine after its fork and close of all
+ * descriptors. In this case, ntp.conf has been processed and any
+ * "logfile" directive needs to be honored in the child as well.
+ */
+void
+setup_logfile(
+ const char * name
+ )
+{
+ if (NULL == syslog_fname && NULL != name) {
+ if (-1 == change_logfile(name, TRUE))
+ msyslog(LOG_ERR, "Cannot open log file %s, %m",
+ name);
+ return ;
+ }
+ if (NULL == syslog_fname)
+ return;
+
+ if (-1 == change_logfile(syslog_fname, FALSE))
+ msyslog(LOG_ERR, "Cannot reopen log file %s, %m",
+ syslog_fname);
}
diff --git a/contrib/ntp/libntp/netof.c b/contrib/ntp/libntp/netof.c
index fd57568..c8831c3 100644
--- a/contrib/ntp/libntp/netof.c
+++ b/contrib/ntp/libntp/netof.c
@@ -2,47 +2,54 @@
* netof - return the net address part of an ip address in a sockaddr_storage structure
* (zero out host part)
*/
+#include <config.h>
#include <stdio.h>
+#include <syslog.h>
#include "ntp_fp.h"
+#include "ntp_net.h"
#include "ntp_stdlib.h"
#include "ntp.h"
-#define NUM_NETOF_BUFS 10
-static struct sockaddr_storage ssbuf[NUM_NETOF_BUFS];
-static int next_ssbuf = 0;
-
-struct sockaddr_storage*
+sockaddr_u *
netof(
- struct sockaddr_storage* hostaddr
+ sockaddr_u *hostaddr
)
{
- register u_int32 netnum;
- struct sockaddr_storage *netaddr;
+ static sockaddr_u netofbuf[8];
+ static int next_netofbuf;
+ u_int32 netnum;
+ sockaddr_u * netaddr;
+
+ netaddr = &netofbuf[next_netofbuf];
+ next_netofbuf = (next_netofbuf + 1) % COUNTOF(netofbuf);
- netaddr = &ssbuf[next_ssbuf++];
- if (next_ssbuf == NUM_NETOF_BUFS)
- next_ssbuf = 0;
- memcpy(netaddr, hostaddr, sizeof(struct sockaddr_storage));
+ memcpy(netaddr, hostaddr, sizeof(*netaddr));
- if(netaddr->ss_family == AF_INET) {
- netnum = ((struct sockaddr_in*)netaddr)->sin_addr.s_addr;
+ if (IS_IPV4(netaddr)) {
+ netnum = SRCADR(netaddr);
/*
* We live in a modern CIDR world where the basement nets, which
* used to be class A, are now probably associated with each
* host address. So, for class-A nets, all bits are significant.
*/
- if(IN_CLASSC(netnum))
- netnum &= IN_CLASSC_NET;
+ if (IN_CLASSC(netnum))
+ netnum &= IN_CLASSC_NET;
else if (IN_CLASSB(netnum))
- netnum &= IN_CLASSB_NET;
- ((struct sockaddr_in*)netaddr)->sin_addr.s_addr = netnum;
- }
- else if(netaddr->ss_family == AF_INET6) {
- /* Here we put 0 at the local link address so we get net address */
- memset(&((struct sockaddr_in6*)netaddr)->sin6_addr.s6_addr[8], 0, 8*sizeof(u_char));
- }
-
- return netaddr;
+ netnum &= IN_CLASSB_NET;
+
+ SET_ADDR4(netaddr, netnum);
+
+ } else if (IS_IPV6(netaddr))
+ /* assume the typical /64 subnet size */
+ zero_mem(&NSRCADR6(netaddr)[8], 8);
+#ifdef DEBUG
+ else {
+ msyslog(LOG_ERR, "netof unknown AF %d", AF(netaddr));
+ exit(1);
+ }
+#endif
+
+ return netaddr;
}
diff --git a/contrib/ntp/libntp/ntp_calendar.c b/contrib/ntp/libntp/ntp_calendar.c
new file mode 100644
index 0000000..ff6ead3
--- /dev/null
+++ b/contrib/ntp/libntp/ntp_calendar.c
@@ -0,0 +1,1801 @@
+/*
+ * ntp_calendar.c - calendar and helper functions
+ *
+ * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
+ * The contents of 'html/copyright.html' apply.
+ *
+ * --------------------------------------------------------------------
+ * Some notes on the implementation:
+ *
+ * Calendar algorithms thrive on the division operation, which is one of
+ * the slowest numerical operations in any CPU. What saves us here from
+ * abysmal performance is the fact that all divisions are divisions by
+ * constant numbers, and most compilers can do this by a multiplication
+ * operation. But this might not work when using the div/ldiv/lldiv
+ * function family, because many compilers are not able to do inline
+ * expansion of the code with following optimisation for the
+ * constant-divider case.
+ *
+ * Also div/ldiv/lldiv are defined in terms of int/long/longlong, which
+ * are inherently target dependent. Nothing that could not be cured with
+ * autoconf, but still a mess...
+ *
+ * Furthermore, we need floor division in many places. C either leaves
+ * the division behaviour undefined (< C99) or demands truncation to
+ * zero (>= C99), so additional steps are required to make sure the
+ * algorithms work. The {l,ll}div function family is requested to
+ * truncate towards zero, which is also the wrong direction for our
+ * purpose.
+ *
+ * For all this, all divisions by constant are coded manually, even when
+ * there is a joined div/mod operation: The optimiser should sort that
+ * out, if possible. Most of the calculations are done with unsigned
+ * types, explicitely using two's complement arithmetics where
+ * necessary. This minimises the dependecies to compiler and target,
+ * while still giving reasonable to good performance.
+ *
+ * The implementation uses a few tricks that exploit properties of the
+ * two's complement: Floor division on negative dividents can be
+ * executed by using the one's complement of the divident. One's
+ * complement can be easily created using XOR and a mask.
+ *
+ * Finally, check for overflow conditions is minimal. There are only two
+ * calculation steps in the whole calendar that suffer from an internal
+ * overflow, and these conditions are checked: errno is set to EDOM and
+ * the results are clamped/saturated in this case. All other functions
+ * do not suffer from internal overflow and simply return the result
+ * truncated to 32 bits.
+ *
+ * This is a sacrifice made for execution speed. Since a 32-bit day
+ * counter covers +/- 5,879,610 years and the clamp limits the effective
+ * range to +/-2.9 million years, this should not pose a problem here.
+ *
+ */
+
+#include <config.h>
+#include <sys/types.h>
+
+#include "ntp_types.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+
+/* For now, let's take the conservative approach: if the target property
+ * macros are not defined, check a few well-known compiler/architecture
+ * settings. Default is to assume that the representation of signed
+ * integers is unknown and shift-arithmetic-right is not available.
+ */
+#ifndef TARGET_HAS_2CPL
+# if defined(__GNUC__)
+# if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
+# define TARGET_HAS_2CPL 1
+# else
+# define TARGET_HAS_2CPL 0
+# endif
+# elif defined(_MSC_VER)
+# if defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM)
+# define TARGET_HAS_2CPL 1
+# else
+# define TARGET_HAS_2CPL 0
+# endif
+# else
+# define TARGET_HAS_2CPL 0
+# endif
+#endif
+
+#ifndef TARGET_HAS_SAR
+# define TARGET_HAS_SAR 0
+#endif
+
+/*
+ *---------------------------------------------------------------------
+ * replacing the 'time()' function
+ * --------------------------------------------------------------------
+ */
+
+static systime_func_ptr systime_func = &time;
+static inline time_t now(void);
+
+
+systime_func_ptr
+ntpcal_set_timefunc(
+ systime_func_ptr nfunc
+ )
+{
+ systime_func_ptr res;
+
+ res = systime_func;
+ if (NULL == nfunc)
+ nfunc = &time;
+ systime_func = nfunc;
+
+ return res;
+}
+
+
+static inline time_t
+now(void)
+{
+ return (*systime_func)(NULL);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Get sign extension mask and unsigned 2cpl rep for a signed integer
+ *---------------------------------------------------------------------
+ */
+
+static inline uint32_t
+int32_sflag(
+ const int32_t v)
+{
+# if TARGET_HAS_2CPL && TARGET_HAS_SAR && SIZEOF_INT >= 4
+
+ /* Let's assume that shift is the fastest way to get the sign
+ * extension of of a signed integer. This might not always be
+ * true, though -- On 8bit CPUs or machines without barrel
+ * shifter this will kill the performance. So we make sure
+ * we do this only if 'int' has at least 4 bytes.
+ */
+ return (uint32_t)(v >> 31);
+
+# else
+
+ /* This should be a rather generic approach for getting a sign
+ * extension mask...
+ */
+ return UINT32_C(0) - (uint32_t)(v < 0);
+
+# endif
+}
+
+static inline uint32_t
+int32_to_uint32_2cpl(
+ const int32_t v)
+{
+ uint32_t vu;
+
+# if TARGET_HAS_2CPL
+
+ /* Just copy through the 32 bits from the signed value if we're
+ * on a two's complement target.
+ */
+ vu = (uint32_t)v;
+
+# else
+
+ /* Convert from signed int to unsigned int two's complement. Do
+ * not make any assumptions about the representation of signed
+ * integers, but make sure signed integer overflow cannot happen
+ * here. A compiler on a two's complement target *might* find
+ * out that this is just a complicated cast (as above), but your
+ * mileage might vary.
+ */
+ if (v < 0)
+ vu = ~(uint32_t)(-(v + 1));
+ else
+ vu = (uint32_t)v;
+
+# endif
+
+ return vu;
+}
+
+static inline int32_t
+uint32_2cpl_to_int32(
+ const uint32_t vu)
+{
+ int32_t v;
+
+# if TARGET_HAS_2CPL
+
+ /* Just copy through the 32 bits from the unsigned value if
+ * we're on a two's complement target.
+ */
+ v = (int32_t)vu;
+
+# else
+
+ /* Convert to signed integer, making sure signed integer
+ * overflow cannot happen. Again, the optimiser might or might
+ * not find out that this is just a copy of 32 bits on a target
+ * with two's complement representation for signed integers.
+ */
+ if (vu > INT32_MAX)
+ v = -(int32_t)(~vu) - 1;
+ else
+ v = (int32_t)vu;
+
+# endif
+
+ return v;
+}
+
+/* Some of the calculations need to multiply the input by 4 before doing
+ * a division. This can cause overflow and strange results. Therefore we
+ * clamp / saturate the input operand. And since we do the calculations
+ * in unsigned int with an extra sign flag/mask, we only loose one bit
+ * of the input value range.
+ */
+static inline uint32_t
+uint32_saturate(
+ uint32_t vu,
+ uint32_t mu)
+{
+ static const uint32_t limit = UINT32_MAX/4u;
+ if ((mu ^ vu) > limit) {
+ vu = mu ^ limit;
+ errno = EDOM;
+ }
+ return vu;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert between 'time_t' and 'vint64'
+ *---------------------------------------------------------------------
+ */
+vint64
+time_to_vint64(
+ const time_t * ptt
+ )
+{
+ vint64 res;
+ time_t tt;
+
+ tt = *ptt;
+
+# if SIZEOF_TIME_T <= 4
+
+ res.D_s.hi = 0;
+ if (tt < 0) {
+ res.D_s.lo = (uint32_t)-tt;
+ M_NEG(res.D_s.hi, res.D_s.lo);
+ } else {
+ res.D_s.lo = (uint32_t)tt;
+ }
+
+# elif defined(HAVE_INT64)
+
+ res.q_s = tt;
+
+# else
+ /*
+ * shifting negative signed quantities is compiler-dependent, so
+ * we better avoid it and do it all manually. And shifting more
+ * than the width of a quantity is undefined. Also a don't do!
+ */
+ if (tt < 0) {
+ tt = -tt;
+ res.D_s.lo = (uint32_t)tt;
+ res.D_s.hi = (uint32_t)(tt >> 32);
+ M_NEG(res.D_s.hi, res.D_s.lo);
+ } else {
+ res.D_s.lo = (uint32_t)tt;
+ res.D_s.hi = (uint32_t)(tt >> 32);
+ }
+
+# endif
+
+ return res;
+}
+
+
+time_t
+vint64_to_time(
+ const vint64 *tv
+ )
+{
+ time_t res;
+
+# if SIZEOF_TIME_T <= 4
+
+ res = (time_t)tv->D_s.lo;
+
+# elif defined(HAVE_INT64)
+
+ res = (time_t)tv->q_s;
+
+# else
+
+ res = ((time_t)tv->d_s.hi << 32) | tv->D_s.lo;
+
+# endif
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Get the build date & time
+ *---------------------------------------------------------------------
+ */
+int
+ntpcal_get_build_date(
+ struct calendar * jd
+ )
+{
+ /* The C standard tells us the format of '__DATE__':
+ *
+ * __DATE__ The date of translation of the preprocessing
+ * translation unit: a character string literal of the form "Mmm
+ * dd yyyy", where the names of the months are the same as those
+ * generated by the asctime function, and the first character of
+ * dd is a space character if the value is less than 10. If the
+ * date of translation is not available, an
+ * implementation-defined valid date shall be supplied.
+ *
+ * __TIME__ The time of translation of the preprocessing
+ * translation unit: a character string literal of the form
+ * "hh:mm:ss" as in the time generated by the asctime
+ * function. If the time of translation is not available, an
+ * implementation-defined valid time shall be supplied.
+ *
+ * Note that MSVC declares DATE and TIME to be in the local time
+ * zone, while neither the C standard nor the GCC docs make any
+ * statement about this. As a result, we may be +/-12hrs off
+ * UTC. But for practical purposes, this should not be a
+ * problem.
+ *
+ */
+# ifdef MKREPRO_DATE
+ static const char build[] = MKREPRO_TIME "/" MKREPRO_DATE;
+# else
+ static const char build[] = __TIME__ "/" __DATE__;
+# endif
+ static const char mlist[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
+
+ char monstr[4];
+ const char * cp;
+ unsigned short hour, minute, second, day, year;
+ /* Note: The above quantities are used for sscanf 'hu' format,
+ * so using 'uint16_t' is contra-indicated!
+ */
+
+# ifdef DEBUG
+ static int ignore = 0;
+# endif
+
+ ZERO(*jd);
+ jd->year = 1970;
+ jd->month = 1;
+ jd->monthday = 1;
+
+# ifdef DEBUG
+ /* check environment if build date should be ignored */
+ if (0 == ignore) {
+ const char * envstr;
+ envstr = getenv("NTPD_IGNORE_BUILD_DATE");
+ ignore = 1 + (envstr && (!*envstr || !strcasecmp(envstr, "yes")));
+ }
+ if (ignore > 1)
+ return FALSE;
+# endif
+
+ if (6 == sscanf(build, "%hu:%hu:%hu/%3s %hu %hu",
+ &hour, &minute, &second, monstr, &day, &year)) {
+ cp = strstr(mlist, monstr);
+ if (NULL != cp) {
+ jd->year = year;
+ jd->month = (uint8_t)((cp - mlist) / 3 + 1);
+ jd->monthday = (uint8_t)day;
+ jd->hour = (uint8_t)hour;
+ jd->minute = (uint8_t)minute;
+ jd->second = (uint8_t)second;
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+/*
+ *---------------------------------------------------------------------
+ * basic calendar stuff
+ * --------------------------------------------------------------------
+ */
+
+/* month table for a year starting with March,1st */
+static const uint16_t shift_month_table[13] = {
+ 0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337, 366
+};
+
+/* month tables for years starting with January,1st; regular & leap */
+static const uint16_t real_month_table[2][13] = {
+ /* -*- table for regular years -*- */
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ /* -*- table for leap years -*- */
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+};
+
+/*
+ * Some notes on the terminology:
+ *
+ * We use the proleptic Gregorian calendar, which is the Gregorian
+ * calendar extended in both directions ad infinitum. This totally
+ * disregards the fact that this calendar was invented in 1582, and
+ * was adopted at various dates over the world; sometimes even after
+ * the start of the NTP epoch.
+ *
+ * Normally date parts are given as current cycles, while time parts
+ * are given as elapsed cycles:
+ *
+ * 1970-01-01/03:04:05 means 'IN the 1970st. year, IN the first month,
+ * ON the first day, with 3hrs, 4minutes and 5 seconds elapsed.
+ *
+ * The basic calculations for this calendar implementation deal with
+ * ELAPSED date units, which is the number of full years, full months
+ * and full days before a date: 1970-01-01 would be (1969, 0, 0) in
+ * that notation.
+ *
+ * To ease the numeric computations, month and day values outside the
+ * normal range are acceptable: 2001-03-00 will be treated as the day
+ * before 2001-03-01, 2000-13-32 will give the same result as
+ * 2001-02-01 and so on.
+ *
+ * 'rd' or 'RD' is used as an abbreviation for the latin 'rata die'
+ * (day number). This is the number of days elapsed since 0000-12-31
+ * in the proleptic Gregorian calendar. The begin of the Christian Era
+ * (0001-01-01) is RD(1).
+ */
+
+/*
+ * ==================================================================
+ *
+ * General algorithmic stuff
+ *
+ * ==================================================================
+ */
+
+/*
+ *---------------------------------------------------------------------
+ * Do a periodic extension of 'value' around 'pivot' with a period of
+ * 'cycle'.
+ *
+ * The result 'res' is a number that holds to the following properties:
+ *
+ * 1) res MOD cycle == value MOD cycle
+ * 2) pivot <= res < pivot + cycle
+ * (replace </<= with >/>= for negative cycles)
+ *
+ * where 'MOD' denotes the modulo operator for FLOOR DIVISION, which
+ * is not the same as the '%' operator in C: C requires division to be
+ * a truncated division, where remainder and dividend have the same
+ * sign if the remainder is not zero, whereas floor division requires
+ * divider and modulus to have the same sign for a non-zero modulus.
+ *
+ * This function has some useful applications:
+ *
+ * + let Y be a calendar year and V a truncated 2-digit year: then
+ * periodic_extend(Y-50, V, 100)
+ * is the closest expansion of the truncated year with respect to
+ * the full year, that is a 4-digit year with a difference of less
+ * than 50 years to the year Y. ("century unfolding")
+ *
+ * + let T be a UN*X time stamp and V be seconds-of-day: then
+ * perodic_extend(T-43200, V, 86400)
+ * is a time stamp that has the same seconds-of-day as the input
+ * value, with an absolute difference to T of <= 12hrs. ("day
+ * unfolding")
+ *
+ * + Wherever you have a truncated periodic value and a non-truncated
+ * base value and you want to match them somehow...
+ *
+ * Basically, the function delivers 'pivot + (value - pivot) % cycle',
+ * but the implementation takes some pains to avoid internal signed
+ * integer overflows in the '(value - pivot) % cycle' part and adheres
+ * to the floor division convention.
+ *
+ * If 64bit scalars where available on all intended platforms, writing a
+ * version that uses 64 bit ops would be easy; writing a general
+ * division routine for 64bit ops on a platform that can only do
+ * 32/16bit divisions and is still performant is a bit more
+ * difficult. Since most usecases can be coded in a way that does only
+ * require the 32-bit version a 64bit version is NOT provided here.
+ * ---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_periodic_extend(
+ int32_t pivot,
+ int32_t value,
+ int32_t cycle
+ )
+{
+ uint32_t diff;
+ char cpl = 0; /* modulo complement flag */
+ char neg = 0; /* sign change flag */
+
+ /* make the cycle positive and adjust the flags */
+ if (cycle < 0) {
+ cycle = - cycle;
+ neg ^= 1;
+ cpl ^= 1;
+ }
+ /* guard against div by zero or one */
+ if (cycle > 1) {
+ /*
+ * Get absolute difference as unsigned quantity and
+ * the complement flag. This is done by always
+ * subtracting the smaller value from the bigger
+ * one.
+ */
+ if (value >= pivot) {
+ diff = int32_to_uint32_2cpl(value)
+ - int32_to_uint32_2cpl(pivot);
+ } else {
+ diff = int32_to_uint32_2cpl(pivot)
+ - int32_to_uint32_2cpl(value);
+ cpl ^= 1;
+ }
+ diff %= (uint32_t)cycle;
+ if (diff) {
+ if (cpl)
+ diff = (uint32_t)cycle - diff;
+ if (neg)
+ diff = ~diff + 1;
+ pivot += uint32_2cpl_to_int32(diff);
+ }
+ }
+ return pivot;
+}
+
+/*
+ *-------------------------------------------------------------------
+ * Convert a timestamp in NTP scale to a 64bit seconds value in the UN*X
+ * scale with proper epoch unfolding around a given pivot or the current
+ * system time. This function happily accepts negative pivot values as
+ * timestamps befor 1970-01-01, so be aware of possible trouble on
+ * platforms with 32bit 'time_t'!
+ *
+ * This is also a periodic extension, but since the cycle is 2^32 and
+ * the shift is 2^31, we can do some *very* fast math without explicit
+ * divisions.
+ *-------------------------------------------------------------------
+ */
+vint64
+ntpcal_ntp_to_time(
+ uint32_t ntp,
+ const time_t * pivot
+ )
+{
+ vint64 res;
+
+# if defined(HAVE_INT64)
+
+ res.q_s = (pivot != NULL)
+ ? *pivot
+ : now();
+ res.Q_s -= 0x80000000; /* unshift of half range */
+ ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */
+ ntp -= res.D_s.lo; /* cycle difference */
+ res.Q_s += (uint64_t)ntp; /* get expanded time */
+
+# else /* no 64bit scalars */
+
+ time_t tmp;
+
+ tmp = (pivot != NULL)
+ ? *pivot
+ : now();
+ res = time_to_vint64(&tmp);
+ M_SUB(res.D_s.hi, res.D_s.lo, 0, 0x80000000);
+ ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */
+ ntp -= res.D_s.lo; /* cycle difference */
+ M_ADD(res.D_s.hi, res.D_s.lo, 0, ntp);
+
+# endif /* no 64bit scalars */
+
+ return res;
+}
+
+/*
+ *-------------------------------------------------------------------
+ * Convert a timestamp in NTP scale to a 64bit seconds value in the NTP
+ * scale with proper epoch unfolding around a given pivot or the current
+ * system time.
+ *
+ * Note: The pivot must be given in the UN*X time domain!
+ *
+ * This is also a periodic extension, but since the cycle is 2^32 and
+ * the shift is 2^31, we can do some *very* fast math without explicit
+ * divisions.
+ *-------------------------------------------------------------------
+ */
+vint64
+ntpcal_ntp_to_ntp(
+ uint32_t ntp,
+ const time_t *pivot
+ )
+{
+ vint64 res;
+
+# if defined(HAVE_INT64)
+
+ res.q_s = (pivot)
+ ? *pivot
+ : now();
+ res.Q_s -= 0x80000000; /* unshift of half range */
+ res.Q_s += (uint32_t)JAN_1970; /* warp into NTP domain */
+ ntp -= res.D_s.lo; /* cycle difference */
+ res.Q_s += (uint64_t)ntp; /* get expanded time */
+
+# else /* no 64bit scalars */
+
+ time_t tmp;
+
+ tmp = (pivot)
+ ? *pivot
+ : now();
+ res = time_to_vint64(&tmp);
+ M_SUB(res.D_s.hi, res.D_s.lo, 0, 0x80000000u);
+ M_ADD(res.D_s.hi, res.D_s.lo, 0, (uint32_t)JAN_1970);/*into NTP */
+ ntp -= res.D_s.lo; /* cycle difference */
+ M_ADD(res.D_s.hi, res.D_s.lo, 0, ntp);
+
+# endif /* no 64bit scalars */
+
+ return res;
+}
+
+
+/*
+ * ==================================================================
+ *
+ * Splitting values to composite entities
+ *
+ * ==================================================================
+ */
+
+/*
+ *-------------------------------------------------------------------
+ * Split a 64bit seconds value into elapsed days in 'res.hi' and
+ * elapsed seconds since midnight in 'res.lo' using explicit floor
+ * division. This function happily accepts negative time values as
+ * timestamps before the respective epoch start.
+ * -------------------------------------------------------------------
+ */
+ntpcal_split
+ntpcal_daysplit(
+ const vint64 *ts
+ )
+{
+ ntpcal_split res;
+ uint32_t Q;
+
+# if defined(HAVE_INT64)
+
+ /* Manual floor division by SECSPERDAY. This uses the one's
+ * complement trick, too, but without an extra flag value: The
+ * flag would be 64bit, and that's a bit of overkill on a 32bit
+ * target that has to use a register pair for a 64bit number.
+ */
+ if (ts->q_s < 0)
+ Q = ~(uint32_t)(~ts->Q_s / SECSPERDAY);
+ else
+ Q = (uint32_t)(ts->Q_s / SECSPERDAY);
+
+# else
+
+ uint32_t ah, al, sflag, A;
+
+ /* get operand into ah/al (either ts or ts' one's complement,
+ * for later floor division)
+ */
+ sflag = int32_sflag(ts->d_s.hi);
+ ah = sflag ^ ts->D_s.hi;
+ al = sflag ^ ts->D_s.lo;
+
+ /* Since 86400 == 128*675 we can drop the least 7 bits and
+ * divide by 675 instead of 86400. Then the maximum remainder
+ * after each devision step is 674, and we need 10 bits for
+ * that. So in the next step we can shift in 22 bits from the
+ * numerator.
+ *
+ * Therefore we load the accu with the top 13 bits (51..63) in
+ * the first shot. We don't have to remember the quotient -- it
+ * would be shifted out anyway.
+ */
+ A = ah >> 19;
+ if (A >= 675)
+ A = (A % 675u);
+
+ /* Now assemble the remainder with bits 29..50 from the
+ * numerator and divide. This creates the upper ten bits of the
+ * quotient. (Well, the top 22 bits of a 44bit result. But that
+ * will be truncated to 32 bits anyway.)
+ */
+ A = (A << 19) | (ah & 0x0007FFFFu);
+ A = (A << 3) | (al >> 29);
+ Q = A / 675u;
+ A = A % 675u;
+
+ /* Now assemble the remainder with bits 7..28 from the numerator
+ * and do a final division step.
+ */
+ A = (A << 22) | ((al >> 7) & 0x003FFFFFu);
+ Q = (Q << 22) | (A / 675u);
+
+ /* The last 7 bits get simply dropped, as they have no affect on
+ * the quotient when dividing by 86400.
+ */
+
+ /* apply sign correction and calculate the true floor
+ * remainder.
+ */
+ Q ^= sflag;
+
+# endif
+
+ res.hi = uint32_2cpl_to_int32(Q);
+ res.lo = ts->D_s.lo - Q * SECSPERDAY;
+
+ return res;
+}
+
+/*
+ *-------------------------------------------------------------------
+ * Split a 32bit seconds value into h/m/s and excessive days. This
+ * function happily accepts negative time values as timestamps before
+ * midnight.
+ * -------------------------------------------------------------------
+ */
+static int32_t
+priv_timesplit(
+ int32_t split[3],
+ int32_t ts
+ )
+{
+ /* Do 3 chained floor divisions by positive constants, using the
+ * one's complement trick and factoring out the intermediate XOR
+ * ops to reduce the number of operations.
+ */
+ uint32_t us, um, uh, ud, sflag;
+
+ sflag = int32_sflag(ts);
+ us = int32_to_uint32_2cpl(ts);
+
+ um = (sflag ^ us) / SECSPERMIN;
+ uh = um / MINSPERHR;
+ ud = uh / HRSPERDAY;
+
+ um ^= sflag;
+ uh ^= sflag;
+ ud ^= sflag;
+
+ split[0] = (int32_t)(uh - ud * HRSPERDAY );
+ split[1] = (int32_t)(um - uh * MINSPERHR );
+ split[2] = (int32_t)(us - um * SECSPERMIN);
+
+ return uint32_2cpl_to_int32(ud);
+}
+
+/*
+ * ---------------------------------------------------------------------
+ * Given the number of elapsed days in the calendar era, split this
+ * number into the number of elapsed years in 'res.hi' and the number
+ * of elapsed days of that year in 'res.lo'.
+ *
+ * if 'isleapyear' is not NULL, it will receive an integer that is 0 for
+ * regular years and a non-zero value for leap years.
+ *---------------------------------------------------------------------
+ */
+ntpcal_split
+ntpcal_split_eradays(
+ int32_t days,
+ int *isleapyear
+ )
+{
+ /* Use the fast cyclesplit algorithm here, to calculate the
+ * centuries and years in a century with one division each. This
+ * reduces the number of division operations to two, but is
+ * susceptible to internal range overflow. We make sure the
+ * input operands are in the safe range; this still gives us
+ * approx +/-2.9 million years.
+ */
+ ntpcal_split res;
+ int32_t n100, n001; /* calendar year cycles */
+ uint32_t uday, Q, sflag;
+
+ /* split off centuries first */
+ sflag = int32_sflag(days);
+ uday = uint32_saturate(int32_to_uint32_2cpl(days), sflag);
+ uday = (4u * uday) | 3u;
+ Q = sflag ^ ((sflag ^ uday) / GREGORIAN_CYCLE_DAYS);
+ uday = uday - Q * GREGORIAN_CYCLE_DAYS;
+ n100 = uint32_2cpl_to_int32(Q);
+
+ /* Split off years in century -- days >= 0 here, and we're far
+ * away from integer overflow trouble now. */
+ uday |= 3;
+ n001 = uday / GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
+ uday = uday % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
+
+ /* Assemble the year and day in year */
+ res.hi = n100 * 100 + n001;
+ res.lo = uday / 4u;
+
+ /* Eventually set the leap year flag. Note: 0 <= n001 <= 99 and
+ * Q is still the two's complement representation of the
+ * centuries: The modulo 4 ops can be done with masking here.
+ * We also shift the year and the century by one, so the tests
+ * can be done against zero instead of 3.
+ */
+ if (isleapyear)
+ *isleapyear = !((n001+1) & 3)
+ && ((n001 != 99) || !((Q+1) & 3));
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Given a number of elapsed days in a year and a leap year indicator,
+ * split the number of elapsed days into the number of elapsed months in
+ * 'res.hi' and the number of elapsed days of that month in 'res.lo'.
+ *
+ * This function will fail and return {-1,-1} if the number of elapsed
+ * days is not in the valid range!
+ *---------------------------------------------------------------------
+ */
+ntpcal_split
+ntpcal_split_yeardays(
+ int32_t eyd,
+ int isleapyear
+ )
+{
+ ntpcal_split res;
+ const uint16_t *lt; /* month length table */
+
+ /* check leap year flag and select proper table */
+ lt = real_month_table[(isleapyear != 0)];
+ if (0 <= eyd && eyd < lt[12]) {
+ /* get zero-based month by approximation & correction step */
+ res.hi = eyd >> 5; /* approx month; might be 1 too low */
+ if (lt[res.hi + 1] <= eyd) /* fixup approximative month value */
+ res.hi += 1;
+ res.lo = eyd - lt[res.hi];
+ } else {
+ res.lo = res.hi = -1;
+ }
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert a RD into the date part of a 'struct calendar'.
+ *---------------------------------------------------------------------
+ */
+int
+ntpcal_rd_to_date(
+ struct calendar *jd,
+ int32_t rd
+ )
+{
+ ntpcal_split split;
+ int leapy;
+ u_int ymask;
+
+ /* Get day-of-week first. Since rd is signed, the remainder can
+ * be in the range [-6..+6], but the assignment to an unsigned
+ * variable maps the negative values to positive values >=7.
+ * This makes the sign correction look strange, but adding 7
+ * causes the needed wrap-around into the desired value range of
+ * zero to six, both inclusive.
+ */
+ jd->weekday = rd % DAYSPERWEEK;
+ if (jd->weekday >= DAYSPERWEEK) /* weekday is unsigned! */
+ jd->weekday += DAYSPERWEEK;
+
+ split = ntpcal_split_eradays(rd - 1, &leapy);
+ /* Get year and day-of-year, with overflow check. If any of the
+ * upper 16 bits is set after shifting to unity-based years, we
+ * will have an overflow when converting to an unsigned 16bit
+ * year. Shifting to the right is OK here, since it does not
+ * matter if the shift is logic or arithmetic.
+ */
+ split.hi += 1;
+ ymask = 0u - ((split.hi >> 16) == 0);
+ jd->year = (uint16_t)(split.hi & ymask);
+ jd->yearday = (uint16_t)split.lo + 1;
+
+ /* convert to month and mday */
+ split = ntpcal_split_yeardays(split.lo, leapy);
+ jd->month = (uint8_t)split.hi + 1;
+ jd->monthday = (uint8_t)split.lo + 1;
+
+ return ymask ? leapy : -1;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert a RD into the date part of a 'struct tm'.
+ *---------------------------------------------------------------------
+ */
+int
+ntpcal_rd_to_tm(
+ struct tm *utm,
+ int32_t rd
+ )
+{
+ ntpcal_split split;
+ int leapy;
+
+ /* get day-of-week first */
+ utm->tm_wday = rd % DAYSPERWEEK;
+ if (utm->tm_wday < 0)
+ utm->tm_wday += DAYSPERWEEK;
+
+ /* get year and day-of-year */
+ split = ntpcal_split_eradays(rd - 1, &leapy);
+ utm->tm_year = split.hi - 1899;
+ utm->tm_yday = split.lo; /* 0-based */
+
+ /* convert to month and mday */
+ split = ntpcal_split_yeardays(split.lo, leapy);
+ utm->tm_mon = split.hi; /* 0-based */
+ utm->tm_mday = split.lo + 1; /* 1-based */
+
+ return leapy;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Take a value of seconds since midnight and split it into hhmmss in a
+ * 'struct calendar'.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_daysec_to_date(
+ struct calendar *jd,
+ int32_t sec
+ )
+{
+ int32_t days;
+ int ts[3];
+
+ days = priv_timesplit(ts, sec);
+ jd->hour = (uint8_t)ts[0];
+ jd->minute = (uint8_t)ts[1];
+ jd->second = (uint8_t)ts[2];
+
+ return days;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Take a value of seconds since midnight and split it into hhmmss in a
+ * 'struct tm'.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_daysec_to_tm(
+ struct tm *utm,
+ int32_t sec
+ )
+{
+ int32_t days;
+ int32_t ts[3];
+
+ days = priv_timesplit(ts, sec);
+ utm->tm_hour = ts[0];
+ utm->tm_min = ts[1];
+ utm->tm_sec = ts[2];
+
+ return days;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * take a split representation for day/second-of-day and day offset
+ * and convert it to a 'struct calendar'. The seconds will be normalised
+ * into the range of a day, and the day will be adjusted accordingly.
+ *
+ * returns >0 if the result is in a leap year, 0 if in a regular
+ * year and <0 if the result did not fit into the calendar struct.
+ *---------------------------------------------------------------------
+ */
+int
+ntpcal_daysplit_to_date(
+ struct calendar *jd,
+ const ntpcal_split *ds,
+ int32_t dof
+ )
+{
+ dof += ntpcal_daysec_to_date(jd, ds->lo);
+ return ntpcal_rd_to_date(jd, ds->hi + dof);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * take a split representation for day/second-of-day and day offset
+ * and convert it to a 'struct tm'. The seconds will be normalised
+ * into the range of a day, and the day will be adjusted accordingly.
+ *
+ * returns 1 if the result is in a leap year and zero if in a regular
+ * year.
+ *---------------------------------------------------------------------
+ */
+int
+ntpcal_daysplit_to_tm(
+ struct tm *utm,
+ const ntpcal_split *ds ,
+ int32_t dof
+ )
+{
+ dof += ntpcal_daysec_to_tm(utm, ds->lo);
+
+ return ntpcal_rd_to_tm(utm, ds->hi + dof);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Take a UN*X time and convert to a calendar structure.
+ *---------------------------------------------------------------------
+ */
+int
+ntpcal_time_to_date(
+ struct calendar *jd,
+ const vint64 *ts
+ )
+{
+ ntpcal_split ds;
+
+ ds = ntpcal_daysplit(ts);
+ ds.hi += ntpcal_daysec_to_date(jd, ds.lo);
+ ds.hi += DAY_UNIX_STARTS;
+
+ return ntpcal_rd_to_date(jd, ds.hi);
+}
+
+
+/*
+ * ==================================================================
+ *
+ * merging composite entities
+ *
+ * ==================================================================
+ */
+
+/*
+ *---------------------------------------------------------------------
+ * Merge a number of days and a number of seconds into seconds,
+ * expressed in 64 bits to avoid overflow.
+ *---------------------------------------------------------------------
+ */
+vint64
+ntpcal_dayjoin(
+ int32_t days,
+ int32_t secs
+ )
+{
+ vint64 res;
+
+# if defined(HAVE_INT64)
+
+ res.q_s = days;
+ res.q_s *= SECSPERDAY;
+ res.q_s += secs;
+
+# else
+
+ uint32_t p1, p2;
+ int isneg;
+
+ /*
+ * res = days *86400 + secs, using manual 16/32 bit
+ * multiplications and shifts.
+ */
+ isneg = (days < 0);
+ if (isneg)
+ days = -days;
+
+ /* assemble days * 675 */
+ res.D_s.lo = (days & 0xFFFF) * 675u;
+ res.D_s.hi = 0;
+ p1 = (days >> 16) * 675u;
+ p2 = p1 >> 16;
+ p1 = p1 << 16;
+ M_ADD(res.D_s.hi, res.D_s.lo, p2, p1);
+
+ /* mul by 128, using shift */
+ res.D_s.hi = (res.D_s.hi << 7) | (res.D_s.lo >> 25);
+ res.D_s.lo = (res.D_s.lo << 7);
+
+ /* fix sign */
+ if (isneg)
+ M_NEG(res.D_s.hi, res.D_s.lo);
+
+ /* properly add seconds */
+ p2 = 0;
+ if (secs < 0) {
+ p1 = (uint32_t)-secs;
+ M_NEG(p2, p1);
+ } else {
+ p1 = (uint32_t)secs;
+ }
+ M_ADD(res.D_s.hi, res.D_s.lo, p2, p1);
+
+# endif
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * get leap years since epoch in elapsed years
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_leapyears_in_years(
+ int32_t years
+ )
+{
+ /* We use the in-out-in algorithm here, using the one's
+ * complement division trick for negative numbers. The chained
+ * division sequence by 4/25/4 gives the compiler the chance to
+ * get away with only one true division and doing shifts otherwise.
+ */
+
+ uint32_t sflag, sum, uyear;
+
+ sflag = int32_sflag(years);
+ uyear = int32_to_uint32_2cpl(years);
+ uyear ^= sflag;
+
+ sum = (uyear /= 4u); /* 4yr rule --> IN */
+ sum -= (uyear /= 25u); /* 100yr rule --> OUT */
+ sum += (uyear /= 4u); /* 400yr rule --> IN */
+
+ /* Thanks to the alternation of IN/OUT/IN we can do the sum
+ * directly and have a single one's complement operation
+ * here. (Only if the years are negative, of course.) Otherwise
+ * the one's complement would have to be done when
+ * adding/subtracting the terms.
+ */
+ return uint32_2cpl_to_int32(sflag ^ sum);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert elapsed years in Era into elapsed days in Era.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_days_in_years(
+ int32_t years
+ )
+{
+ return years * DAYSPERYEAR + ntpcal_leapyears_in_years(years);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert a number of elapsed month in a year into elapsed days in year.
+ *
+ * The month will be normalized, and 'res.hi' will contain the
+ * excessive years that must be considered when converting the years,
+ * while 'res.lo' will contain the number of elapsed days since start
+ * of the year.
+ *
+ * This code uses the shifted-month-approach to convert month to days,
+ * because then there is no need to have explicit leap year
+ * information. The slight disadvantage is that for most month values
+ * the result is a negative value, and the year excess is one; the
+ * conversion is then simply based on the start of the following year.
+ *---------------------------------------------------------------------
+ */
+ntpcal_split
+ntpcal_days_in_months(
+ int32_t m
+ )
+{
+ ntpcal_split res;
+
+ /* Add ten months and correct if needed. (It likely is...) */
+ res.lo = m + 10;
+ res.hi = (res.lo >= 12);
+ if (res.hi)
+ res.lo -= 12;
+
+ /* if still out of range, normalise by floor division ... */
+ if (res.lo < 0 || res.lo >= 12) {
+ uint32_t mu, Q, sflag;
+ sflag = int32_sflag(res.lo);
+ mu = int32_to_uint32_2cpl(res.lo);
+ Q = sflag ^ ((sflag ^ mu) / 12u);
+ res.hi += uint32_2cpl_to_int32(Q);
+ res.lo = mu - Q * 12u;
+ }
+
+ /* get cummulated days in year with unshift */
+ res.lo = shift_month_table[res.lo] - 306;
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert ELAPSED years/months/days of gregorian calendar to elapsed
+ * days in Gregorian epoch.
+ *
+ * If you want to convert years and days-of-year, just give a month of
+ * zero.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_edate_to_eradays(
+ int32_t years,
+ int32_t mons,
+ int32_t mdays
+ )
+{
+ ntpcal_split tmp;
+ int32_t res;
+
+ if (mons) {
+ tmp = ntpcal_days_in_months(mons);
+ res = ntpcal_days_in_years(years + tmp.hi) + tmp.lo;
+ } else
+ res = ntpcal_days_in_years(years);
+ res += mdays;
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert ELAPSED years/months/days of gregorian calendar to elapsed
+ * days in year.
+ *
+ * Note: This will give the true difference to the start of the given year,
+ * even if months & days are off-scale.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_edate_to_yeardays(
+ int32_t years,
+ int32_t mons,
+ int32_t mdays
+ )
+{
+ ntpcal_split tmp;
+
+ if (0 <= mons && mons < 12) {
+ years += 1;
+ mdays += real_month_table[is_leapyear(years)][mons];
+ } else {
+ tmp = ntpcal_days_in_months(mons);
+ mdays += tmp.lo
+ + ntpcal_days_in_years(years + tmp.hi)
+ - ntpcal_days_in_years(years);
+ }
+
+ return mdays;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert elapsed days and the hour/minute/second information into
+ * total seconds.
+ *
+ * If 'isvalid' is not NULL, do a range check on the time specification
+ * and tell if the time input is in the normal range, permitting for a
+ * single leapsecond.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_etime_to_seconds(
+ int32_t hours,
+ int32_t minutes,
+ int32_t seconds
+ )
+{
+ int32_t res;
+
+ res = (hours * MINSPERHR + minutes) * SECSPERMIN + seconds;
+
+ return res;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert the date part of a 'struct tm' (that is, year, month,
+ * day-of-month) into the RD of that day.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_tm_to_rd(
+ const struct tm *utm
+ )
+{
+ return ntpcal_edate_to_eradays(utm->tm_year + 1899,
+ utm->tm_mon,
+ utm->tm_mday - 1) + 1;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * Convert the date part of a 'struct calendar' (that is, year, month,
+ * day-of-month) into the RD of that day.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_date_to_rd(
+ const struct calendar *jd
+ )
+{
+ return ntpcal_edate_to_eradays((int32_t)jd->year - 1,
+ (int32_t)jd->month - 1,
+ (int32_t)jd->monthday - 1) + 1;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * convert a year number to rata die of year start
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_year_to_ystart(
+ int32_t year
+ )
+{
+ return ntpcal_days_in_years(year - 1) + 1;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * For a given RD, get the RD of the associated year start,
+ * that is, the RD of the last January,1st on or before that day.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_rd_to_ystart(
+ int32_t rd
+ )
+{
+ /*
+ * Rather simple exercise: split the day number into elapsed
+ * years and elapsed days, then remove the elapsed days from the
+ * input value. Nice'n sweet...
+ */
+ return rd - ntpcal_split_eradays(rd - 1, NULL).lo;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * For a given RD, get the RD of the associated month start.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_rd_to_mstart(
+ int32_t rd
+ )
+{
+ ntpcal_split split;
+ int leaps;
+
+ split = ntpcal_split_eradays(rd - 1, &leaps);
+ split = ntpcal_split_yeardays(split.lo, leaps);
+
+ return rd - split.lo;
+}
+
+/*
+ *---------------------------------------------------------------------
+ * take a 'struct calendar' and get the seconds-of-day from it.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_date_to_daysec(
+ const struct calendar *jd
+ )
+{
+ return ntpcal_etime_to_seconds(jd->hour, jd->minute,
+ jd->second);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * take a 'struct tm' and get the seconds-of-day from it.
+ *---------------------------------------------------------------------
+ */
+int32_t
+ntpcal_tm_to_daysec(
+ const struct tm *utm
+ )
+{
+ return ntpcal_etime_to_seconds(utm->tm_hour, utm->tm_min,
+ utm->tm_sec);
+}
+
+/*
+ *---------------------------------------------------------------------
+ * take a 'struct calendar' and convert it to a 'time_t'
+ *---------------------------------------------------------------------
+ */
+time_t
+ntpcal_date_to_time(
+ const struct calendar *jd
+ )
+{
+ vint64 join;
+ int32_t days, secs;
+
+ days = ntpcal_date_to_rd(jd) - DAY_UNIX_STARTS;
+ secs = ntpcal_date_to_daysec(jd);
+ join = ntpcal_dayjoin(days, secs);
+
+ return vint64_to_time(&join);
+}
+
+
+/*
+ * ==================================================================
+ *
+ * extended and unchecked variants of caljulian/caltontp
+ *
+ * ==================================================================
+ */
+int
+ntpcal_ntp64_to_date(
+ struct calendar *jd,
+ const vint64 *ntp
+ )
+{
+ ntpcal_split ds;
+
+ ds = ntpcal_daysplit(ntp);
+ ds.hi += ntpcal_daysec_to_date(jd, ds.lo);
+
+ return ntpcal_rd_to_date(jd, ds.hi + DAY_NTP_STARTS);
+}
+
+int
+ntpcal_ntp_to_date(
+ struct calendar *jd,
+ uint32_t ntp,
+ const time_t *piv
+ )
+{
+ vint64 ntp64;
+
+ /*
+ * Unfold ntp time around current time into NTP domain. Split
+ * into days and seconds, shift days into CE domain and
+ * process the parts.
+ */
+ ntp64 = ntpcal_ntp_to_ntp(ntp, piv);
+ return ntpcal_ntp64_to_date(jd, &ntp64);
+}
+
+
+vint64
+ntpcal_date_to_ntp64(
+ const struct calendar *jd
+ )
+{
+ /*
+ * Convert date to NTP. Ignore yearday, use d/m/y only.
+ */
+ return ntpcal_dayjoin(ntpcal_date_to_rd(jd) - DAY_NTP_STARTS,
+ ntpcal_date_to_daysec(jd));
+}
+
+
+uint32_t
+ntpcal_date_to_ntp(
+ const struct calendar *jd
+ )
+{
+ /*
+ * Get lower half of 64-bit NTP timestamp from date/time.
+ */
+ return ntpcal_date_to_ntp64(jd).d_s.lo;
+}
+
+
+
+/*
+ * ==================================================================
+ *
+ * day-of-week calculations
+ *
+ * ==================================================================
+ */
+/*
+ * Given a RataDie and a day-of-week, calculate a RDN that is reater-than,
+ * greater-or equal, closest, less-or-equal or less-than the given RDN
+ * and denotes the given day-of-week
+ */
+int32_t
+ntpcal_weekday_gt(
+ int32_t rdn,
+ int32_t dow
+ )
+{
+ return ntpcal_periodic_extend(rdn+1, dow, 7);
+}
+
+int32_t
+ntpcal_weekday_ge(
+ int32_t rdn,
+ int32_t dow
+ )
+{
+ return ntpcal_periodic_extend(rdn, dow, 7);
+}
+
+int32_t
+ntpcal_weekday_close(
+ int32_t rdn,
+ int32_t dow
+ )
+{
+ return ntpcal_periodic_extend(rdn-3, dow, 7);
+}
+
+int32_t
+ntpcal_weekday_le(
+ int32_t rdn,
+ int32_t dow
+ )
+{
+ return ntpcal_periodic_extend(rdn, dow, -7);
+}
+
+int32_t
+ntpcal_weekday_lt(
+ int32_t rdn,
+ int32_t dow
+ )
+{
+ return ntpcal_periodic_extend(rdn-1, dow, -7);
+}
+
+/*
+ * ==================================================================
+ *
+ * ISO week-calendar conversions
+ *
+ * The ISO8601 calendar defines a calendar of years, weeks and weekdays.
+ * It is related to the Gregorian calendar, and a ISO year starts at the
+ * Monday closest to Jan,1st of the corresponding Gregorian year. A ISO
+ * calendar year has always 52 or 53 weeks, and like the Grogrian
+ * calendar the ISO8601 calendar repeats itself every 400 years, or
+ * 146097 days, or 20871 weeks.
+ *
+ * While it is possible to write ISO calendar functions based on the
+ * Gregorian calendar functions, the following implementation takes a
+ * different approach, based directly on years and weeks.
+ *
+ * Analysis of the tabulated data shows that it is not possible to
+ * interpolate from years to weeks over a full 400 year range; cyclic
+ * shifts over 400 years do not provide a solution here. But it *is*
+ * possible to interpolate over every single century of the 400-year
+ * cycle. (The centennial leap year rule seems to be the culprit here.)
+ *
+ * It can be shown that a conversion from years to weeks can be done
+ * using a linear transformation of the form
+ *
+ * w = floor( y * a + b )
+ *
+ * where the slope a must hold to
+ *
+ * 52.1780821918 <= a < 52.1791044776
+ *
+ * and b must be chosen according to the selected slope and the number
+ * of the century in a 400-year period.
+ *
+ * The inverse calculation can also be done in this way. Careful scaling
+ * provides an unlimited set of integer coefficients a,k,b that enable
+ * us to write the calulation in the form
+ *
+ * w = (y * a + b ) / k
+ * y = (w * a' + b') / k'
+ *
+ * In this implementation the values of k and k' are chosen to be
+ * smallest possible powers of two, so the division can be implemented
+ * as shifts if the optimiser chooses to do so.
+ *
+ * ==================================================================
+ */
+
+/*
+ * Given a number of elapsed (ISO-)years since the begin of the
+ * christian era, return the number of elapsed weeks corresponding to
+ * the number of years.
+ */
+int32_t
+isocal_weeks_in_years(
+ int32_t years
+ )
+{
+ /*
+ * use: w = (y * 53431 + b[c]) / 1024 as interpolation
+ */
+ static const uint16_t bctab[4] = { 157, 449, 597, 889 };
+
+ int32_t cs, cw;
+ uint32_t cc, ci, yu, sflag;
+
+ sflag = int32_sflag(years);
+ yu = int32_to_uint32_2cpl(years);
+
+ /* split off centuries, using floor division */
+ cc = sflag ^ ((sflag ^ yu) / 100u);
+ yu -= cc * 100u;
+
+ /* calculate century cycles shift and cycle index:
+ * Assuming a century is 5217 weeks, we have to add a cycle
+ * shift that is 3 for every 4 centuries, because 3 of the four
+ * centuries have 5218 weeks. So '(cc*3 + 1) / 4' is the actual
+ * correction, and the second century is the defective one.
+ *
+ * Needs floor division by 4, which is done with masking and
+ * shifting.
+ */
+ ci = cc * 3u + 1;
+ cs = uint32_2cpl_to_int32(sflag ^ ((sflag ^ ci) / 4u));
+ ci = ci % 4u;
+
+ /* Get weeks in century. Can use plain division here as all ops
+ * are >= 0, and let the compiler sort out the possible
+ * optimisations.
+ */
+ cw = (yu * 53431u + bctab[ci]) / 1024u;
+
+ return uint32_2cpl_to_int32(cc) * 5217 + cs + cw;
+}
+
+/*
+ * Given a number of elapsed weeks since the begin of the christian
+ * era, split this number into the number of elapsed years in res.hi
+ * and the excessive number of weeks in res.lo. (That is, res.lo is
+ * the number of elapsed weeks in the remaining partial year.)
+ */
+ntpcal_split
+isocal_split_eraweeks(
+ int32_t weeks
+ )
+{
+ /*
+ * use: y = (w * 157 + b[c]) / 8192 as interpolation
+ */
+
+ static const uint16_t bctab[4] = { 85, 130, 17, 62 };
+
+ ntpcal_split res;
+ int32_t cc, ci;
+ uint32_t sw, cy, Q, sflag;
+
+ /* Use two fast cycle-split divisions here. This is again
+ * susceptible to internal overflow, so we check the range. This
+ * still permits more than +/-20 million years, so this is
+ * likely a pure academical problem.
+ *
+ * We want to execute '(weeks * 4 + 2) /% 20871' under floor
+ * division rules in the first step.
+ */
+ sflag = int32_sflag(weeks);
+ sw = uint32_saturate(int32_to_uint32_2cpl(weeks), sflag);
+ sw = 4u * sw + 2;
+ Q = sflag ^ ((sflag ^ sw) / GREGORIAN_CYCLE_WEEKS);
+ sw -= Q * GREGORIAN_CYCLE_WEEKS;
+ ci = Q % 4u;
+ cc = uint32_2cpl_to_int32(Q);
+
+ /* Split off years; sw >= 0 here! The scaled weeks in the years
+ * are scaled up by 157 afterwards.
+ */
+ sw = (sw / 4u) * 157u + bctab[ci];
+ cy = sw / 8192u; /* ws >> 13 , let the compiler sort it out */
+ sw = sw % 8192u; /* ws & 8191, let the compiler sort it out */
+
+ /* assemble elapsed years and downscale the elapsed weeks in
+ * the year.
+ */
+ res.hi = 100*cc + cy;
+ res.lo = sw / 157u;
+
+ return res;
+}
+
+/*
+ * Given a second in the NTP time scale and a pivot, expand the NTP
+ * time stamp around the pivot and convert into an ISO calendar time
+ * stamp.
+ */
+int
+isocal_ntp64_to_date(
+ struct isodate *id,
+ const vint64 *ntp
+ )
+{
+ ntpcal_split ds;
+ int32_t ts[3];
+ uint32_t uw, ud, sflag;
+
+ /*
+ * Split NTP time into days and seconds, shift days into CE
+ * domain and process the parts.
+ */
+ ds = ntpcal_daysplit(ntp);
+
+ /* split time part */
+ ds.hi += priv_timesplit(ts, ds.lo);
+ id->hour = (uint8_t)ts[0];
+ id->minute = (uint8_t)ts[1];
+ id->second = (uint8_t)ts[2];
+
+ /* split days into days and weeks, using floor division in unsigned */
+ ds.hi += DAY_NTP_STARTS - 1; /* shift from NTP to RDN */
+ sflag = int32_sflag(ds.hi);
+ ud = int32_to_uint32_2cpl(ds.hi);
+ uw = sflag ^ ((sflag ^ ud) / DAYSPERWEEK);
+ ud -= uw * DAYSPERWEEK;
+ ds.hi = uint32_2cpl_to_int32(uw);
+ ds.lo = ud;
+
+ id->weekday = (uint8_t)ds.lo + 1; /* weekday result */
+
+ /* get year and week in year */
+ ds = isocal_split_eraweeks(ds.hi); /* elapsed years&week*/
+ id->year = (uint16_t)ds.hi + 1; /* shift to current */
+ id->week = (uint8_t )ds.lo + 1;
+
+ return (ds.hi >= 0 && ds.hi < 0x0000FFFF);
+}
+
+int
+isocal_ntp_to_date(
+ struct isodate *id,
+ uint32_t ntp,
+ const time_t *piv
+ )
+{
+ vint64 ntp64;
+
+ /*
+ * Unfold ntp time around current time into NTP domain, then
+ * convert the full time stamp.
+ */
+ ntp64 = ntpcal_ntp_to_ntp(ntp, piv);
+ return isocal_ntp64_to_date(id, &ntp64);
+}
+
+/*
+ * Convert a ISO date spec into a second in the NTP time scale,
+ * properly truncated to 32 bit.
+ */
+vint64
+isocal_date_to_ntp64(
+ const struct isodate *id
+ )
+{
+ int32_t weeks, days, secs;
+
+ weeks = isocal_weeks_in_years((int32_t)id->year - 1)
+ + (int32_t)id->week - 1;
+ days = weeks * 7 + (int32_t)id->weekday;
+ /* days is RDN of ISO date now */
+ secs = ntpcal_etime_to_seconds(id->hour, id->minute, id->second);
+
+ return ntpcal_dayjoin(days - DAY_NTP_STARTS, secs);
+}
+
+uint32_t
+isocal_date_to_ntp(
+ const struct isodate *id
+ )
+{
+ /*
+ * Get lower half of 64-bit NTP timestamp from date/time.
+ */
+ return isocal_date_to_ntp64(id).d_s.lo;
+}
+
+/* -*-EOF-*- */
diff --git a/contrib/ntp/libntp/ntp_crypto_rnd.c b/contrib/ntp/libntp/ntp_crypto_rnd.c
new file mode 100644
index 0000000..96348f2
--- /dev/null
+++ b/contrib/ntp/libntp/ntp_crypto_rnd.c
@@ -0,0 +1,113 @@
+/*
+ * Crypto-quality random number functions
+ *
+ * Author: Harlan Stenn, 2014
+ *
+ * This file is Copyright (c) 2014 by Network Time Foundation.
+ * BSD terms apply: see the file COPYRIGHT in the distribution root for details.
+ */
+
+#include "config.h"
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+
+#include <l_stdlib.h>
+#include <ntp_random.h>
+
+#ifdef USE_OPENSSL_CRYPTO_RAND
+#include <openssl/err.h>
+#include <openssl/rand.h>
+
+int crypto_rand_init = 0;
+#else
+
+# ifndef HAVE_ARC4RANDOM_BUF
+static void
+arc4random_buf(void *buf, size_t nbytes);
+
+void
+evutil_secure_rng_get_bytes(void *buf, size_t nbytes);
+
+static void
+arc4random_buf(void *buf, size_t nbytes)
+{
+ evutil_secure_rng_get_bytes(buf, nbytes);
+ return;
+}
+# endif
+#endif
+
+/*
+ * As of late 2014, here's how we plan to provide cryptographic-quality
+ * random numbers:
+ *
+ * - If we are building with OpenSSL, use RAND_poll() and RAND_bytes().
+ * - Otherwise, use arc4random().
+ *
+ * Use of arc4random() can be forced using configure --disable-openssl-random
+ *
+ * We can count on arc4random existing, thru the OS or thru libevent.
+ * The quality of arc4random depends on the implementor.
+ *
+ * RAND_poll() doesn't show up until XXX. If it's not present, we
+ * need to either provide our own or use arc4random().
+ */
+
+/*
+ * ntp_crypto_srandom:
+ *
+ * Initialize the random number generator, if needed by the underlying
+ * crypto random number generation mechanism.
+ */
+
+void
+ntp_crypto_srandom(
+ void
+ )
+{
+#ifdef USE_OPENSSL_CRYPTO_RAND
+ if (!crypto_rand_init) {
+ RAND_poll();
+ crypto_rand_init = 1;
+ }
+#else
+ /* No initialization needed for arc4random() */
+#endif
+}
+
+
+/*
+ * ntp_crypto_random_buf:
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+ntp_crypto_random_buf(
+ void *buf,
+ size_t nbytes
+ )
+{
+#ifdef USE_OPENSSL_CRYPTO_RAND
+ int rc;
+
+ rc = RAND_bytes(buf, nbytes);
+ if (1 != rc) {
+ unsigned long err;
+ char *err_str;
+
+ err = ERR_get_error();
+ err_str = ERR_error_string(err, NULL);
+ /* XXX: Log the error */
+ (void)&err_str;
+
+ return -1;
+ }
+ return 0;
+#else
+ arc4random_buf(buf, nbytes);
+ return 0;
+#endif
+}
diff --git a/contrib/ntp/libntp/ntp_intres.c b/contrib/ntp/libntp/ntp_intres.c
new file mode 100644
index 0000000..b0f5620
--- /dev/null
+++ b/contrib/ntp/libntp/ntp_intres.c
@@ -0,0 +1,1128 @@
+/*
+ * ntp_intres.c - Implements a generic blocking worker child or thread,
+ * initially to provide a nonblocking solution for DNS
+ * name to address lookups available with getaddrinfo().
+ *
+ * This is a new implementation as of 2009 sharing the filename and
+ * very little else with the prior implementation, which used a
+ * temporary file to receive a single set of requests from the parent,
+ * and a NTP mode 7 authenticated request to push back responses.
+ *
+ * A primary goal in rewriting this code was the need to support the
+ * pool configuration directive's requirement to retrieve multiple
+ * addresses resolving a single name, which has previously been
+ * satisfied with blocking resolver calls from the ntpd mainline code.
+ *
+ * A secondary goal is to provide a generic mechanism for other
+ * blocking operations to be delegated to a worker using a common
+ * model for both Unix and Windows ntpd. ntp_worker.c, work_fork.c,
+ * and work_thread.c implement the generic mechanism. This file
+ * implements the two current consumers, getaddrinfo_sometime() and the
+ * presently unused getnameinfo_sometime().
+ *
+ * Both routines deliver results to a callback and manage memory
+ * allocation, meaning there is no freeaddrinfo_sometime().
+ *
+ * The initial implementation for Unix uses a pair of unidirectional
+ * pipes, one each for requests and responses, connecting the forked
+ * blocking child worker with the ntpd mainline. The threaded code
+ * uses arrays of pointers to queue requests and responses.
+ *
+ * The parent drives the process, including scheduling sleeps between
+ * retries.
+ *
+ * Memory is managed differently for a child process, which mallocs
+ * request buffers to read from the pipe into, whereas the threaded
+ * code mallocs a copy of the request to hand off to the worker via
+ * the queueing array. The resulting request buffer is free()d by
+ * platform-independent code. A wrinkle is the request needs to be
+ * available to the requestor during response processing.
+ *
+ * Response memory allocation is also platform-dependent. With a
+ * separate process and pipes, the response is free()d after being
+ * written to the pipe. With threads, the same memory is handed
+ * over and the requestor frees it after processing is completed.
+ *
+ * The code should be generalized to support threads on Unix using
+ * much of the same code used for Windows initially.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_workimpl.h"
+
+#ifdef WORKER
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+
+/**/
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#include <arpa/inet.h>
+/**/
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#if !defined(HAVE_RES_INIT) && defined(HAVE___RES_INIT)
+# define HAVE_RES_INIT
+#endif
+
+#if defined(HAVE_RESOLV_H) && defined(HAVE_RES_INIT)
+# ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h> /* DNS HEADER struct */
+# endif
+# ifdef HAVE_NETDB_H
+# include <netdb.h>
+# endif
+# include <resolv.h>
+# ifdef HAVE_INT32_ONLY_WITH_DNS
+# define HAVE_INT32
+# endif
+# ifdef HAVE_U_INT32_ONLY_WITH_DNS
+# define HAVE_U_INT32
+# endif
+#endif
+
+#include "ntp.h"
+#include "ntp_debug.h"
+#include "ntp_malloc.h"
+#include "ntp_syslog.h"
+#include "ntp_unixtime.h"
+#include "ntp_intres.h"
+#include "intreswork.h"
+
+
+/*
+ * Following are implementations of getaddrinfo_sometime() and
+ * getnameinfo_sometime(). Each is implemented in three routines:
+ *
+ * getaddrinfo_sometime() getnameinfo_sometime()
+ * blocking_getaddrinfo() blocking_getnameinfo()
+ * getaddrinfo_sometime_complete() getnameinfo_sometime_complete()
+ *
+ * The first runs in the parent and marshalls (or serializes) request
+ * parameters into a request blob which is processed in the child by
+ * the second routine, blocking_*(), which serializes the results into
+ * a response blob unpacked by the third routine, *_complete(), which
+ * calls the callback routine provided with the request and frees
+ * _request_ memory allocated by the first routine. Response memory
+ * is managed by the code which calls the *_complete routines.
+ */
+
+/* === typedefs === */
+typedef struct blocking_gai_req_tag { /* marshalled args */
+ size_t octets;
+ u_int dns_idx;
+ time_t scheduled;
+ time_t earliest;
+ struct addrinfo hints;
+ int retry;
+ gai_sometime_callback callback;
+ void * context;
+ size_t nodesize;
+ size_t servsize;
+} blocking_gai_req;
+
+typedef struct blocking_gai_resp_tag {
+ size_t octets;
+ int retcode;
+ int retry;
+ int gai_errno; /* for EAI_SYSTEM case */
+ int ai_count;
+ /*
+ * Followed by ai_count struct addrinfo and then ai_count
+ * sockaddr_u and finally the canonical name strings.
+ */
+} blocking_gai_resp;
+
+typedef struct blocking_gni_req_tag {
+ size_t octets;
+ u_int dns_idx;
+ time_t scheduled;
+ time_t earliest;
+ int retry;
+ size_t hostoctets;
+ size_t servoctets;
+ int flags;
+ gni_sometime_callback callback;
+ void * context;
+ sockaddr_u socku;
+} blocking_gni_req;
+
+typedef struct blocking_gni_resp_tag {
+ size_t octets;
+ int retcode;
+ int gni_errno; /* for EAI_SYSTEM case */
+ int retry;
+ size_t hostoctets;
+ size_t servoctets;
+ /*
+ * Followed by hostoctets bytes of null-terminated host,
+ * then servoctets bytes of null-terminated service.
+ */
+} blocking_gni_resp;
+
+/* per-DNS-worker state in parent */
+typedef struct dnschild_ctx_tag {
+ u_int index;
+ time_t next_dns_timeslot;
+} dnschild_ctx;
+
+/* per-DNS-worker state in worker */
+typedef struct dnsworker_ctx_tag {
+ blocking_child * c;
+ time_t ignore_scheduled_before;
+#ifdef HAVE_RES_INIT
+ time_t next_res_init;
+#endif
+} dnsworker_ctx;
+
+
+/* === variables === */
+dnschild_ctx ** dnschild_contexts; /* parent */
+u_int dnschild_contexts_alloc;
+dnsworker_ctx ** dnsworker_contexts; /* child */
+u_int dnsworker_contexts_alloc;
+
+#ifdef HAVE_RES_INIT
+static time_t next_res_init;
+#endif
+
+
+/* === forward declarations === */
+static u_int reserve_dnschild_ctx(void);
+static u_int get_dnschild_ctx(void);
+static void alloc_dnsworker_context(u_int);
+/* static void free_dnsworker_context(u_int); */
+static dnsworker_ctx * get_worker_context(blocking_child *, u_int);
+static void scheduled_sleep(time_t, time_t,
+ dnsworker_ctx *);
+static void manage_dns_retry_interval(time_t *, time_t *,
+ int *,
+ time_t *);
+static int should_retry_dns(int, int);
+#ifdef HAVE_RES_INIT
+static void reload_resolv_conf(dnsworker_ctx *);
+#else
+# define reload_resolv_conf(wc) \
+ do { \
+ (void)(wc); \
+ } while (FALSE)
+#endif
+static void getaddrinfo_sometime_complete(blocking_work_req,
+ void *, size_t,
+ void *);
+static void getnameinfo_sometime_complete(blocking_work_req,
+ void *, size_t,
+ void *);
+
+
+/* === functions === */
+/*
+ * getaddrinfo_sometime - uses blocking child to call getaddrinfo then
+ * invokes provided callback completion function.
+ */
+int
+getaddrinfo_sometime(
+ const char * node,
+ const char * service,
+ const struct addrinfo * hints,
+ int retry,
+ gai_sometime_callback callback,
+ void * context
+ )
+{
+ blocking_gai_req * gai_req;
+ u_int idx;
+ dnschild_ctx * child_ctx;
+ size_t req_size;
+ size_t nodesize;
+ size_t servsize;
+ time_t now;
+
+ REQUIRE(NULL != node);
+ if (NULL != hints) {
+ REQUIRE(0 == hints->ai_addrlen);
+ REQUIRE(NULL == hints->ai_addr);
+ REQUIRE(NULL == hints->ai_canonname);
+ REQUIRE(NULL == hints->ai_next);
+ }
+
+ idx = get_dnschild_ctx();
+ child_ctx = dnschild_contexts[idx];
+
+ nodesize = strlen(node) + 1;
+ servsize = strlen(service) + 1;
+ req_size = sizeof(*gai_req) + nodesize + servsize;
+
+ gai_req = emalloc_zero(req_size);
+
+ gai_req->octets = req_size;
+ gai_req->dns_idx = idx;
+ now = time(NULL);
+ gai_req->scheduled = now;
+ gai_req->earliest = max(now, child_ctx->next_dns_timeslot);
+ child_ctx->next_dns_timeslot = gai_req->earliest;
+ if (hints != NULL)
+ gai_req->hints = *hints;
+ gai_req->retry = retry;
+ gai_req->callback = callback;
+ gai_req->context = context;
+ gai_req->nodesize = nodesize;
+ gai_req->servsize = servsize;
+
+ memcpy((char *)gai_req + sizeof(*gai_req), node, nodesize);
+ memcpy((char *)gai_req + sizeof(*gai_req) + nodesize, service,
+ servsize);
+
+ if (queue_blocking_request(
+ BLOCKING_GETADDRINFO,
+ gai_req,
+ req_size,
+ &getaddrinfo_sometime_complete,
+ gai_req)) {
+
+ msyslog(LOG_ERR, "unable to queue getaddrinfo request");
+ errno = EFAULT;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+blocking_getaddrinfo(
+ blocking_child * c,
+ blocking_pipe_header * req
+ )
+{
+ blocking_gai_req * gai_req;
+ dnsworker_ctx * worker_ctx;
+ blocking_pipe_header * resp;
+ blocking_gai_resp * gai_resp;
+ char * node;
+ char * service;
+ struct addrinfo * ai_res;
+ struct addrinfo * ai;
+ struct addrinfo * serialized_ai;
+ size_t canons_octets;
+ size_t this_octets;
+ size_t resp_octets;
+ char * cp;
+ time_t time_now;
+
+ gai_req = (void *)((char *)req + sizeof(*req));
+ node = (char *)gai_req + sizeof(*gai_req);
+ service = node + gai_req->nodesize;
+
+ worker_ctx = get_worker_context(c, gai_req->dns_idx);
+ scheduled_sleep(gai_req->scheduled, gai_req->earliest,
+ worker_ctx);
+ reload_resolv_conf(worker_ctx);
+
+ /*
+ * Take a shot at the final size, better to overestimate
+ * at first and then realloc to a smaller size.
+ */
+
+ resp_octets = sizeof(*resp) + sizeof(*gai_resp) +
+ 16 * (sizeof(struct addrinfo) +
+ sizeof(sockaddr_u)) +
+ 256;
+ resp = emalloc_zero(resp_octets);
+ gai_resp = (void *)(resp + 1);
+
+ TRACE(2, ("blocking_getaddrinfo given node %s serv %s fam %d flags %x\n",
+ node, service, gai_req->hints.ai_family,
+ gai_req->hints.ai_flags));
+#ifdef DEBUG
+ if (debug >= 2)
+ fflush(stdout);
+#endif
+ ai_res = NULL;
+ gai_resp->retcode = getaddrinfo(node, service, &gai_req->hints,
+ &ai_res);
+ gai_resp->retry = gai_req->retry;
+#ifdef EAI_SYSTEM
+ if (EAI_SYSTEM == gai_resp->retcode)
+ gai_resp->gai_errno = errno;
+#endif
+ canons_octets = 0;
+
+ if (0 == gai_resp->retcode) {
+ ai = ai_res;
+ while (NULL != ai) {
+ gai_resp->ai_count++;
+ if (ai->ai_canonname)
+ canons_octets += strlen(ai->ai_canonname) + 1;
+ ai = ai->ai_next;
+ }
+ /*
+ * If this query succeeded only after retrying, DNS may have
+ * just become responsive. Ignore previously-scheduled
+ * retry sleeps once for each pending request, similar to
+ * the way scheduled_sleep() does when its worker_sleep()
+ * is interrupted.
+ */
+ if (gai_resp->retry > INITIAL_DNS_RETRY) {
+ time_now = time(NULL);
+ worker_ctx->ignore_scheduled_before = time_now;
+ TRACE(1, ("DNS success after retry, ignoring sleeps scheduled before now (%s)\n",
+ humantime(time_now)));
+ }
+ }
+
+ /*
+ * Our response consists of a header, followed by ai_count
+ * addrinfo structs followed by ai_count sockaddr_storage
+ * structs followed by the canonical names.
+ */
+ gai_resp->octets = sizeof(*gai_resp)
+ + gai_resp->ai_count
+ * (sizeof(gai_req->hints)
+ + sizeof(sockaddr_u))
+ + canons_octets;
+
+ resp_octets = sizeof(*resp) + gai_resp->octets;
+ resp = erealloc(resp, resp_octets);
+ gai_resp = (void *)(resp + 1);
+
+ /* cp serves as our current pointer while serializing */
+ cp = (void *)(gai_resp + 1);
+ canons_octets = 0;
+
+ if (0 == gai_resp->retcode) {
+ ai = ai_res;
+ while (NULL != ai) {
+ memcpy(cp, ai, sizeof(*ai));
+ serialized_ai = (void *)cp;
+ cp += sizeof(*ai);
+
+ /* transform ai_canonname into offset */
+ if (NULL != serialized_ai->ai_canonname) {
+ serialized_ai->ai_canonname = (char *)canons_octets;
+ canons_octets += strlen(ai->ai_canonname) + 1;
+ }
+
+ /* leave fixup of ai_addr pointer for receiver */
+
+ ai = ai->ai_next;
+ }
+
+ ai = ai_res;
+ while (NULL != ai) {
+ INSIST(ai->ai_addrlen <= sizeof(sockaddr_u));
+ memcpy(cp, ai->ai_addr, ai->ai_addrlen);
+ cp += sizeof(sockaddr_u);
+
+ ai = ai->ai_next;
+ }
+
+ ai = ai_res;
+ while (NULL != ai) {
+ if (NULL != ai->ai_canonname) {
+ this_octets = strlen(ai->ai_canonname) + 1;
+ memcpy(cp, ai->ai_canonname, this_octets);
+ cp += this_octets;
+ }
+
+ ai = ai->ai_next;
+ }
+ freeaddrinfo(ai_res);
+ }
+
+ /*
+ * make sure our walk and earlier calc match
+ */
+ DEBUG_INSIST((size_t)(cp - (char *)resp) == resp_octets);
+
+ if (queue_blocking_response(c, resp, resp_octets, req)) {
+ msyslog(LOG_ERR, "blocking_getaddrinfo can not queue response");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static void
+getaddrinfo_sometime_complete(
+ blocking_work_req rtype,
+ void * context,
+ size_t respsize,
+ void * resp
+ )
+{
+ blocking_gai_req * gai_req;
+ blocking_gai_resp * gai_resp;
+ dnschild_ctx * child_ctx;
+ struct addrinfo * ai;
+ struct addrinfo * next_ai;
+ sockaddr_u * psau;
+ char * node;
+ char * service;
+ char * canon_start;
+ time_t time_now;
+ int again;
+ int af;
+ const char * fam_spec;
+ int i;
+
+ gai_req = context;
+ gai_resp = resp;
+
+ DEBUG_REQUIRE(BLOCKING_GETADDRINFO == rtype);
+ DEBUG_REQUIRE(respsize == gai_resp->octets);
+
+ node = (char *)gai_req + sizeof(*gai_req);
+ service = node + gai_req->nodesize;
+
+ child_ctx = dnschild_contexts[gai_req->dns_idx];
+
+ if (0 == gai_resp->retcode) {
+ /*
+ * If this query succeeded only after retrying, DNS may have
+ * just become responsive.
+ */
+ if (gai_resp->retry > INITIAL_DNS_RETRY) {
+ time_now = time(NULL);
+ child_ctx->next_dns_timeslot = time_now;
+ TRACE(1, ("DNS success after retry, %u next_dns_timeslot reset (%s)\n",
+ gai_req->dns_idx, humantime(time_now)));
+ }
+ } else {
+ again = should_retry_dns(gai_resp->retcode,
+ gai_resp->gai_errno);
+ /*
+ * exponential backoff of DNS retries to 64s
+ */
+ if (gai_req->retry > 0 && again) {
+ /* log the first retry only */
+ if (INITIAL_DNS_RETRY == gai_req->retry)
+ NLOG(NLOG_SYSINFO) {
+ af = gai_req->hints.ai_family;
+ fam_spec = (AF_INET6 == af)
+ ? " (AAAA)"
+ : (AF_INET == af)
+ ? " (A)"
+ : "";
+#ifdef EAI_SYSTEM
+ if (EAI_SYSTEM == gai_resp->retcode) {
+ errno = gai_resp->gai_errno;
+ msyslog(LOG_INFO,
+ "retrying DNS %s%s: EAI_SYSTEM %d: %m",
+ node, fam_spec,
+ gai_resp->gai_errno);
+ } else
+#endif
+ msyslog(LOG_INFO,
+ "retrying DNS %s%s: %s (%d)",
+ node, fam_spec,
+ gai_strerror(gai_resp->retcode),
+ gai_resp->retcode);
+ }
+ manage_dns_retry_interval(&gai_req->scheduled,
+ &gai_req->earliest, &gai_req->retry,
+ &child_ctx->next_dns_timeslot);
+ if (!queue_blocking_request(
+ BLOCKING_GETADDRINFO,
+ gai_req,
+ gai_req->octets,
+ &getaddrinfo_sometime_complete,
+ gai_req))
+ return;
+ else
+ msyslog(LOG_ERR,
+ "unable to retry hostname %s",
+ node);
+ }
+ }
+
+ /*
+ * fixup pointers in returned addrinfo array
+ */
+ ai = (void *)((char *)gai_resp + sizeof(*gai_resp));
+ next_ai = NULL;
+ for (i = gai_resp->ai_count - 1; i >= 0; i--) {
+ ai[i].ai_next = next_ai;
+ next_ai = &ai[i];
+ }
+
+ psau = (void *)((char *)ai + gai_resp->ai_count * sizeof(*ai));
+ canon_start = (char *)psau + gai_resp->ai_count * sizeof(*psau);
+
+ for (i = 0; i < gai_resp->ai_count; i++) {
+ if (NULL != ai[i].ai_addr)
+ ai[i].ai_addr = &psau->sa;
+ psau++;
+ if (NULL != ai[i].ai_canonname)
+ ai[i].ai_canonname += (size_t)canon_start;
+ }
+
+ ENSURE((char *)psau == canon_start);
+
+ if (!gai_resp->ai_count)
+ ai = NULL;
+
+ (*gai_req->callback)(gai_resp->retcode, gai_resp->gai_errno,
+ gai_req->context, node, service,
+ &gai_req->hints, ai);
+
+ free(gai_req);
+ /* gai_resp is part of block freed by process_blocking_resp() */
+}
+
+
+#ifdef TEST_BLOCKING_WORKER
+void gai_test_callback(int rescode, int gai_errno, void *context, const char *name, const char *service, const struct addrinfo *hints, const struct addrinfo *ai_res)
+{
+ sockaddr_u addr;
+
+ if (rescode) {
+ TRACE(1, ("gai_test_callback context %p error rescode %d %s serv %s\n",
+ context, rescode, name, service));
+ return;
+ }
+ while (!rescode && NULL != ai_res) {
+ ZERO_SOCK(&addr);
+ memcpy(&addr, ai_res->ai_addr, ai_res->ai_addrlen);
+ TRACE(1, ("ctx %p fam %d addr %s canon '%s' type %s at %p ai_addr %p ai_next %p\n",
+ context,
+ AF(&addr),
+ stoa(&addr),
+ (ai_res->ai_canonname)
+ ? ai_res->ai_canonname
+ : "",
+ (SOCK_DGRAM == ai_res->ai_socktype)
+ ? "DGRAM"
+ : (SOCK_STREAM == ai_res->ai_socktype)
+ ? "STREAM"
+ : "(other)",
+ ai_res,
+ ai_res->ai_addr,
+ ai_res->ai_next));
+
+ getnameinfo_sometime((sockaddr_u *)ai_res->ai_addr, 128, 32, 0, gni_test_callback, context);
+
+ ai_res = ai_res->ai_next;
+ }
+}
+#endif /* TEST_BLOCKING_WORKER */
+
+
+int
+getnameinfo_sometime(
+ sockaddr_u * psau,
+ size_t hostoctets,
+ size_t servoctets,
+ int flags,
+ gni_sometime_callback callback,
+ void * context
+ )
+{
+ blocking_gni_req * gni_req;
+ u_int idx;
+ dnschild_ctx * child_ctx;
+ time_t time_now;
+
+ REQUIRE(hostoctets);
+ REQUIRE(hostoctets + servoctets < 1024);
+
+ idx = get_dnschild_ctx();
+ child_ctx = dnschild_contexts[idx];
+
+ gni_req = emalloc_zero(sizeof(*gni_req));
+
+ gni_req->octets = sizeof(*gni_req);
+ gni_req->dns_idx = idx;
+ time_now = time(NULL);
+ gni_req->scheduled = time_now;
+ gni_req->earliest = max(time_now, child_ctx->next_dns_timeslot);
+ child_ctx->next_dns_timeslot = gni_req->earliest;
+ memcpy(&gni_req->socku, psau, SOCKLEN(psau));
+ gni_req->hostoctets = hostoctets;
+ gni_req->servoctets = servoctets;
+ gni_req->flags = flags;
+ gni_req->retry = INITIAL_DNS_RETRY;
+ gni_req->callback = callback;
+ gni_req->context = context;
+
+ if (queue_blocking_request(
+ BLOCKING_GETNAMEINFO,
+ gni_req,
+ sizeof(*gni_req),
+ &getnameinfo_sometime_complete,
+ gni_req)) {
+
+ msyslog(LOG_ERR, "unable to queue getnameinfo request");
+ errno = EFAULT;
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+blocking_getnameinfo(
+ blocking_child * c,
+ blocking_pipe_header * req
+ )
+{
+ blocking_gni_req * gni_req;
+ dnsworker_ctx * worker_ctx;
+ blocking_pipe_header * resp;
+ blocking_gni_resp * gni_resp;
+ size_t octets;
+ size_t resp_octets;
+ char * service;
+ char * cp;
+ int rc;
+ time_t time_now;
+ char host[1024];
+
+ gni_req = (void *)((char *)req + sizeof(*req));
+
+ octets = gni_req->hostoctets + gni_req->servoctets;
+
+ /*
+ * Some alloca() implementations are fragile regarding
+ * large allocations. We only need room for the host
+ * and service names.
+ */
+ REQUIRE(octets < sizeof(host));
+ service = host + gni_req->hostoctets;
+
+ worker_ctx = get_worker_context(c, gni_req->dns_idx);
+ scheduled_sleep(gni_req->scheduled, gni_req->earliest,
+ worker_ctx);
+ reload_resolv_conf(worker_ctx);
+
+ /*
+ * Take a shot at the final size, better to overestimate
+ * then realloc to a smaller size.
+ */
+
+ resp_octets = sizeof(*resp) + sizeof(*gni_resp) + octets;
+ resp = emalloc_zero(resp_octets);
+ gni_resp = (void *)((char *)resp + sizeof(*resp));
+
+ TRACE(2, ("blocking_getnameinfo given addr %s flags 0x%x hostlen %lu servlen %lu\n",
+ stoa(&gni_req->socku), gni_req->flags,
+ (u_long)gni_req->hostoctets, (u_long)gni_req->servoctets));
+
+ gni_resp->retcode = getnameinfo(&gni_req->socku.sa,
+ SOCKLEN(&gni_req->socku),
+ host,
+ gni_req->hostoctets,
+ service,
+ gni_req->servoctets,
+ gni_req->flags);
+ gni_resp->retry = gni_req->retry;
+#ifdef EAI_SYSTEM
+ if (EAI_SYSTEM == gni_resp->retcode)
+ gni_resp->gni_errno = errno;
+#endif
+
+ if (0 != gni_resp->retcode) {
+ gni_resp->hostoctets = 0;
+ gni_resp->servoctets = 0;
+ } else {
+ gni_resp->hostoctets = strlen(host) + 1;
+ gni_resp->servoctets = strlen(service) + 1;
+ /*
+ * If this query succeeded only after retrying, DNS may have
+ * just become responsive. Ignore previously-scheduled
+ * retry sleeps once for each pending request, similar to
+ * the way scheduled_sleep() does when its worker_sleep()
+ * is interrupted.
+ */
+ if (gni_req->retry > INITIAL_DNS_RETRY) {
+ time_now = time(NULL);
+ worker_ctx->ignore_scheduled_before = time_now;
+ TRACE(1, ("DNS success after retrying, ignoring sleeps scheduled before now (%s)\n",
+ humantime(time_now)));
+ }
+ }
+ octets = gni_resp->hostoctets + gni_resp->servoctets;
+ /*
+ * Our response consists of a header, followed by the host and
+ * service strings, each null-terminated.
+ */
+ resp_octets = sizeof(*resp) + sizeof(*gni_resp) + octets;
+
+ resp = erealloc(resp, resp_octets);
+ gni_resp = (void *)(resp + 1);
+
+ gni_resp->octets = sizeof(*gni_resp) + octets;
+
+ /* cp serves as our current pointer while serializing */
+ cp = (void *)(gni_resp + 1);
+
+ if (0 == gni_resp->retcode) {
+ memcpy(cp, host, gni_resp->hostoctets);
+ cp += gni_resp->hostoctets;
+ memcpy(cp, service, gni_resp->servoctets);
+ cp += gni_resp->servoctets;
+ }
+
+ INSIST((size_t)(cp - (char *)resp) == resp_octets);
+ INSIST(resp_octets - sizeof(*resp) == gni_resp->octets);
+
+ rc = queue_blocking_response(c, resp, resp_octets, req);
+ if (rc)
+ msyslog(LOG_ERR, "blocking_getnameinfo unable to queue response");
+ return rc;
+}
+
+
+static void
+getnameinfo_sometime_complete(
+ blocking_work_req rtype,
+ void * context,
+ size_t respsize,
+ void * resp
+ )
+{
+ blocking_gni_req * gni_req;
+ blocking_gni_resp * gni_resp;
+ dnschild_ctx * child_ctx;
+ char * host;
+ char * service;
+ time_t time_now;
+ int again;
+
+ gni_req = context;
+ gni_resp = resp;
+
+ DEBUG_REQUIRE(BLOCKING_GETNAMEINFO == rtype);
+ DEBUG_REQUIRE(respsize == gni_resp->octets);
+
+ child_ctx = dnschild_contexts[gni_req->dns_idx];
+
+ if (0 == gni_resp->retcode) {
+ /*
+ * If this query succeeded only after retrying, DNS may have
+ * just become responsive.
+ */
+ if (gni_resp->retry > INITIAL_DNS_RETRY) {
+ time_now = time(NULL);
+ child_ctx->next_dns_timeslot = time_now;
+ TRACE(1, ("DNS success after retry, %u next_dns_timeslot reset (%s)\n",
+ gni_req->dns_idx, humantime(time_now)));
+ }
+ } else {
+ again = should_retry_dns(gni_resp->retcode, gni_resp->gni_errno);
+ /*
+ * exponential backoff of DNS retries to 64s
+ */
+ if (gni_req->retry > 0)
+ manage_dns_retry_interval(&gni_req->scheduled,
+ &gni_req->earliest, &gni_req->retry,
+ &child_ctx->next_dns_timeslot);
+
+ if (gni_req->retry > 0 && again) {
+ if (!queue_blocking_request(
+ BLOCKING_GETNAMEINFO,
+ gni_req,
+ gni_req->octets,
+ &getnameinfo_sometime_complete,
+ gni_req))
+ return;
+
+ msyslog(LOG_ERR, "unable to retry reverse lookup of %s", stoa(&gni_req->socku));
+ }
+ }
+
+ if (!gni_resp->hostoctets) {
+ host = NULL;
+ service = NULL;
+ } else {
+ host = (char *)gni_resp + sizeof(*gni_resp);
+ service = (gni_resp->servoctets)
+ ? host + gni_resp->hostoctets
+ : NULL;
+ }
+
+ (*gni_req->callback)(gni_resp->retcode, gni_resp->gni_errno,
+ &gni_req->socku, gni_req->flags, host,
+ service, gni_req->context);
+
+ free(gni_req);
+ /* gni_resp is part of block freed by process_blocking_resp() */
+}
+
+
+#ifdef TEST_BLOCKING_WORKER
+void gni_test_callback(int rescode, int gni_errno, sockaddr_u *psau, int flags, const char *host, const char *service, void *context)
+{
+ if (!rescode)
+ TRACE(1, ("gni_test_callback got host '%s' serv '%s' for addr %s context %p\n",
+ host, service, stoa(psau), context));
+ else
+ TRACE(1, ("gni_test_callback context %p rescode %d gni_errno %d flags 0x%x addr %s\n",
+ context, rescode, gni_errno, flags, stoa(psau)));
+}
+#endif /* TEST_BLOCKING_WORKER */
+
+
+#ifdef HAVE_RES_INIT
+static void
+reload_resolv_conf(
+ dnsworker_ctx * worker_ctx
+ )
+{
+ time_t time_now;
+
+ /*
+ * This is ad-hoc. Reload /etc/resolv.conf once per minute
+ * to pick up on changes from the DHCP client. [Bug 1226]
+ * When using threads for the workers, this needs to happen
+ * only once per minute process-wide.
+ */
+ time_now = time(NULL);
+# ifdef WORK_THREAD
+ worker_ctx->next_res_init = next_res_init;
+# endif
+ if (worker_ctx->next_res_init <= time_now) {
+ if (worker_ctx->next_res_init != 0)
+ res_init();
+ worker_ctx->next_res_init = time_now + 60;
+# ifdef WORK_THREAD
+ next_res_init = worker_ctx->next_res_init;
+# endif
+ }
+}
+#endif /* HAVE_RES_INIT */
+
+
+static u_int
+reserve_dnschild_ctx(void)
+{
+ const size_t ps = sizeof(dnschild_contexts[0]);
+ const size_t cs = sizeof(*dnschild_contexts[0]);
+ u_int c;
+ u_int new_alloc;
+ size_t octets;
+ size_t new_octets;
+
+ c = 0;
+ while (TRUE) {
+ for ( ; c < dnschild_contexts_alloc; c++) {
+ if (NULL == dnschild_contexts[c]) {
+ dnschild_contexts[c] = emalloc_zero(cs);
+
+ return c;
+ }
+ }
+ new_alloc = dnschild_contexts_alloc + 20;
+ new_octets = new_alloc * ps;
+ octets = dnschild_contexts_alloc * ps;
+ dnschild_contexts = erealloc_zero(dnschild_contexts,
+ new_octets, octets);
+ dnschild_contexts_alloc = new_alloc;
+ }
+}
+
+
+static u_int
+get_dnschild_ctx(void)
+{
+ static u_int shared_ctx = UINT_MAX;
+
+ if (worker_per_query)
+ return reserve_dnschild_ctx();
+
+ if (UINT_MAX == shared_ctx)
+ shared_ctx = reserve_dnschild_ctx();
+
+ return shared_ctx;
+}
+
+
+static void
+alloc_dnsworker_context(
+ u_int idx
+ )
+{
+ const size_t worker_context_sz = sizeof(*dnsworker_contexts[0]);
+
+ REQUIRE(NULL == dnsworker_contexts[idx]);
+ dnsworker_contexts[idx] = emalloc_zero(worker_context_sz);
+}
+
+
+static dnsworker_ctx *
+get_worker_context(
+ blocking_child * c,
+ u_int idx
+ )
+{
+ static size_t ps = sizeof(dnsworker_contexts[0]);
+ u_int min_new_alloc;
+ u_int new_alloc;
+ size_t octets;
+ size_t new_octets;
+
+ if (dnsworker_contexts_alloc <= idx) {
+ min_new_alloc = 1 + idx;
+ /* round new_alloc up to nearest multiple of 4 */
+ new_alloc = (min_new_alloc + 4) & ~(4 - 1);
+ new_octets = new_alloc * ps;
+ octets = dnsworker_contexts_alloc * ps;
+ dnsworker_contexts = erealloc_zero(dnsworker_contexts,
+ new_octets, octets);
+ dnsworker_contexts_alloc = new_alloc;
+ }
+
+ if (NULL == dnsworker_contexts[idx])
+ alloc_dnsworker_context(idx);
+ ZERO(*dnsworker_contexts[idx]);
+ dnsworker_contexts[idx]->c = c;
+
+ return dnsworker_contexts[idx];
+}
+
+
+static void
+scheduled_sleep(
+ time_t scheduled,
+ time_t earliest,
+ dnsworker_ctx * worker_ctx
+ )
+{
+ time_t now;
+
+ if (scheduled < worker_ctx->ignore_scheduled_before) {
+ TRACE(1, ("ignoring sleep until %s scheduled at %s (before %s)\n",
+ humantime(earliest), humantime(scheduled),
+ humantime(worker_ctx->ignore_scheduled_before)));
+ return;
+ }
+
+ now = time(NULL);
+
+ if (now < earliest) {
+ TRACE(1, ("sleep until %s scheduled at %s (>= %s)\n",
+ humantime(earliest), humantime(scheduled),
+ humantime(worker_ctx->ignore_scheduled_before)));
+ if (-1 == worker_sleep(worker_ctx->c, earliest - now)) {
+ /* our sleep was interrupted */
+ now = time(NULL);
+ worker_ctx->ignore_scheduled_before = now;
+#ifdef HAVE_RES_INIT
+ worker_ctx->next_res_init = now + 60;
+ next_res_init = worker_ctx->next_res_init;
+ res_init();
+#endif
+ TRACE(1, ("sleep interrupted by daemon, ignoring sleeps scheduled before now (%s)\n",
+ humantime(worker_ctx->ignore_scheduled_before)));
+ }
+ }
+}
+
+
+/*
+ * manage_dns_retry_interval is a helper used by
+ * getaddrinfo_sometime_complete and getnameinfo_sometime_complete
+ * to calculate the new retry interval and schedule the next query.
+ */
+static void
+manage_dns_retry_interval(
+ time_t * pscheduled,
+ time_t * pwhen,
+ int * pretry,
+ time_t * pnext_timeslot
+ )
+{
+ time_t now;
+ time_t when;
+ int retry;
+
+ now = time(NULL);
+ retry = *pretry;
+ when = max(now + retry, *pnext_timeslot);
+ *pnext_timeslot = when;
+ retry = min(64, retry << 1);
+
+ *pscheduled = now;
+ *pwhen = when;
+ *pretry = retry;
+}
+
+/*
+ * should_retry_dns is a helper used by getaddrinfo_sometime_complete
+ * and getnameinfo_sometime_complete which implements ntpd's DNS retry
+ * policy.
+ */
+static int
+should_retry_dns(
+ int rescode,
+ int res_errno
+ )
+{
+ static int eai_again_seen;
+ int again;
+#if defined (EAI_SYSTEM) && defined(DEBUG)
+ char msg[256];
+#endif
+
+ /*
+ * If the resolver failed, see if the failure is
+ * temporary. If so, return success.
+ */
+ again = 0;
+
+ switch (rescode) {
+
+ case EAI_FAIL:
+ again = 1;
+ break;
+
+ case EAI_AGAIN:
+ again = 1;
+ eai_again_seen = 1; /* [Bug 1178] */
+ break;
+
+ case EAI_NONAME:
+#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME)
+ case EAI_NODATA:
+#endif
+ again = !eai_again_seen; /* [Bug 1178] */
+ break;
+
+#ifdef EAI_SYSTEM
+ case EAI_SYSTEM:
+ /*
+ * EAI_SYSTEM means the real error is in errno. We should be more
+ * discriminating about which errno values require retrying, but
+ * this matches existing behavior.
+ */
+ again = 1;
+# ifdef DEBUG
+ errno_to_str(res_errno, msg, sizeof(msg));
+ TRACE(1, ("intres: EAI_SYSTEM errno %d (%s) means try again, right?\n",
+ res_errno, msg));
+# endif
+ break;
+#endif
+ }
+
+ TRACE(2, ("intres: resolver returned: %s (%d), %sretrying\n",
+ gai_strerror(rescode), rescode, again ? "" : "not "));
+
+ return again;
+}
+
+#else /* !WORKER follows */
+int ntp_intres_nonempty_compilation_unit;
+#endif
diff --git a/contrib/ntp/libntp/ntp_libopts.c b/contrib/ntp/libntp/ntp_libopts.c
new file mode 100644
index 0000000..c504f8b
--- /dev/null
+++ b/contrib/ntp/libntp/ntp_libopts.c
@@ -0,0 +1,58 @@
+/*
+ * ntp_libopts.c
+ *
+ * Common code interfacing with Autogen's libopts command-line option
+ * processing.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include "ntp_libopts.h"
+#include "ntp_stdlib.h"
+
+extern const char *Version; /* version.c for each program */
+
+
+/*
+ * ntpOptionProcess() was a clone of libopts' optionProcess which
+ * overrode the --version output, appending detail from version.c
+ * which was not available at Autogen time. This is now done via
+ * AutoOpts' version-proc = override in copyright.def, so this
+ * routine is a straightforward wrapper of optionProcess().
+ */
+int
+ntpOptionProcess(
+ tOptions * pOpts,
+ int argc,
+ char ** argv
+ )
+{
+ return optionProcess(pOpts, argc, argv);
+}
+
+
+/*
+ * ntpOptionPrintVersion() replaces the stock optionPrintVersion() via
+ * version-proc = ntpOptionPrintVersion; in copyright.def. It differs
+ * from the stock function by displaying the complete version string,
+ * including compile time which was unknown when Autogen ran.
+ *
+ * Like optionPrintVersion() this function must exit(0) rather than
+ * return.
+ */
+void
+ntpOptionPrintVersion(
+ tOptions * pOpts,
+ tOptDesc * pOD
+ )
+{
+ UNUSED_ARG(pOpts);
+ UNUSED_ARG(pOD);
+
+ printf("%s\n", Version);
+ fflush(stdout);
+ exit(EXIT_SUCCESS);
+}
diff --git a/contrib/ntp/libntp/ntp_lineedit.c b/contrib/ntp/libntp/ntp_lineedit.c
new file mode 100644
index 0000000..a2b2d29
--- /dev/null
+++ b/contrib/ntp/libntp/ntp_lineedit.c
@@ -0,0 +1,245 @@
+/*
+ * ntp_lineedit.c - generic interface to various line editing libs
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#if defined(HAVE_READLINE_HISTORY) && \
+ (!defined(HAVE_READLINE_HISTORY_H) || \
+ !defined(HAVE_READLINE_READLINE_H))
+# undef HAVE_READLINE_HISTORY
+#endif
+#if defined(HAVE_READLINE_HISTORY)
+# include <readline/readline.h>
+# include <readline/history.h>
+# define LE_READLINE
+#elif defined(HAVE_HISTEDIT_H)
+# include <histedit.h>
+# define LE_EDITLINE
+#else
+# define LE_NONE
+#endif
+
+#include "ntp.h"
+#include "ntp_stdlib.h"
+#include "ntp_lineedit.h"
+
+#define MAXEDITLINE 512
+
+/*
+ * external references
+ */
+
+extern char const * progname;
+
+/*
+ * globals, private prototypes
+ */
+
+static int ntp_readline_initted;
+static char * lineedit_prompt;
+
+
+#ifdef LE_EDITLINE
+# ifndef H_SETSIZE
+# define H_SETSIZE H_EVENT
+# endif
+static EditLine * ntp_el;
+static History * ntp_hist;
+static HistEvent hev;
+
+char * ntp_prompt_callback(EditLine *);
+#endif /* LE_EDITLINE */
+
+
+/*
+ * ntp_readline_init - setup, set or reset prompt string
+ */
+int
+ntp_readline_init(
+ const char * prompt
+ )
+{
+ int success;
+
+ success = 1;
+
+ if (prompt) {
+ if (lineedit_prompt)
+ free(lineedit_prompt);
+ lineedit_prompt = estrdup(prompt);
+ }
+
+#ifdef LE_EDITLINE
+ if (NULL == ntp_el) {
+
+# if 4 == EL_INIT_ARGS
+ ntp_el = el_init(progname, stdin, stdout, stderr);
+# else
+ ntp_el = el_init(progname, stdin, stdout);
+# endif
+ if (ntp_el) {
+
+ el_set(ntp_el, EL_PROMPT, ntp_prompt_callback);
+ el_set(ntp_el, EL_EDITOR, "emacs");
+
+ ntp_hist = history_init();
+
+ if (NULL == ntp_hist) {
+
+ mfprintf(stderr, "history_init(): %m\n");
+ fflush(stderr);
+
+ el_end(ntp_el);
+ ntp_el = NULL;
+
+ success = 0;
+
+ } else {
+ ZERO(hev);
+#ifdef H_SETSIZE
+ history(ntp_hist, &hev, H_SETSIZE, 128);
+#endif
+ el_set(ntp_el, EL_HIST, history,
+ ntp_hist);
+ /* use any .editrc */
+ el_source(ntp_el, NULL);
+ }
+ } else
+ success = 0;
+ }
+#endif /* LE_EDITLINE */
+
+ ntp_readline_initted = success;
+
+ return success;
+}
+
+
+/*
+ * ntp_readline_uninit - release resources
+ */
+void
+ntp_readline_uninit(
+ void
+ )
+{
+#ifdef LE_EDITLINE
+ if (ntp_el) {
+ el_end(ntp_el);
+ ntp_el = NULL;
+
+ history_end(ntp_hist);
+ ntp_hist = NULL;
+ }
+#endif /* LE_EDITLINE */
+
+ if (lineedit_prompt) {
+ free(lineedit_prompt);
+ lineedit_prompt = NULL;
+ }
+
+ ntp_readline_initted = 0;
+}
+
+
+/*
+ * ntp_readline - read a line with the line editor available
+ *
+ * The string returned must be released with free()
+ */
+
+char *
+ntp_readline(
+ int * pcount
+ )
+{
+ char * line;
+#ifdef LE_NONE
+ char line_buf[MAXEDITLINE];
+#endif
+#ifdef LE_EDITLINE
+ const char * cline;
+#endif
+
+ if (!ntp_readline_initted)
+ return NULL;
+
+ *pcount = 0;
+
+#ifdef LE_READLINE
+ line = readline(lineedit_prompt ? lineedit_prompt : "");
+ if (NULL != line) {
+ if (*line) {
+ add_history(line);
+ }
+ *pcount = strlen(line);
+ }
+#endif /* LE_READLINE */
+
+#ifdef LE_EDITLINE
+ cline = el_gets(ntp_el, pcount);
+
+ if (NULL != cline) {
+ history(ntp_hist, &hev, H_ENTER, cline);
+ line = estrdup(cline);
+ } else if (*pcount == -1) {
+ line = NULL;
+ } else {
+ line = estrdup("");
+ }
+#endif /* LE_EDITLINE */
+
+#ifdef LE_NONE
+ /* stone hammers */
+ if (lineedit_prompt) {
+# ifdef VMS
+ /*
+ * work around problem mixing
+ * stdout & stderr
+ */
+ fputs("", stdout);
+# endif /* VMS */
+
+ fputs(lineedit_prompt, stderr);
+ fflush(stderr);
+ }
+
+ line = fgets(line_buf, sizeof(line_buf), stdin);
+ if (NULL != line && *line) {
+ *pcount = strlen(line);
+ line = estrdup(line);
+ } else
+ line = NULL;
+
+#endif /* LE_NONE */
+
+
+ if (!line) /* EOF */
+ fputs("\n", stderr);
+
+ return line;
+}
+
+
+#ifdef LE_EDITLINE
+/*
+ * ntp_prompt_callback - return prompt string to el_gets()
+ */
+char *
+ntp_prompt_callback(
+ EditLine *el
+ )
+{
+ UNUSED_ARG(el);
+
+ return lineedit_prompt;
+}
+#endif /* LE_EDITLINE */
+
diff --git a/contrib/ntp/libntp/ntp_random.c b/contrib/ntp/libntp/ntp_random.c
index 700b4ee..0ada44f 100644
--- a/contrib/ntp/libntp/ntp_random.c
+++ b/contrib/ntp/libntp/ntp_random.c
@@ -39,15 +39,13 @@ static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95";
#endif /* LIBC_SCCS and not lint */
#include "config.h"
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
-#include <ntp_types.h>
+#include <l_stdlib.h>
#include <ntp_random.h>
#include <ntp_unixtime.h>
@@ -142,15 +140,8 @@ static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95";
#define DEG_4 63
#define SEP_4 1
-/*
- * Array versions of the above information to make code run faster --
- * relies on fact that TYPE_i == i.
- */
#define MAX_TYPES 5 /* max number of types above */
-static long degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
-static long seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
-
/*
* Initially, everything is set up as if from:
*
@@ -165,7 +156,7 @@ static long seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
* MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
*/
-static long randtbl[DEG_3 + 1] = {
+static unsigned long randtbl[DEG_3 + 1] = {
TYPE_3,
#ifdef USE_WEAK_SEEDING
/* Historic implementation compatibility */
@@ -200,8 +191,8 @@ static long randtbl[DEG_3 + 1] = {
* in the initialization of randtbl) because the state table pointer is set
* to point to randtbl[1] (as explained below).
*/
-static long *fptr = &randtbl[SEP_3 + 1];
-static long *rptr = &randtbl[1];
+static unsigned long *fptr = &randtbl[SEP_3 + 1];
+static unsigned long *rptr = &randtbl[1];
/*
* The following things are the pointer to the state information table, the
@@ -213,13 +204,13 @@ static long *rptr = &randtbl[1];
* this is more efficient than indexing every time to find the address of
* the last element to see if the front and rear pointers have wrapped.
*/
-static long *state = &randtbl[1];
+static unsigned long *state = &randtbl[1];
static long rand_type = TYPE_3;
static long rand_deg = DEG_3;
static long rand_sep = SEP_3;
-static long *end_ptr = &randtbl[DEG_3 + 1];
+static unsigned long *end_ptr = &randtbl[DEG_3 + 1];
-static inline long good_rand P((long));
+static inline long good_rand (long);
static inline long
good_rand (
@@ -270,19 +261,22 @@ ntp_srandom(
unsigned long x
)
{
- register long i;
+ long i;
- if (rand_type == TYPE_0)
+ if (rand_type == TYPE_0) {
state[0] = x;
- else {
+ } else {
state[0] = x;
for (i = 1; i < rand_deg; i++)
state[i] = good_rand(state[i - 1]);
fptr = &state[rand_sep];
rptr = &state[0];
for (i = 0; i < 10 * rand_deg; i++)
- (void)ntp_random();
+ x = ntp_random();
}
+
+ /* seed the likely faster (and poorer) rand() as well */
+ srand((u_int)x);
}
/*
@@ -309,6 +303,24 @@ ntp_srandomdev( void )
}
#endif
+
+/*
+ * ntp_initstate() and ntp_setstate() are unused in our codebase and
+ * trigger warnings due to casting to a more-strictly-aligned pointer
+ * on alignment-sensitive platforms. #ifdef them away to save noise,
+ * build time, and binary space, but retain the code in case we find a
+ * use.
+ */
+#ifdef COMPILE_UNUSED_FUNCTIONS
+/*
+ * Array versions of the above information to make code run faster --
+ * relies on fact that TYPE_i == i.
+ */
+#define MAX_TYPES 5 /* max number of types above */
+
+static long degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
+static long seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
+
/*
* initstate:
*
@@ -372,7 +384,7 @@ ntp_initstate(
rand_deg = DEG_4;
rand_sep = SEP_4;
}
- state = (long *) (long_arg_state + 1); /* first location */
+ state = (unsigned long *) (long_arg_state + 1); /* first location */
end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
ntp_srandom(seed);
if (rand_type == TYPE_0)
@@ -406,7 +418,7 @@ ntp_setstate(
char *arg_state /* pointer to state array */
)
{
- register long *new_state = (long *) arg_state;
+ register unsigned long *new_state = (unsigned long *) arg_state;
register long type = new_state[0] % MAX_TYPES;
register long rear = new_state[0] / MAX_TYPES;
char *ostate = (char *)(&state[-1]);
@@ -429,7 +441,7 @@ ntp_setstate(
(void)fprintf(stderr,
"random: state info corrupted; not changed.\n");
}
- state = (long *) (new_state + 1);
+ state = (new_state + 1);
if (rand_type != TYPE_0) {
rptr = &state[rear];
fptr = &state[(rear + rand_sep) % rand_deg];
@@ -437,6 +449,8 @@ ntp_setstate(
end_ptr = &state[rand_deg]; /* set end_ptr too */
return(ostate);
}
+#endif /* COMPILE_UNUSED_FUNCTIONS */
+
/*
* random:
@@ -459,7 +473,7 @@ long
ntp_random( void )
{
register long i;
- register long *f, *r;
+ register unsigned long *f, *r;
if (rand_type == TYPE_0) {
i = state[0];
diff --git a/contrib/ntp/libntp/ntp_rfc2553.c b/contrib/ntp/libntp/ntp_rfc2553.c
index 017ef83..a9ebb4b 100644
--- a/contrib/ntp/libntp/ntp_rfc2553.c
+++ b/contrib/ntp/libntp/ntp_rfc2553.c
@@ -69,7 +69,9 @@
#include <sys/types.h>
#include <ctype.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
#include <isc/net.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
@@ -78,8 +80,152 @@
#include "ntpd.h"
#include "ntp_malloc.h"
-#include "ntp_stdlib.h"
#include "ntp_string.h"
+#include "ntp_debug.h"
+
+
+/*
+ * copy_addrinfo() - copy a single addrinfo to malloc()'d block.
+ * copy_addrinfo_list() - copy an addrinfo list to malloc()'d block.
+ *
+ * Copies an addrinfo list and its associated data to a contiguous block
+ * of storage from emalloc(). Callback routines invoked via
+ * getaddrinfo_sometime() have access to the resulting addrinfo list
+ * only until they return. This routine provides an easy way to make a
+ * persistent copy. Although the list provided to gai_sometime_callback
+ * routines is similarly contiguous, to keep this code usable in any
+ * context where we might want to duplicate an addrinfo list, it does
+ * not require the input list be contiguous.
+ *
+ * The returned list head pointer is passed to free() to release the
+ * entire list.
+ *
+ * In keeping with the rest of the NTP distribution, sockaddr_u is used
+ * in preference to struct sockaddr_storage, which is a member of the
+ * former union and so compatible.
+ *
+ * The rest of ntp_rfc2553.c is conditioned on ISC_PLATFORM_HAVEIPV6
+ * not being defined, copy_addrinfo_*() are exceptions.
+ */
+struct addrinfo * copy_addrinfo_common(const struct addrinfo *, int
+#ifdef EREALLOC_CALLSITE
+ ,
+ const char *, int
+#endif
+ );
+
+
+struct addrinfo *
+copy_addrinfo_impl(
+ const struct addrinfo * src
+#ifdef EREALLOC_CALLSITE
+ ,
+ const char * caller_file,
+ int caller_line
+#endif
+ )
+{
+ return copy_addrinfo_common(src, TRUE
+#ifdef EREALLOC_CALLSITE
+ ,
+ caller_file, caller_line
+#endif
+ );
+}
+
+
+struct addrinfo *
+copy_addrinfo_list_impl(
+ const struct addrinfo * src
+#ifdef EREALLOC_CALLSITE
+ ,
+ const char * caller_file,
+ int caller_line
+#endif
+ )
+{
+ return copy_addrinfo_common(src, FALSE
+#ifdef EREALLOC_CALLSITE
+ ,
+ caller_file, caller_line
+#endif
+ );
+}
+
+
+struct addrinfo *
+copy_addrinfo_common(
+ const struct addrinfo * src,
+ int just_one
+#ifdef EREALLOC_CALLSITE
+ ,
+ const char * caller_file,
+ int caller_line
+#endif
+ )
+{
+ const struct addrinfo * ai_src;
+ const struct addrinfo * ai_nxt;
+ struct addrinfo * ai_cpy;
+ struct addrinfo * dst;
+ sockaddr_u * psau;
+ char * pcanon;
+ u_int elements;
+ size_t octets;
+ size_t canons_octets;
+ size_t str_octets;
+
+ elements = 0;
+ canons_octets = 0;
+
+ for (ai_src = src; NULL != ai_src; ai_src = ai_nxt) {
+ if (just_one)
+ ai_nxt = NULL;
+ else
+ ai_nxt = ai_src->ai_next;
+ ++elements;
+ if (NULL != ai_src->ai_canonname)
+ canons_octets += 1 + strlen(ai_src->ai_canonname);
+ }
+
+ octets = elements * (sizeof(*ai_cpy) + sizeof(*psau));
+ octets += canons_octets;
+
+ dst = erealloczsite(NULL, octets, 0, TRUE, caller_file,
+ caller_line);
+ ai_cpy = dst;
+ psau = (void *)(ai_cpy + elements);
+ pcanon = (void *)(psau + elements);
+
+ for (ai_src = src; NULL != ai_src; ai_src = ai_nxt) {
+ if (just_one)
+ ai_nxt = NULL;
+ else
+ ai_nxt = ai_src->ai_next;
+ *ai_cpy = *ai_src;
+ REQUIRE(ai_src->ai_addrlen <= sizeof(sockaddr_u));
+ memcpy(psau, ai_src->ai_addr, ai_src->ai_addrlen);
+ ai_cpy->ai_addr = &psau->sa;
+ ++psau;
+ if (NULL != ai_cpy->ai_canonname) {
+ ai_cpy->ai_canonname = pcanon;
+ str_octets = 1 + strlen(ai_src->ai_canonname);
+ memcpy(pcanon, ai_src->ai_canonname, str_octets);
+ pcanon += str_octets;
+ }
+ if (NULL != ai_cpy->ai_next) {
+ if (just_one)
+ ai_cpy->ai_next = NULL;
+ else
+ ai_cpy->ai_next = ai_cpy + 1;
+ }
+ ++ai_cpy;
+ }
+ ENSURE(pcanon == ((char *)dst + octets));
+
+ return dst;
+}
+
#ifndef ISC_PLATFORM_HAVEIPV6
@@ -127,8 +273,8 @@ DNSlookup_name(
}
#endif
-static int do_nodename P((const char *nodename, struct addrinfo *ai,
- const struct addrinfo *hints));
+static int do_nodename (const char *nodename, struct addrinfo *ai,
+ const struct addrinfo *hints);
int
getaddrinfo (const char *nodename, const char *servname,
@@ -288,7 +434,6 @@ getnameinfo (const struct sockaddr *sa, u_int salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
{
struct hostent *hp;
- int namelen;
if (sa->sa_family != AF_INET)
return (EAI_FAMILY);
@@ -301,16 +446,8 @@ getnameinfo (const struct sockaddr *sa, u_int salen, char *host,
else
return (EAI_FAIL);
}
- if (host != NULL && hostlen > 0) {
- /*
- * Don't exceed buffer
- */
- namelen = min(strlen(hp->h_name), hostlen - 1);
- if (namelen > 0) {
- strncpy(host, hp->h_name, namelen);
- host[namelen] = '\0';
- }
- }
+ if (host != NULL && hostlen > 0)
+ strlcpy(host, hp->h_name, hostlen);
return (0);
}
@@ -362,7 +499,7 @@ do_nodename(
sockin6->sin6_addr = in6addr_any;
*/
}
-#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+#ifdef ISC_PLATFORM_HAVESALEN
ai->ai_addr->sa_len = SOCKLEN(ai->ai_addr);
#endif
@@ -428,15 +565,11 @@ do_nodename(
sockin = (struct sockaddr_in *)ai->ai_addr;
memcpy(&sockin->sin_addr, hp->h_addr, hp->h_length);
ai->ai_addr->sa_family = hp->h_addrtype;
-#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+#ifdef ISC_PLATFORM_HAVESALEN
ai->ai_addr->sa_len = sizeof(struct sockaddr);
#endif
- if (hints != NULL && hints->ai_flags & AI_CANONNAME) {
- ai->ai_canonname = malloc(strlen(hp->h_name) + 1);
- if (ai->ai_canonname == NULL)
- return (EAI_MEMORY);
- strcpy(ai->ai_canonname, hp->h_name);
- }
+ if (hints != NULL && (hints->ai_flags & AI_CANONNAME))
+ ai->ai_canonname = estrdup(hp->h_name);
return (0);
}
diff --git a/contrib/ntp/libntp/ntp_worker.c b/contrib/ntp/libntp/ntp_worker.c
new file mode 100644
index 0000000..32970da
--- /dev/null
+++ b/contrib/ntp/libntp/ntp_worker.c
@@ -0,0 +1,340 @@
+/*
+ * ntp_worker.c
+ */
+#include <config.h>
+#include "ntp_workimpl.h"
+
+#ifdef WORKER
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+
+#include "iosignal.h"
+#include "ntp_stdlib.h"
+#include "ntp_malloc.h"
+#include "ntp_syslog.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_assert.h"
+#include "ntp_unixtime.h"
+#include "intreswork.h"
+
+
+#define CHILD_MAX_IDLE (3 * 60) /* seconds, idle worker limit */
+
+blocking_child ** blocking_children;
+size_t blocking_children_alloc;
+int worker_per_query; /* boolean */
+int intres_req_pending;
+
+
+#ifndef HAVE_IO_COMPLETION_PORT
+/*
+ * pipe_socketpair()
+ *
+ * Provides an AF_UNIX socketpair on systems which have them, otherwise
+ * pair of unidirectional pipes.
+ */
+int
+pipe_socketpair(
+ int caller_fds[2],
+ int * is_pipe
+ )
+{
+ int rc;
+ int fds[2];
+ int called_pipe;
+
+#ifdef HAVE_SOCKETPAIR
+ rc = socketpair(AF_UNIX, SOCK_STREAM, 0, &fds[0]);
+#else
+ rc = -1;
+#endif
+
+ if (-1 == rc) {
+ rc = pipe(&fds[0]);
+ called_pipe = TRUE;
+ } else {
+ called_pipe = FALSE;
+ }
+
+ if (-1 == rc)
+ return rc;
+
+ caller_fds[0] = fds[0];
+ caller_fds[1] = fds[1];
+ if (is_pipe != NULL)
+ *is_pipe = called_pipe;
+
+ return 0;
+}
+
+
+/*
+ * close_all_except()
+ *
+ * Close all file descriptors except the given keep_fd.
+ */
+void
+close_all_except(
+ int keep_fd
+ )
+{
+ int fd;
+
+ for (fd = 0; fd < keep_fd; fd++)
+ close(fd);
+
+ close_all_beyond(keep_fd);
+}
+
+
+/*
+ * close_all_beyond()
+ *
+ * Close all file descriptors after the given keep_fd, which is the
+ * highest fd to keep open.
+ */
+void
+close_all_beyond(
+ int keep_fd
+ )
+{
+# ifdef HAVE_CLOSEFROM
+ closefrom(keep_fd + 1);
+# elif defined(F_CLOSEM)
+ /*
+ * From 'Writing Reliable AIX Daemons,' SG24-4946-00,
+ * by Eric Agar (saves us from doing 32767 system
+ * calls)
+ */
+ if (fcntl(keep_fd + 1, F_CLOSEM, 0) == -1)
+ msyslog(LOG_ERR, "F_CLOSEM(%d): %m", keep_fd + 1);
+# else /* !HAVE_CLOSEFROM && !F_CLOSEM follows */
+ int fd;
+ int max_fd;
+
+ max_fd = GETDTABLESIZE();
+ for (fd = keep_fd + 1; fd < max_fd; fd++)
+ close(fd);
+# endif /* !HAVE_CLOSEFROM && !F_CLOSEM */
+}
+#endif /* HAVE_IO_COMPLETION_PORT */
+
+
+u_int
+available_blocking_child_slot(void)
+{
+ const size_t each = sizeof(blocking_children[0]);
+ u_int slot;
+ size_t prev_alloc;
+ size_t new_alloc;
+ size_t prev_octets;
+ size_t octets;
+
+ for (slot = 0; slot < blocking_children_alloc; slot++) {
+ if (NULL == blocking_children[slot])
+ return slot;
+ if (blocking_children[slot]->reusable) {
+ blocking_children[slot]->reusable = FALSE;
+ return slot;
+ }
+ }
+
+ prev_alloc = blocking_children_alloc;
+ prev_octets = prev_alloc * each;
+ new_alloc = blocking_children_alloc + 4;
+ octets = new_alloc * each;
+ blocking_children = erealloc_zero(blocking_children, octets,
+ prev_octets);
+ blocking_children_alloc = new_alloc;
+
+ return prev_alloc;
+}
+
+
+int
+queue_blocking_request(
+ blocking_work_req rtype,
+ void * req,
+ size_t reqsize,
+ blocking_work_callback done_func,
+ void * context
+ )
+{
+ static u_int intres_slot = UINT_MAX;
+ u_int child_slot;
+ blocking_child * c;
+ blocking_pipe_header req_hdr;
+
+ req_hdr.octets = sizeof(req_hdr) + reqsize;
+ req_hdr.magic_sig = BLOCKING_REQ_MAGIC;
+ req_hdr.rtype = rtype;
+ req_hdr.done_func = done_func;
+ req_hdr.context = context;
+
+ child_slot = UINT_MAX;
+ if (worker_per_query || UINT_MAX == intres_slot ||
+ blocking_children[intres_slot]->reusable)
+ child_slot = available_blocking_child_slot();
+ if (!worker_per_query) {
+ if (UINT_MAX == intres_slot)
+ intres_slot = child_slot;
+ else
+ child_slot = intres_slot;
+ if (0 == intres_req_pending)
+ intres_timeout_req(0);
+ }
+ intres_req_pending++;
+ INSIST(UINT_MAX != child_slot);
+ c = blocking_children[child_slot];
+ if (NULL == c) {
+ c = emalloc_zero(sizeof(*c));
+#ifdef WORK_FORK
+ c->req_read_pipe = -1;
+ c->req_write_pipe = -1;
+#endif
+#ifdef WORK_PIPE
+ c->resp_read_pipe = -1;
+ c->resp_write_pipe = -1;
+#endif
+ blocking_children[child_slot] = c;
+ }
+ req_hdr.child_idx = child_slot;
+
+ return send_blocking_req_internal(c, &req_hdr, req);
+}
+
+
+int queue_blocking_response(
+ blocking_child * c,
+ blocking_pipe_header * resp,
+ size_t respsize,
+ const blocking_pipe_header * req
+ )
+{
+ resp->octets = respsize;
+ resp->magic_sig = BLOCKING_RESP_MAGIC;
+ resp->rtype = req->rtype;
+ resp->context = req->context;
+ resp->done_func = req->done_func;
+
+ return send_blocking_resp_internal(c, resp);
+}
+
+
+void
+process_blocking_resp(
+ blocking_child * c
+ )
+{
+ blocking_pipe_header * resp;
+ void * data;
+
+ /*
+ * On Windows send_blocking_resp_internal() may signal the
+ * blocking_response_ready event multiple times while we're
+ * processing a response, so always consume all available
+ * responses before returning to test the event again.
+ */
+#ifdef WORK_THREAD
+ do {
+#endif
+ resp = receive_blocking_resp_internal(c);
+ if (NULL != resp) {
+ DEBUG_REQUIRE(BLOCKING_RESP_MAGIC ==
+ resp->magic_sig);
+ data = (char *)resp + sizeof(*resp);
+ intres_req_pending--;
+ (*resp->done_func)(resp->rtype, resp->context,
+ resp->octets - sizeof(*resp),
+ data);
+ free(resp);
+ }
+#ifdef WORK_THREAD
+ } while (NULL != resp);
+#endif
+ if (!worker_per_query && 0 == intres_req_pending)
+ intres_timeout_req(CHILD_MAX_IDLE);
+ else if (worker_per_query)
+ req_child_exit(c);
+}
+
+
+/*
+ * blocking_child_common runs as a forked child or a thread
+ */
+int
+blocking_child_common(
+ blocking_child *c
+ )
+{
+ int say_bye;
+ blocking_pipe_header *req;
+
+ say_bye = FALSE;
+ while (!say_bye) {
+ req = receive_blocking_req_internal(c);
+ if (NULL == req) {
+ say_bye = TRUE;
+ continue;
+ }
+
+ DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == req->magic_sig);
+
+ switch (req->rtype) {
+ case BLOCKING_GETADDRINFO:
+ if (blocking_getaddrinfo(c, req))
+ say_bye = TRUE;
+ break;
+
+ case BLOCKING_GETNAMEINFO:
+ if (blocking_getnameinfo(c, req))
+ say_bye = TRUE;
+ break;
+
+ default:
+ msyslog(LOG_ERR, "unknown req %d to blocking worker", req->rtype);
+ say_bye = TRUE;
+ }
+
+ free(req);
+ }
+
+ return 0;
+}
+
+
+/*
+ * worker_idle_timer_fired()
+ *
+ * The parent starts this timer when the last pending response has been
+ * received from the child, making it idle, and clears the timer when a
+ * request is dispatched to the child. Once the timer expires, the
+ * child is sent packing.
+ *
+ * This is called when worker_idle_timer is nonzero and less than or
+ * equal to current_time.
+ */
+void
+worker_idle_timer_fired(void)
+{
+ u_int idx;
+ blocking_child * c;
+
+ DEBUG_REQUIRE(0 == intres_req_pending);
+
+ intres_timeout_req(0);
+ for (idx = 0; idx < blocking_children_alloc; idx++) {
+ c = blocking_children[idx];
+ if (NULL == c)
+ continue;
+ req_child_exit(c);
+ }
+}
+
+
+#else /* !WORKER follows */
+int ntp_worker_nonempty_compilation_unit;
+#endif
diff --git a/contrib/ntp/libntp/numtoa.c b/contrib/ntp/libntp/numtoa.c
index de95118..5efbe94 100644
--- a/contrib/ntp/libntp/numtoa.c
+++ b/contrib/ntp/libntp/numtoa.c
@@ -1,6 +1,13 @@
/*
* numtoa - return asciized network numbers store in local array space
*/
+#include <config.h>
+
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h> /* ntohl */
+#endif
+
#include <stdio.h>
#include "ntp_fp.h"
@@ -17,8 +24,36 @@ numtoa(
netnum = ntohl(num);
LIB_GETBUF(buf);
- (void) sprintf(buf, "%lu.%lu.%lu.%lu", ((u_long)netnum >> 24) & 0xff,
- ((u_long)netnum >> 16) & 0xff, ((u_long)netnum >> 8) & 0xff,
- (u_long)netnum & 0xff);
+ snprintf(buf, LIB_BUFLENGTH, "%lu.%lu.%lu.%lu",
+ ((u_long)netnum >> 24) & 0xff,
+ ((u_long)netnum >> 16) & 0xff,
+ ((u_long)netnum >> 8) & 0xff,
+ (u_long)netnum & 0xff);
return buf;
}
+
+
+/* Convert a refid & stratum to a string */
+const char *
+refid_str(
+ u_int32 refid,
+ int stratum
+ )
+{
+ char * text;
+ size_t tlen;
+
+ if (stratum > 1)
+ return numtoa(refid);
+
+ LIB_GETBUF(text);
+ text[0] = '.';
+ memcpy(&text[1], &refid, sizeof(refid));
+ text[1 + sizeof(refid)] = '\0';
+ tlen = strlen(text);
+ text[tlen] = '.';
+ text[tlen + 1] = '\0';
+
+ return text;
+}
+
diff --git a/contrib/ntp/libntp/numtohost.c b/contrib/ntp/libntp/numtohost.c
index dd51c5d..6b250d6 100644
--- a/contrib/ntp/libntp/numtohost.c
+++ b/contrib/ntp/libntp/numtohost.c
@@ -1,6 +1,12 @@
/*
* numtohost - convert network number to host name.
*/
+#include <config.h>
+
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h> /* ntohl */
+#endif
#include "ntp_fp.h"
#include "ntp_stdlib.h"
@@ -31,8 +37,7 @@ numtohost(
return numtoa(netnum);
LIB_GETBUF(bp);
-
- bp[LIB_BUFLENGTH-1] = '\0';
- (void) strncpy(bp, hp->h_name, LIB_BUFLENGTH-1);
+ strlcpy(bp, hp->h_name, LIB_BUFLENGTH);
+
return bp;
}
diff --git a/contrib/ntp/libntp/octtoint.c b/contrib/ntp/libntp/octtoint.c
index f792b2b..e519601 100644
--- a/contrib/ntp/libntp/octtoint.c
+++ b/contrib/ntp/libntp/octtoint.c
@@ -2,6 +2,7 @@
* octtoint - convert an ascii string in octal to an unsigned
* long, with error checking
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
@@ -23,7 +24,7 @@ octtoint(
u = 0;
while (*cp != '\0') {
- if (!isdigit((int)*cp) || *cp == '8' || *cp == '9')
+ if (!isdigit((unsigned char)*cp) || *cp == '8' || *cp == '9')
return 0;
if (u >= 0x20000000)
return 0; /* overflow */
diff --git a/contrib/ntp/libntp/prettydate.c b/contrib/ntp/libntp/prettydate.c
index 55adf64..25b085e 100644
--- a/contrib/ntp/libntp/prettydate.c
+++ b/contrib/ntp/libntp/prettydate.c
@@ -1,132 +1,231 @@
/*
* prettydate - convert a time stamp to something readable
*/
+#include <config.h>
#include <stdio.h>
#include "ntp_fp.h"
#include "ntp_unixtime.h" /* includes <sys/time.h> */
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
+#include "ntp_assert.h"
+#include "ntp_calendar.h"
-static const char *months[] = {
+#if SIZEOF_TIME_T < 4
+# error sizeof(time_t) < 4 -- this will not work!
+#endif
+
+static char *common_prettydate(l_fp *, int);
+
+const char * const months[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
-static const char *days[] = {
+const char * const daynames[7] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
/* Helper function to handle possible wraparound of the ntp epoch.
+ *
+ * Works by periodic extension of the ntp time stamp in the UN*X epoch.
+ * If the 'time_t' is 32 bit, use solar cycle warping to get the value
+ * in a suitable range. Also uses solar cycle warping to work around
+ * really buggy implementations of 'gmtime()' / 'localtime()' that
+ * cannot work with a negative time value, that is, times before
+ * 1970-01-01. (MSVCRT...)
+ *
+ * Apart from that we're assuming that the localtime/gmtime library
+ * functions have been updated so that they work...
+ *
+ * An explanation: The julian calendar repeats ever 28 years, because
+ * it's the LCM of 7 and 1461, the week and leap year cycles. This is
+ * called a 'solar cycle'. The gregorian calendar does the same as
+ * long as no centennial year (divisible by 100, but not 400) goes in
+ * the way. So between 1901 and 2099 (inclusive) we can warp time
+ * stamps by 28 years to make them suitable for localtime() and
+ * gmtime() if we have trouble. Of course this will play hubbubb with
+ * the DST zone switches, so we should do it only if necessary; but as
+ * we NEED a proper conversion to dates via gmtime() we should try to
+ * cope with as many idiosyncrasies as possible.
+ *
+ */
- Works by assuming that the localtime/gmtime library functions
- have been updated so that they work
-*/
-
-#define MAX_EPOCH_NR 1000
-
-struct tm *
-ntp2unix_tm(
- u_long ntp, int local
- )
+/*
+ * solar cycle in unsigned secs and years, and the cycle limits.
+ */
+#define SOLAR_CYCLE_SECS 0x34AADC80UL /* 7*1461*86400*/
+#define SOLAR_CYCLE_YEARS 28
+#define MINFOLD -3
+#define MAXFOLD 3
+
+static struct tm *
+get_struct_tm(
+ const vint64 *stamp,
+ int local)
{
- time_t t, curr;
- struct tm *tm;
- int curr_year, epoch_nr;
-
- /* First get the current year: */
- curr = time(NULL);
- tm = local ? localtime(&curr) : gmtime(&curr);
- if (!tm) return NULL;
+ struct tm *tm = NULL;
+ int32 folds = 0;
+ time_t ts;
+
+#ifdef HAVE_INT64
+
+ int64 tl;
+ ts = tl = stamp->q_s;
+
+ /*
+ * If there is chance of truncation, try to fix it. Let the
+ * compiler find out if this can happen at all.
+ */
+ while (ts != tl) { /* truncation? */
+ if (tl < 0) {
+ if (--folds < MINFOLD)
+ return NULL;
+ tl += SOLAR_CYCLE_SECS;
+ } else {
+ if (++folds > MAXFOLD)
+ return NULL;
+ tl -= SOLAR_CYCLE_SECS;
+ }
+ ts = tl; /* next try... */
+ }
+#else
+
+ /*
+ * since we do not have 64-bit scalars, it's not likely we have
+ * 64-bit time_t. Assume 32 bits and properly reduce the value.
+ */
+ u_int32 hi, lo;
+
+ hi = stamp->D_s.hi;
+ lo = stamp->D_s.lo;
+
+ while ((hi && ~hi) || ((hi ^ lo) & 0x80000000u)) {
+ if (M_ISNEG(hi, lo)) {
+ if (--folds < MINFOLD)
+ return NULL;
+ M_ADD(hi, lo, 0, SOLAR_CYCLE_SECS);
+ } else {
+ if (++folds > MAXFOLD)
+ return NULL;
+ M_SUB(hi, lo, 0, SOLAR_CYCLE_SECS);
+ }
+ }
+ ts = (int32)lo;
- curr_year = 1900 + tm->tm_year;
+#endif
- /* Convert the ntp timestamp to a unix utc seconds count: */
- t = (time_t) ntp - JAN_1970;
+ /*
+ * 'ts' should be a suitable value by now. Just go ahead, but
+ * with care:
+ *
+ * There are some pathological implementations of 'gmtime()'
+ * and 'localtime()' out there. No matter if we have 32-bit or
+ * 64-bit 'time_t', try to fix this by solar cycle warping
+ * again...
+ *
+ * At least the MSDN says that the (Microsoft) Windoze
+ * versions of 'gmtime()' and 'localtime()' will bark on time
+ * stamps < 0.
+ */
+ while ((tm = (*(local ? localtime : gmtime))(&ts)) == NULL)
+ if (ts < 0) {
+ if (--folds < MINFOLD)
+ return NULL;
+ ts += SOLAR_CYCLE_SECS;
+ } else if (ts >= (time_t)SOLAR_CYCLE_SECS) {
+ if (++folds > MAXFOLD)
+ return NULL;
+ ts -= SOLAR_CYCLE_SECS;
+ } else
+ return NULL; /* That's truly pathological! */
+
+ /* 'tm' surely not NULL here! */
+ INSIST(tm != NULL);
+ if (folds != 0) {
+ tm->tm_year += folds * SOLAR_CYCLE_YEARS;
+ if (tm->tm_year <= 0 || tm->tm_year >= 200)
+ return NULL; /* left warp range... can't help here! */
+ }
- /* Check that the ntp timestamp is not before a 136 year window centered
- around the current year:
+ return tm;
+}
- Failsafe in case of an infinite loop:
- Allow up to 1000 epochs of 136 years each!
- */
- for (epoch_nr = 0; epoch_nr < MAX_EPOCH_NR; epoch_nr++) {
- tm = local ? localtime(&t) : gmtime(&t);
+static char *
+common_prettydate(
+ l_fp *ts,
+ int local
+ )
+{
+ static const char pfmt0[] =
+ "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03u";
+ static const char pfmt1[] =
+ "%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC]";
-#if SIZEOF_TIME_T < 4
-# include "Bletch: sizeof(time_t) < 4!"
-#endif
+ char *bp;
+ struct tm *tm;
+ u_int msec;
+ u_int32 ntps;
+ vint64 sec;
-#if SIZEOF_TIME_T == 4
- /* If 32 bits, then year is 1970-2038, so no sense looking */
- epoch_nr = MAX_EPOCH_NR;
-#else /* SIZEOF_TIME_T > 4 */
- /* Check that the resulting year is in the correct epoch: */
- if (1900 + tm->tm_year > curr_year - 68) break;
+ LIB_GETBUF(bp);
- /* Epoch wraparound: Add 2^32 seconds! */
- t += (time_t) 65536 << 16;
-#endif /* SIZEOF_TIME_T > 4 */
+ /* get & fix milliseconds */
+ ntps = ts->l_ui;
+ msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
+ if (msec >= 1000u) {
+ msec -= 1000u;
+ ntps++;
}
- return tm;
+ sec = ntpcal_ntp_to_time(ntps, NULL);
+ tm = get_struct_tm(&sec, local);
+ if (!tm) {
+ /*
+ * get a replacement, but always in UTC, using
+ * ntpcal_time_to_date()
+ */
+ struct calendar jd;
+ ntpcal_time_to_date(&jd, &sec);
+ snprintf(bp, LIB_BUFLENGTH, local ? pfmt1 : pfmt0,
+ (u_long)ts->l_ui, (u_long)ts->l_uf,
+ daynames[jd.weekday], months[jd.month-1],
+ jd.monthday, jd.year, jd.hour,
+ jd.minute, jd.second, msec);
+ } else
+ snprintf(bp, LIB_BUFLENGTH, pfmt0,
+ (u_long)ts->l_ui, (u_long)ts->l_uf,
+ daynames[tm->tm_wday], months[tm->tm_mon],
+ tm->tm_mday, 1900 + tm->tm_year, tm->tm_hour,
+ tm->tm_min, tm->tm_sec, msec);
+ return bp;
}
+
char *
prettydate(
l_fp *ts
)
{
- char *bp;
- struct tm *tm;
- time_t sec;
- u_long msec;
-
- LIB_GETBUF(bp);
-
- sec = ts->l_ui;
- msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
-
- tm = ntp2unix_tm(sec, 1);
- if (!tm) {
- (void) sprintf(bp, "%08lx.%08lx --- --- -- ---- --:--:--",
- (u_long)ts->l_ui, (u_long)ts->l_uf);
- }
- else {
- (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu",
- (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
- months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
- tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
- }
-
- return bp;
+ return common_prettydate(ts, 1);
}
+
char *
gmprettydate(
l_fp *ts
)
{
- char *bp;
- struct tm *tm;
- time_t sec;
- u_long msec;
-
- LIB_GETBUF(bp);
-
- sec = ts->l_ui;
- msec = ts->l_uf / 4294967; /* fract / (2 ** 32 / 1000) */
+ return common_prettydate(ts, 0);
+}
- tm = ntp2unix_tm(sec, 0);
- if (!tm) {
- (void) sprintf(bp, "%08lx.%08lx --- --- -- ---- --:--:--",
- (u_long)ts->l_ui, (u_long)ts->l_uf);
- }
- else {
- (void) sprintf(bp, "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03lu",
- (u_long)ts->l_ui, (u_long)ts->l_uf, days[tm->tm_wday],
- months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year,
- tm->tm_hour,tm->tm_min, tm->tm_sec, msec);
- }
- return bp;
+struct tm *
+ntp2unix_tm(
+ u_int32 ntp, int local
+ )
+{
+ vint64 vl;
+ vl = ntpcal_ntp_to_time(ntp, NULL);
+ return get_struct_tm(&vl, local);
}
+
diff --git a/contrib/ntp/libntp/recvbuff.c b/contrib/ntp/libntp/recvbuff.c
index 6665686..73ebe88 100644
--- a/contrib/ntp/libntp/recvbuff.c
+++ b/contrib/ntp/libntp/recvbuff.c
@@ -3,27 +3,27 @@
#endif
#include <stdio.h>
-#include "ntp_machine.h"
-#include "ntp_fp.h"
+
+#include "ntp_assert.h"
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
-#include "ntp_io.h"
+#include "ntp_lists.h"
#include "recvbuff.h"
#include "iosignal.h"
-#include <isc/list.h>
+
/*
* Memory allocation
*/
-static u_long volatile full_recvbufs; /* number of recvbufs on fulllist */
-static u_long volatile free_recvbufs; /* number of recvbufs on freelist */
+static u_long volatile full_recvbufs; /* recvbufs on full_recv_fifo */
+static u_long volatile free_recvbufs; /* recvbufs on free_recv_list */
static u_long volatile total_recvbufs; /* total recvbufs currently in use */
static u_long volatile lowater_adds; /* number of times we have added memory */
static u_long volatile buffer_shortfall;/* number of missed free receive buffers
- between replenishments */
+ between replenishments */
-static ISC_LIST(recvbuf_t) full_recv_list; /* Currently used recv buffers */
-static ISC_LIST(recvbuf_t) free_recv_list; /* Currently unused buffers */
+static DECL_FIFO_ANCHOR(recvbuf_t) full_recv_fifo;
+static recvbuf_t * free_recv_list;
#if defined(SYS_WINNT)
@@ -36,10 +36,15 @@ static CRITICAL_SECTION RecvLock;
# define LOCK() EnterCriticalSection(&RecvLock)
# define UNLOCK() LeaveCriticalSection(&RecvLock)
#else
-# define LOCK()
-# define UNLOCK()
+# define LOCK() do {} while (FALSE)
+# define UNLOCK() do {} while (FALSE)
+#endif
+
+#ifdef DEBUG
+static void uninit_recvbuff(void);
#endif
+
u_long
free_recvbuffs (void)
{
@@ -64,15 +69,10 @@ lowater_additions(void)
return lowater_adds;
}
-static void
+static inline void
initialise_buffer(recvbuf_t *buff)
{
- memset((char *) buff, 0, sizeof(recvbuf_t));
-
-#if defined SYS_WINNT
- buff->wsabuff.len = RX_BUFF_SIZE;
- buff->wsabuff.buf = (char *) buff->recv_buffer;
-#endif
+ ZERO(*buff);
}
static void
@@ -84,12 +84,20 @@ create_buffers(int nbufs)
abuf = nbufs + buffer_shortfall;
buffer_shortfall = 0;
- bufp = (recvbuf_t *) emalloc(abuf*sizeof(recvbuf_t));
+#ifndef DEBUG
+ bufp = emalloc_zero(abuf * sizeof(*bufp));
+#endif
- for (i = 0; i < abuf; i++)
- {
- memset((char *) bufp, 0, sizeof(recvbuf_t));
- ISC_LIST_APPEND(free_recv_list, bufp, link);
+ for (i = 0; i < abuf; i++) {
+#ifdef DEBUG
+ /*
+ * Allocate each buffer individually so they can be
+ * free()d during ntpd shutdown on DEBUG builds to
+ * keep them out of heap leak reports.
+ */
+ bufp = emalloc_zero(sizeof(*bufp));
+#endif
+ LINK_SLIST(free_recv_list, bufp, link);
bufp++;
free_recvbufs++;
total_recvbufs++;
@@ -104,8 +112,6 @@ init_recvbuff(int nbufs)
/*
* Init buffer free list and stat counters
*/
- ISC_LIST_INIT(full_recv_list);
- ISC_LIST_INIT(free_recv_list);
free_recvbufs = total_recvbufs = 0;
full_recvbufs = lowater_adds = 0;
@@ -115,7 +121,34 @@ init_recvbuff(int nbufs)
InitializeCriticalSection(&RecvLock);
#endif
+#ifdef DEBUG
+ atexit(&uninit_recvbuff);
+#endif
+}
+
+
+#ifdef DEBUG
+static void
+uninit_recvbuff(void)
+{
+ recvbuf_t *rbunlinked;
+
+ for (;;) {
+ UNLINK_FIFO(rbunlinked, full_recv_fifo, link);
+ if (rbunlinked == NULL)
+ break;
+ free(rbunlinked);
+ }
+
+ for (;;) {
+ UNLINK_HEAD_SLIST(rbunlinked, free_recv_list, link);
+ if (rbunlinked == NULL)
+ break;
+ free(rbunlinked);
+ }
}
+#endif /* DEBUG */
+
/*
* freerecvbuf - make a single recvbuf available for reuse
@@ -129,14 +162,10 @@ freerecvbuf(recvbuf_t *rb)
}
LOCK();
- (rb->used)--;
+ rb->used--;
if (rb->used != 0)
msyslog(LOG_ERR, "******** freerecvbuff non-zero usage: %d *******", rb->used);
- ISC_LIST_APPEND(free_recv_list, rb, link);
-#if defined SYS_WINNT
- rb->wsabuff.len = RX_BUFF_SIZE;
- rb->wsabuff.buf = (char *) rb->recv_buffer;
-#endif
+ LINK_SLIST(free_recv_list, rb, link);
free_recvbufs++;
UNLOCK();
}
@@ -150,63 +179,66 @@ add_full_recv_buffer(recvbuf_t *rb)
return;
}
LOCK();
- ISC_LIST_APPEND(full_recv_list, rb, link);
+ LINK_FIFO(full_recv_fifo, rb, link);
full_recvbufs++;
UNLOCK();
}
+
recvbuf_t *
get_free_recv_buffer(void)
{
- recvbuf_t * buffer = NULL;
+ recvbuf_t *buffer;
+
LOCK();
- buffer = ISC_LIST_HEAD(free_recv_list);
- if (buffer != NULL)
- {
- ISC_LIST_DEQUEUE(free_recv_list, buffer, link);
+ UNLINK_HEAD_SLIST(buffer, free_recv_list, link);
+ if (buffer != NULL) {
free_recvbufs--;
initialise_buffer(buffer);
- (buffer->used)++;
- }
- else
- {
+ buffer->used++;
+ } else {
buffer_shortfall++;
}
UNLOCK();
- return (buffer);
+
+ return buffer;
}
+
#ifdef HAVE_IO_COMPLETION_PORT
recvbuf_t *
get_free_recv_buffer_alloc(void)
{
- recvbuf_t * buffer = get_free_recv_buffer();
- if (buffer == NULL)
- {
+ recvbuf_t *buffer;
+
+ buffer = get_free_recv_buffer();
+ if (NULL == buffer) {
create_buffers(RECV_INC);
buffer = get_free_recv_buffer();
}
+ ENSURE(buffer != NULL);
return (buffer);
}
#endif
+
recvbuf_t *
get_full_recv_buffer(void)
{
- recvbuf_t *rbuf;
+ recvbuf_t * rbuf;
+
LOCK();
#ifdef HAVE_SIGNALED_IO
/*
* make sure there are free buffers when we
- * wander off to do lengthy paket processing with
+ * wander off to do lengthy packet processing with
* any buffer we grab from the full list.
*
* fixes malloc() interrupted by SIGIO risk
* (Bug 889)
*/
- rbuf = ISC_LIST_HEAD(free_recv_list);
- if (rbuf == NULL || buffer_shortfall > 0) {
+ if (NULL == free_recv_list || buffer_shortfall > 0) {
/*
* try to get us some more buffers
*/
@@ -217,30 +249,78 @@ get_full_recv_buffer(void)
/*
* try to grab a full buffer
*/
- rbuf = ISC_LIST_HEAD(full_recv_list);
+ UNLINK_FIFO(rbuf, full_recv_fifo, link);
if (rbuf != NULL)
- {
- ISC_LIST_DEQUEUE(full_recv_list, rbuf, link);
- --full_recvbufs;
- }
- else
- {
- /*
- * Make sure we reset the full count to 0
- */
- full_recvbufs = 0;
+ full_recvbufs--;
+ UNLOCK();
+
+ return rbuf;
+}
+
+
+/*
+ * purge_recv_buffers_for_fd() - purges any previously-received input
+ * from a given file descriptor.
+ */
+void
+purge_recv_buffers_for_fd(
+ SOCKET fd
+ )
+{
+ recvbuf_t *rbufp;
+ recvbuf_t *next;
+ recvbuf_t *punlinked;
+
+ LOCK();
+
+ for (rbufp = HEAD_FIFO(full_recv_fifo);
+ rbufp != NULL;
+ rbufp = next) {
+ next = rbufp->link;
+ if (rbufp->fd == fd) {
+ UNLINK_MID_FIFO(punlinked, full_recv_fifo,
+ rbufp, link, recvbuf_t);
+ INSIST(punlinked == rbufp);
+ full_recvbufs--;
+ freerecvbuf(rbufp);
+ }
}
+
UNLOCK();
- return (rbuf);
}
+
/*
* Checks to see if there are buffers to process
*/
isc_boolean_t has_full_recv_buffer(void)
{
- if (ISC_LIST_HEAD(full_recv_list) != NULL)
+ if (HEAD_FIFO(full_recv_fifo) != NULL)
return (ISC_TRUE);
else
return (ISC_FALSE);
}
+
+
+#ifdef NTP_DEBUG_LISTS_H
+void
+check_gen_fifo_consistency(void *fifo)
+{
+ gen_fifo *pf;
+ gen_node *pthis;
+ gen_node **pptail;
+
+ pf = fifo;
+ REQUIRE((NULL == pf->phead && NULL == pf->pptail) ||
+ (NULL != pf->phead && NULL != pf->pptail));
+
+ pptail = &pf->phead;
+ for (pthis = pf->phead;
+ pthis != NULL;
+ pthis = pthis->link)
+ if (NULL != pthis->link)
+ pptail = &pthis->link;
+
+ REQUIRE(NULL == pf->pptail || pptail == pf->pptail);
+}
+#endif /* NTP_DEBUG_LISTS_H */
diff --git a/contrib/ntp/libntp/refidsmear.c b/contrib/ntp/libntp/refidsmear.c
new file mode 100644
index 0000000..fef428e
--- /dev/null
+++ b/contrib/ntp/libntp/refidsmear.c
@@ -0,0 +1,58 @@
+#include <config.h>
+
+#include <ntp.h>
+#include <ntp_fp.h>
+#include <refidsmear.h>
+
+/*
+ * we want to test a refid format of:
+ * 254.x.y.x
+ *
+ * where x.y.z are 24 bits containing 2 (signed) integer bits
+ * and 22 fractional bits.
+ *
+ */
+
+
+l_fp
+convertRefIDToLFP(uint32_t r)
+{
+ l_fp temp;
+
+ r = ntohl(r);
+
+ // printf("%03d %08x: ", (r >> 24) & 0xFF, (r & 0x00FFFFFF) );
+
+ temp.l_uf = (r << 10); /* 22 fractional bits */
+
+ temp.l_ui = (r >> 22) & 0x3;
+ temp.l_ui |= ~(temp.l_ui & 2) + 1;
+
+ return temp;
+}
+
+
+uint32_t
+convertLFPToRefID(l_fp num)
+{
+ uint32_t temp;
+
+ /* round the input with the highest bit to shift out from the
+ * fraction, then keep just two bits from the integral part.
+ *
+ * TODO: check for overflows; should we clamp/saturate or just
+ * complain?
+ */
+ L_ADDUF(&num, 0x200);
+ num.l_ui &= 3;
+
+ /* combine integral and fractional part to 24 bits */
+ temp = (num.l_ui << 22) | (num.l_uf >> 10);
+
+ /* put in the leading 254.0.0.0 */
+ temp |= UINT32_C(0xFE000000);
+
+ // printf("%03d %08x: ", (temp >> 24) & 0xFF, (temp & 0x00FFFFFF) );
+
+ return htonl(temp);
+}
diff --git a/contrib/ntp/libntp/refnumtoa.c b/contrib/ntp/libntp/refnumtoa.c
index 7c5d96e..e6ca55ae 100644
--- a/contrib/ntp/libntp/refnumtoa.c
+++ b/contrib/ntp/libntp/refnumtoa.c
@@ -1,36 +1,36 @@
/*
* refnumtoa - return asciized refclock addresses stored in local array space
*/
+#include <config.h>
#include <stdio.h>
-#include "ntp_fp.h"
+#include "ntp_net.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
-char *
+const char *
refnumtoa(
- struct sockaddr_storage* num
+ sockaddr_u *num
)
{
- register u_int32 netnum;
- register char *buf;
- register const char *rclock;
+ u_int32 netnum;
+ char *buf;
+ const char *rclock;
- LIB_GETBUF(buf);
+ if (!ISREFCLOCKADR(num))
+ return socktoa(num);
- if(num->ss_family == AF_INET) {
- netnum = ntohl(((struct sockaddr_in*)num)->sin_addr.s_addr);
- rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
+ LIB_GETBUF(buf);
+ netnum = SRCADR(num);
+ rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
- if (rclock != NULL)
- (void)sprintf(buf, "%s(%lu)", rclock, (u_long)netnum & 0xff);
- else
- (void)sprintf(buf, "REFCLK(%lu,%lu)",
- ((u_long)netnum >> 8) & 0xff, (u_long)netnum & 0xff);
+ if (rclock != NULL)
+ snprintf(buf, LIB_BUFLENGTH, "%s(%lu)",
+ rclock, (u_long)netnum & 0xff);
+ else
+ snprintf(buf, LIB_BUFLENGTH, "REFCLK(%lu,%lu)",
+ ((u_long)netnum >> 8) & 0xff,
+ (u_long)netnum & 0xff);
- }
- else {
- (void)sprintf(buf, "refclock address type not implemented yet, use IPv4 refclock address.");
- }
return buf;
}
diff --git a/contrib/ntp/libntp/snprintf.c b/contrib/ntp/libntp/snprintf.c
index 7588b84..2b6a374 100644
--- a/contrib/ntp/libntp/snprintf.c
+++ b/contrib/ntp/libntp/snprintf.c
@@ -1,62 +1,2132 @@
+/*
+ * Modified by Dave Hart for integration into NTP 4.2.7 <hart@ntp.org>
+ *
+ * Changed in a backwards-incompatible way to separate HAVE_SNPRINTF
+ * from HW_WANT_RPL_SNPRINTF, etc. for each of the four replaced
+ * functions.
+ *
+ * Changed to honor hw_force_rpl_snprintf=yes, etc. This is used by NTP
+ * to test rpl_snprintf() and rpl_vsnprintf() on platforms which provide
+ * C99-compliant implementations.
+ */
+
+/* $Id: snprintf.c,v 1.9 2008/01/20 14:02:00 holger Exp $ */
+
+/*
+ * Copyright (c) 1995 Patrick Powell.
+ *
+ * This code is based on code written by Patrick Powell <papowell@astart.com>.
+ * It may be used for any purpose as long as this notice remains intact on all
+ * source code distributions.
+ */
+
+/*
+ * Copyright (c) 2008 Holger Weiss.
+ *
+ * This version of the code is maintained by Holger Weiss <holger@jhweiss.de>.
+ * My changes to the code may freely be used, modified and/or redistributed for
+ * any purpose. It would be nice if additions and fixes to this file (including
+ * trivial code cleanups) would be sent back in order to let me include them in
+ * the version available at <http://www.jhweiss.de/software/snprintf.html>.
+ * However, this is not a requirement for using or redistributing (possibly
+ * modified) versions of this file, nor is leaving this notice intact mandatory.
+ */
+
+/*
+ * History
+ *
+ * 2008-01-20 Holger Weiss <holger@jhweiss.de> for C99-snprintf 1.1:
+ *
+ * Fixed the detection of infinite floating point values on IRIX (and
+ * possibly other systems) and applied another few minor cleanups.
+ *
+ * 2008-01-06 Holger Weiss <holger@jhweiss.de> for C99-snprintf 1.0:
+ *
+ * Added a lot of new features, fixed many bugs, and incorporated various
+ * improvements done by Andrew Tridgell <tridge@samba.org>, Russ Allbery
+ * <rra@stanford.edu>, Hrvoje Niksic <hniksic@xemacs.org>, Damien Miller
+ * <djm@mindrot.org>, and others for the Samba, INN, Wget, and OpenSSH
+ * projects. The additions include: support the "e", "E", "g", "G", and
+ * "F" conversion specifiers (and use conversion style "f" or "F" for the
+ * still unsupported "a" and "A" specifiers); support the "hh", "ll", "j",
+ * "t", and "z" length modifiers; support the "#" flag and the (non-C99)
+ * "'" flag; use localeconv(3) (if available) to get both the current
+ * locale's decimal point character and the separator between groups of
+ * digits; fix the handling of various corner cases of field width and
+ * precision specifications; fix various floating point conversion bugs;
+ * handle infinite and NaN floating point values; don't attempt to write to
+ * the output buffer (which may be NULL) if a size of zero was specified;
+ * check for integer overflow of the field width, precision, and return
+ * values and during the floating point conversion; use the OUTCHAR() macro
+ * instead of a function for better performance; provide asprintf(3) and
+ * vasprintf(3) functions; add new test cases. The replacement functions
+ * have been renamed to use an "rpl_" prefix, the function calls in the
+ * main project (and in this file) must be redefined accordingly for each
+ * replacement function which is needed (by using Autoconf or other means).
+ * Various other minor improvements have been applied and the coding style
+ * was cleaned up for consistency.
+ *
+ * 2007-07-23 Holger Weiss <holger@jhweiss.de> for Mutt 1.5.13:
+ *
+ * C99 compliant snprintf(3) and vsnprintf(3) functions return the number
+ * of characters that would have been written to a sufficiently sized
+ * buffer (excluding the '\0'). The original code simply returned the
+ * length of the resulting output string, so that's been fixed.
+ *
+ * 1998-03-05 Michael Elkins <me@mutt.org> for Mutt 0.90.8:
+ *
+ * The original code assumed that both snprintf(3) and vsnprintf(3) were
+ * missing. Some systems only have snprintf(3) but not vsnprintf(3), so
+ * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
+ *
+ * 1998-01-27 Thomas Roessler <roessler@does-not-exist.org> for Mutt 0.89i:
+ *
+ * The PGP code was using unsigned hexadecimal formats. Unfortunately,
+ * unsigned formats simply didn't work.
+ *
+ * 1997-10-22 Brandon Long <blong@fiction.net> for Mutt 0.87.1:
+ *
+ * Ok, added some minimal floating point support, which means this probably
+ * requires libm on most operating systems. Don't yet support the exponent
+ * (e,E) and sigfig (g,G). Also, fmtint() was pretty badly broken, it just
+ * wasn't being exercised in ways which showed it, so that's been fixed.
+ * Also, formatted the code to Mutt conventions, and removed dead code left
+ * over from the original. Also, there is now a builtin-test, run with:
+ * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm && ./snprintf
+ *
+ * 2996-09-15 Brandon Long <blong@fiction.net> for Mutt 0.43:
+ *
+ * This was ugly. It is still ugly. I opted out of floating point
+ * numbers, but the formatter understands just about everything from the
+ * normal C string format, at least as far as I can tell from the Solaris
+ * 2.5 printf(3S) man page.
+ */
+
+/*
+ * ToDo
+ *
+ * - Add wide character support.
+ * - Add support for "%a" and "%A" conversions.
+ * - Create test routines which predefine the expected results. Our test cases
+ * usually expose bugs in system implementations rather than in ours :-)
+ */
+
+/*
+ * Usage
+ *
+ * 1) The following preprocessor macros should be defined to 1 if the feature or
+ * file in question is available on the target system (by using Autoconf or
+ * other means), though basic functionality should be available as long as
+ * HAVE_STDARG_H and HAVE_STDLIB_H are defined correctly:
+ *
+ * HW_WANT_RPL_VSNPRINTF
+ * HW_WANT_RPL_SNPRINTF
+ * HW_WANT_RPL_VASPRINTF
+ * HW_WANT_RPL_ASPRINTF
+ * HAVE_VSNPRINTF // define to 1 #if HW_WANT_RPL_VSNPRINTF
+ * HAVE_SNPRINTF // define to 1 #if HW_WANT_RPL_SNPRINTF
+ * HAVE_VASPRINTF // define to 1 #if HW_WANT_RPL_VASPRINTF
+ * HAVE_ASPRINTF // define to 1 #if HW_WANT_RPL_ASPRINTF
+ * HAVE_STDARG_H
+ * HAVE_STDDEF_H
+ * HAVE_STDINT_H
+ * HAVE_STDLIB_H
+ * HAVE_INTTYPES_H
+ * HAVE_LOCALE_H
+ * HAVE_LOCALECONV
+ * HAVE_LCONV_DECIMAL_POINT
+ * HAVE_LCONV_THOUSANDS_SEP
+ * HAVE_LONG_DOUBLE
+ * HAVE_LONG_LONG_INT
+ * HAVE_UNSIGNED_LONG_LONG_INT
+ * HAVE_INTMAX_T
+ * HAVE_UINTMAX_T
+ * HAVE_UINTPTR_T
+ * HAVE_PTRDIFF_T
+ * HAVE_VA_COPY
+ * HAVE___VA_COPY
+ *
+ * 2) The calls to the functions which should be replaced must be redefined
+ * throughout the project files (by using Autoconf or other means):
+ *
+ * #if HW_WANT_RPL_VSNPRINTF
+ * #define vsnprintf rpl_vsnprintf
+ * #endif
+ * #if HW_WANT_RPL_SNPRINTF
+ * #define snprintf rpl_snprintf
+ * #endif
+ * #if HW_WANT_RPL_VASPRINTF
+ * #define vasprintf rpl_vasprintf
+ * #endif
+ * #if HW_WANT_RPL_ASPRINTF
+ * #define asprintf rpl_asprintf
+ * #endif
+ *
+ * 3) The required replacement functions should be declared in some header file
+ * included throughout the project files:
+ *
+ * #if HAVE_CONFIG_H
+ * #include <config.h>
+ * #endif
+ * #if HAVE_STDARG_H
+ * #include <stdarg.h>
+ * #if HW_WANT_RPL_VSNPRINTF
+ * int rpl_vsnprintf(char *, size_t, const char *, va_list);
+ * #endif
+ * #if HW_WANT_RPL_SNPRINTF
+ * int rpl_snprintf(char *, size_t, const char *, ...);
+ * #endif
+ * #if HW_WANT_RPL_VASPRINTF
+ * int rpl_vasprintf(char **, const char *, va_list);
+ * #endif
+ * #if HW_WANT_RPL_ASPRINTF
+ * int rpl_asprintf(char **, const char *, ...);
+ * #endif
+ * #endif
+ *
+ * Autoconf macros for handling step 1 and step 2 are available at
+ * <http://www.jhweiss.de/software/snprintf.html>.
+ */
+
+#if HAVE_CONFIG_H
#include <config.h>
+#endif /* HAVE_CONFIG_H */
-#if !HAVE_SNPRINTF
-#include <sys/types.h>
+#if TEST_SNPRINTF
+#include <math.h> /* For pow(3), NAN, and INFINITY. */
+#include <string.h> /* For strcmp(3). */
+#if defined(__NetBSD__) || \
+ defined(__FreeBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__NeXT__) || \
+ defined(__bsd__)
+#define OS_BSD 1
+#elif defined(sgi) || defined(__sgi)
+#ifndef __c99
+#define __c99 /* Force C99 mode to get <stdint.h> included on IRIX 6.5.30. */
+#endif /* !defined(__c99) */
+#define OS_IRIX 1
+#define OS_SYSV 1
+#elif defined(__svr4__)
+#define OS_SYSV 1
+#elif defined(__linux__)
+#define OS_LINUX 1
+#endif /* defined(__NetBSD__) || defined(__FreeBSD__) || [...] */
+#if HAVE_CONFIG_H /* Undefine definitions possibly done in config.h. */
+#ifdef HAVE_SNPRINTF
+#undef HAVE_SNPRINTF
+#endif /* defined(HAVE_SNPRINTF) */
+#ifdef HAVE_VSNPRINTF
+#undef HAVE_VSNPRINTF
+#endif /* defined(HAVE_VSNPRINTF) */
+#ifdef HAVE_ASPRINTF
+#undef HAVE_ASPRINTF
+#endif /* defined(HAVE_ASPRINTF) */
+#ifdef HAVE_VASPRINTF
+#undef HAVE_VASPRINTF
+#endif /* defined(HAVE_VASPRINTF) */
+#ifdef snprintf
+#undef snprintf
+#endif /* defined(snprintf) */
+#ifdef vsnprintf
+#undef vsnprintf
+#endif /* defined(vsnprintf) */
+#ifdef asprintf
+#undef asprintf
+#endif /* defined(asprintf) */
+#ifdef vasprintf
+#undef vasprintf
+#endif /* defined(vasprintf) */
+#else /* By default, we assume a modern system for testing. */
+#ifndef HAVE_STDARG_H
+#define HAVE_STDARG_H 1
+#endif /* HAVE_STDARG_H */
+#ifndef HAVE_STDDEF_H
+#define HAVE_STDDEF_H 1
+#endif /* HAVE_STDDEF_H */
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 1
+#endif /* HAVE_STDINT_H */
+#ifndef HAVE_STDLIB_H
+#define HAVE_STDLIB_H 1
+#endif /* HAVE_STDLIB_H */
+#ifndef HAVE_INTTYPES_H
+#define HAVE_INTTYPES_H 1
+#endif /* HAVE_INTTYPES_H */
+#ifndef HAVE_LOCALE_H
+#define HAVE_LOCALE_H 1
+#endif /* HAVE_LOCALE_H */
+#ifndef HAVE_LOCALECONV
+#define HAVE_LOCALECONV 1
+#endif /* !defined(HAVE_LOCALECONV) */
+#ifndef HAVE_LCONV_DECIMAL_POINT
+#define HAVE_LCONV_DECIMAL_POINT 1
+#endif /* HAVE_LCONV_DECIMAL_POINT */
+#ifndef HAVE_LCONV_THOUSANDS_SEP
+#define HAVE_LCONV_THOUSANDS_SEP 1
+#endif /* HAVE_LCONV_THOUSANDS_SEP */
+#ifndef HAVE_LONG_DOUBLE
+#define HAVE_LONG_DOUBLE 1
+#endif /* !defined(HAVE_LONG_DOUBLE) */
+#ifndef HAVE_LONG_LONG_INT
+#define HAVE_LONG_LONG_INT 1
+#endif /* !defined(HAVE_LONG_LONG_INT) */
+#ifndef HAVE_UNSIGNED_LONG_LONG_INT
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#endif /* !defined(HAVE_UNSIGNED_LONG_LONG_INT) */
+#ifndef HAVE_INTMAX_T
+#define HAVE_INTMAX_T 1
+#endif /* !defined(HAVE_INTMAX_T) */
+#ifndef HAVE_UINTMAX_T
+#define HAVE_UINTMAX_T 1
+#endif /* !defined(HAVE_UINTMAX_T) */
+#ifndef HAVE_UINTPTR_T
+#define HAVE_UINTPTR_T 1
+#endif /* !defined(HAVE_UINTPTR_T) */
+#ifndef HAVE_PTRDIFF_T
+#define HAVE_PTRDIFF_T 1
+#endif /* !defined(HAVE_PTRDIFF_T) */
+#ifndef HAVE_VA_COPY
+#define HAVE_VA_COPY 1
+#endif /* !defined(HAVE_VA_COPY) */
+#ifndef HAVE___VA_COPY
+#define HAVE___VA_COPY 1
+#endif /* !defined(HAVE___VA_COPY) */
+#endif /* HAVE_CONFIG_H */
+#define snprintf rpl_snprintf
+#define vsnprintf rpl_vsnprintf
+#define asprintf rpl_asprintf
+#define vasprintf rpl_vasprintf
+#endif /* TEST_SNPRINTF */
-#ifdef __STDC__
+#if HW_WANT_RPL_SNPRINTF || HW_WANT_RPL_VSNPRINTF || HW_WANT_RPL_ASPRINTF || HW_WANT_RPL_VASPRINTF
+#include <stdio.h> /* For NULL, size_t, vsnprintf(3), and vasprintf(3). */
+#ifdef VA_START
+#undef VA_START
+#endif /* defined(VA_START) */
+#ifdef VA_SHIFT
+#undef VA_SHIFT
+#endif /* defined(VA_SHIFT) */
+#if HAVE_STDARG_H
#include <stdarg.h>
-#else
+#define VA_START(ap, last) va_start(ap, last)
+#define VA_SHIFT(ap, value, type) /* No-op for ANSI C. */
+#else /* Assume <varargs.h> is available. */
#include <varargs.h>
-#endif
-#include <stdio.h>
+#define VA_START(ap, last) va_start(ap) /* "last" is ignored. */
+#define VA_SHIFT(ap, value, type) value = va_arg(ap, type)
+#endif /* HAVE_STDARG_H */
+
+#if HW_WANT_RPL_VASPRINTF
+#if HAVE_STDLIB_H
+#include <stdlib.h> /* For malloc(3). */
+#endif /* HAVE_STDLIB_H */
+#ifdef VA_COPY
+#undef VA_COPY
+#endif /* defined(VA_COPY) */
+#ifdef VA_END_COPY
+#undef VA_END_COPY
+#endif /* defined(VA_END_COPY) */
+#if HAVE_VA_COPY
+#define VA_COPY(dest, src) va_copy(dest, src)
+#define VA_END_COPY(ap) va_end(ap)
+#elif HAVE___VA_COPY
+#define VA_COPY(dest, src) __va_copy(dest, src)
+#define VA_END_COPY(ap) va_end(ap)
+#else
+#define VA_COPY(dest, src) (void)mymemcpy(&dest, &src, sizeof(va_list))
+#define VA_END_COPY(ap) /* No-op. */
+#define NEED_MYMEMCPY 1
+static void *mymemcpy(void *, void *, size_t);
+#endif /* HAVE_VA_COPY */
+#endif /* HW_WANT_RPL_VASPRINTF */
-#include "l_stdlib.h"
+#if HW_WANT_RPL_VSNPRINTF
+#include <errno.h> /* For ERANGE and errno. */
+#include <limits.h> /* For *_MAX. */
+#if HAVE_INTTYPES_H
+#include <inttypes.h> /* For intmax_t (if not defined in <stdint.h>). */
+#endif /* HAVE_INTTYPES_H */
+#if HAVE_LOCALE_H
+#include <locale.h> /* For localeconv(3). */
+#endif /* HAVE_LOCALE_H */
+#if HAVE_STDDEF_H
+#include <stddef.h> /* For ptrdiff_t. */
+#endif /* HAVE_STDDEF_H */
+#if HAVE_STDINT_H
+#include <stdint.h> /* For intmax_t. */
+#endif /* HAVE_STDINT_H */
-#ifdef __STDC__
-int snprintf(char *str, size_t n, const char *fmt, ...)
+/* Support for unsigned long long int. We may also need ULLONG_MAX. */
+#ifndef ULONG_MAX /* We may need ULONG_MAX as a fallback. */
+#ifdef UINT_MAX
+#define ULONG_MAX UINT_MAX
#else
-int snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- const char *fmt;
- va_dcl
-#endif
+#define ULONG_MAX INT_MAX
+#endif /* defined(UINT_MAX) */
+#endif /* !defined(ULONG_MAX) */
+#ifdef ULLONG
+#undef ULLONG
+#endif /* defined(ULLONG) */
+#if HAVE_UNSIGNED_LONG_LONG_INT
+#define ULLONG unsigned long long int
+#ifndef ULLONG_MAX
+#define ULLONG_MAX ULONG_MAX
+#endif /* !defined(ULLONG_MAX) */
+#else
+#define ULLONG unsigned long int
+#ifdef ULLONG_MAX
+#undef ULLONG_MAX
+#endif /* defined(ULLONG_MAX) */
+#define ULLONG_MAX ULONG_MAX
+#endif /* HAVE_LONG_LONG_INT */
+
+/* Support for uintmax_t. We also need UINTMAX_MAX. */
+#ifdef UINTMAX_T
+#undef UINTMAX_T
+#endif /* defined(UINTMAX_T) */
+#if HAVE_UINTMAX_T || defined(uintmax_t)
+#define UINTMAX_T uintmax_t
+#ifndef UINTMAX_MAX
+#define UINTMAX_MAX ULLONG_MAX
+#endif /* !defined(UINTMAX_MAX) */
+#else
+#define UINTMAX_T ULLONG
+#ifdef UINTMAX_MAX
+#undef UINTMAX_MAX
+#endif /* defined(UINTMAX_MAX) */
+#define UINTMAX_MAX ULLONG_MAX
+#endif /* HAVE_UINTMAX_T || defined(uintmax_t) */
+
+/* Support for long double. */
+#ifndef LDOUBLE
+#if HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif /* HAVE_LONG_DOUBLE */
+#endif /* !defined(LDOUBLE) */
+
+/* Support for long long int. */
+#ifndef LLONG
+#if HAVE_LONG_LONG_INT
+#define LLONG long long int
+#else
+#define LLONG long int
+#endif /* HAVE_LONG_LONG_INT */
+#endif /* !defined(LLONG) */
+
+/* Support for intmax_t. */
+#ifndef INTMAX_T
+#if HAVE_INTMAX_T || defined(intmax_t)
+#define INTMAX_T intmax_t
+#else
+#define INTMAX_T LLONG
+#endif /* HAVE_INTMAX_T || defined(intmax_t) */
+#endif /* !defined(INTMAX_T) */
+
+/* Support for uintptr_t. */
+#ifndef UINTPTR_T
+#if HAVE_UINTPTR_T || defined(uintptr_t)
+#define UINTPTR_T uintptr_t
+#else
+#define UINTPTR_T unsigned long int
+#endif /* HAVE_UINTPTR_T || defined(uintptr_t) */
+#endif /* !defined(UINTPTR_T) */
+
+/* Support for ptrdiff_t. */
+#ifndef PTRDIFF_T
+#if HAVE_PTRDIFF_T || defined(ptrdiff_t)
+#define PTRDIFF_T ptrdiff_t
+#else
+#define PTRDIFF_T long int
+#endif /* HAVE_PTRDIFF_T || defined(ptrdiff_t) */
+#endif /* !defined(PTRDIFF_T) */
+
+/*
+ * We need an unsigned integer type corresponding to ptrdiff_t (cf. C99:
+ * 7.19.6.1, 7). However, we'll simply use PTRDIFF_T and convert it to an
+ * unsigned type if necessary. This should work just fine in practice.
+ */
+#ifndef UPTRDIFF_T
+#define UPTRDIFF_T PTRDIFF_T
+#endif /* !defined(UPTRDIFF_T) */
+
+/*
+ * We need a signed integer type corresponding to size_t (cf. C99: 7.19.6.1, 7).
+ * However, we'll simply use size_t and convert it to a signed type if
+ * necessary. This should work just fine in practice.
+ */
+#ifndef SSIZE_T
+#define SSIZE_T size_t
+#endif /* !defined(SSIZE_T) */
+
+/* Either ERANGE or E2BIG should be available everywhere. */
+#ifndef ERANGE
+#define ERANGE E2BIG
+#endif /* !defined(ERANGE) */
+#ifndef EOVERFLOW
+#define EOVERFLOW ERANGE
+#endif /* !defined(EOVERFLOW) */
+
+/*
+ * Buffer size to hold the octal string representation of UINT128_MAX without
+ * nul-termination ("3777777777777777777777777777777777777777777").
+ */
+#ifdef MAX_CONVERT_LENGTH
+#undef MAX_CONVERT_LENGTH
+#endif /* defined(MAX_CONVERT_LENGTH) */
+#define MAX_CONVERT_LENGTH 43
+
+/* Format read states. */
+#define PRINT_S_DEFAULT 0
+#define PRINT_S_FLAGS 1
+#define PRINT_S_WIDTH 2
+#define PRINT_S_DOT 3
+#define PRINT_S_PRECISION 4
+#define PRINT_S_MOD 5
+#define PRINT_S_CONV 6
+
+/* Format flags. */
+#define PRINT_F_MINUS (1 << 0)
+#define PRINT_F_PLUS (1 << 1)
+#define PRINT_F_SPACE (1 << 2)
+#define PRINT_F_NUM (1 << 3)
+#define PRINT_F_ZERO (1 << 4)
+#define PRINT_F_QUOTE (1 << 5)
+#define PRINT_F_UP (1 << 6)
+#define PRINT_F_UNSIGNED (1 << 7)
+#define PRINT_F_TYPE_G (1 << 8)
+#define PRINT_F_TYPE_E (1 << 9)
+
+/* Conversion flags. */
+#define PRINT_C_CHAR 1
+#define PRINT_C_SHORT 2
+#define PRINT_C_LONG 3
+#define PRINT_C_LLONG 4
+#define PRINT_C_LDOUBLE 5
+#define PRINT_C_SIZE 6
+#define PRINT_C_PTRDIFF 7
+#define PRINT_C_INTMAX 8
+
+#ifndef MAX
+#define MAX(x, y) ((x >= y) ? x : y)
+#endif /* !defined(MAX) */
+#ifndef CHARTOINT
+#define CHARTOINT(ch) (ch - '0')
+#endif /* !defined(CHARTOINT) */
+#ifndef ISDIGIT
+#define ISDIGIT(ch) ('0' <= (unsigned char)ch && (unsigned char)ch <= '9')
+#endif /* !defined(ISDIGIT) */
+#ifndef ISNAN
+#define ISNAN(x) (x != x)
+#endif /* !defined(ISNAN) */
+#ifndef ISINF
+#define ISINF(x) (x != 0.0 && x + x == x)
+#endif /* !defined(ISINF) */
+
+#ifdef OUTCHAR
+#undef OUTCHAR
+#endif /* defined(OUTCHAR) */
+#define OUTCHAR(str, len, size, ch) \
+do { \
+ if (len + 1 < size) \
+ str[len] = ch; \
+ (len)++; \
+} while (/* CONSTCOND */ 0)
+
+static void fmtstr(char *, size_t *, size_t, const char *, int, int, int);
+static void fmtint(char *, size_t *, size_t, INTMAX_T, int, int, int, int);
+static void fmtflt(char *, size_t *, size_t, LDOUBLE, int, int, int, int *);
+static void printsep(char *, size_t *, size_t);
+static int getnumsep(int);
+static int getexponent(LDOUBLE);
+static int convert(UINTMAX_T, char *, size_t, int, int);
+static UINTMAX_T cast(LDOUBLE);
+static UINTMAX_T myround(LDOUBLE);
+static LDOUBLE mypow10(int);
+
+int
+rpl_vsnprintf(char *str, size_t size, const char *format, va_list args);
+
+int
+rpl_vsnprintf(char *str, size_t size, const char *format, va_list args)
+{
+ LDOUBLE fvalue;
+ INTMAX_T value;
+ unsigned char cvalue;
+ const char *strvalue;
+ INTMAX_T *intmaxptr;
+ PTRDIFF_T *ptrdiffptr;
+ SSIZE_T *sizeptr;
+ LLONG *llongptr;
+ long int *longptr;
+ int *intptr;
+ short int *shortptr;
+ signed char *charptr;
+ size_t len = 0;
+ int overflow = 0;
+ int base = 0;
+ int cflags = 0;
+ int flags = 0;
+ int width = 0;
+ int precision = -1;
+ int state = PRINT_S_DEFAULT;
+ char ch = *format++;
+
+ /*
+ * C99 says: "If `n' is zero, nothing is written, and `s' may be a null
+ * pointer." (7.19.6.5, 2) We're forgiving and allow a NULL pointer
+ * even if a size larger than zero was specified. At least NetBSD's
+ * snprintf(3) does the same, as well as other versions of this file.
+ * (Though some of these versions will write to a non-NULL buffer even
+ * if a size of zero was specified, which violates the standard.)
+ */
+ if (str == NULL && size != 0)
+ size = 0;
+
+ while (ch != '\0')
+ switch (state) {
+ case PRINT_S_DEFAULT:
+ if (ch == '%')
+ state = PRINT_S_FLAGS;
+ else
+ OUTCHAR(str, len, size, ch);
+ ch = *format++;
+ break;
+ case PRINT_S_FLAGS:
+ switch (ch) {
+ case '-':
+ flags |= PRINT_F_MINUS;
+ ch = *format++;
+ break;
+ case '+':
+ flags |= PRINT_F_PLUS;
+ ch = *format++;
+ break;
+ case ' ':
+ flags |= PRINT_F_SPACE;
+ ch = *format++;
+ break;
+ case '#':
+ flags |= PRINT_F_NUM;
+ ch = *format++;
+ break;
+ case '0':
+ flags |= PRINT_F_ZERO;
+ ch = *format++;
+ break;
+ case '\'': /* SUSv2 flag (not in C99). */
+ flags |= PRINT_F_QUOTE;
+ ch = *format++;
+ break;
+ default:
+ state = PRINT_S_WIDTH;
+ break;
+ }
+ break;
+ case PRINT_S_WIDTH:
+ if (ISDIGIT(ch)) {
+ ch = CHARTOINT(ch);
+ if (width > (INT_MAX - ch) / 10) {
+ overflow = 1;
+ goto out;
+ }
+ width = 10 * width + ch;
+ ch = *format++;
+ } else if (ch == '*') {
+ /*
+ * C99 says: "A negative field width argument is
+ * taken as a `-' flag followed by a positive
+ * field width." (7.19.6.1, 5)
+ */
+ if ((width = va_arg(args, int)) < 0) {
+ flags |= PRINT_F_MINUS;
+ width = -width;
+ }
+ ch = *format++;
+ state = PRINT_S_DOT;
+ } else
+ state = PRINT_S_DOT;
+ break;
+ case PRINT_S_DOT:
+ if (ch == '.') {
+ state = PRINT_S_PRECISION;
+ ch = *format++;
+ } else
+ state = PRINT_S_MOD;
+ break;
+ case PRINT_S_PRECISION:
+ if (precision == -1)
+ precision = 0;
+ if (ISDIGIT(ch)) {
+ ch = CHARTOINT(ch);
+ if (precision > (INT_MAX - ch) / 10) {
+ overflow = 1;
+ goto out;
+ }
+ precision = 10 * precision + ch;
+ ch = *format++;
+ } else if (ch == '*') {
+ /*
+ * C99 says: "A negative precision argument is
+ * taken as if the precision were omitted."
+ * (7.19.6.1, 5)
+ */
+ if ((precision = va_arg(args, int)) < 0)
+ precision = -1;
+ ch = *format++;
+ state = PRINT_S_MOD;
+ } else
+ state = PRINT_S_MOD;
+ break;
+ case PRINT_S_MOD:
+ switch (ch) {
+ case 'h':
+ ch = *format++;
+ if (ch == 'h') { /* It's a char. */
+ ch = *format++;
+ cflags = PRINT_C_CHAR;
+ } else
+ cflags = PRINT_C_SHORT;
+ break;
+ case 'l':
+ ch = *format++;
+ if (ch == 'l') { /* It's a long long. */
+ ch = *format++;
+ cflags = PRINT_C_LLONG;
+ } else
+ cflags = PRINT_C_LONG;
+ break;
+ case 'L':
+ cflags = PRINT_C_LDOUBLE;
+ ch = *format++;
+ break;
+ case 'j':
+ cflags = PRINT_C_INTMAX;
+ ch = *format++;
+ break;
+ case 't':
+ cflags = PRINT_C_PTRDIFF;
+ ch = *format++;
+ break;
+ case 'z':
+ cflags = PRINT_C_SIZE;
+ ch = *format++;
+ break;
+ }
+ state = PRINT_S_CONV;
+ break;
+ case PRINT_S_CONV:
+ switch (ch) {
+ case 'd':
+ /* FALLTHROUGH */
+ case 'i':
+ switch (cflags) {
+ case PRINT_C_CHAR:
+ value = (signed char)va_arg(args, int);
+ break;
+ case PRINT_C_SHORT:
+ value = (short int)va_arg(args, int);
+ break;
+ case PRINT_C_LONG:
+ value = va_arg(args, long int);
+ break;
+ case PRINT_C_LLONG:
+ value = va_arg(args, LLONG);
+ break;
+ case PRINT_C_SIZE:
+ value = va_arg(args, SSIZE_T);
+ break;
+ case PRINT_C_INTMAX:
+ value = va_arg(args, INTMAX_T);
+ break;
+ case PRINT_C_PTRDIFF:
+ value = va_arg(args, PTRDIFF_T);
+ break;
+ default:
+ value = va_arg(args, int);
+ break;
+ }
+ fmtint(str, &len, size, value, 10, width,
+ precision, flags);
+ break;
+ case 'X':
+ flags |= PRINT_F_UP;
+ /* FALLTHROUGH */
+ case 'x':
+ base = 16;
+ /* FALLTHROUGH */
+ case 'o':
+ if (base == 0)
+ base = 8;
+ /* FALLTHROUGH */
+ case 'u':
+ if (base == 0)
+ base = 10;
+ flags |= PRINT_F_UNSIGNED;
+ switch (cflags) {
+ case PRINT_C_CHAR:
+ value = (unsigned char)va_arg(args,
+ unsigned int);
+ break;
+ case PRINT_C_SHORT:
+ value = (unsigned short int)va_arg(args,
+ unsigned int);
+ break;
+ case PRINT_C_LONG:
+ value = va_arg(args, unsigned long int);
+ break;
+ case PRINT_C_LLONG:
+ value = va_arg(args, ULLONG);
+ break;
+ case PRINT_C_SIZE:
+ value = va_arg(args, size_t);
+ break;
+ case PRINT_C_INTMAX:
+ value = va_arg(args, UINTMAX_T);
+ break;
+ case PRINT_C_PTRDIFF:
+ value = va_arg(args, UPTRDIFF_T);
+ break;
+ default:
+ value = va_arg(args, unsigned int);
+ break;
+ }
+ fmtint(str, &len, size, value, base, width,
+ precision, flags);
+ break;
+ case 'A':
+ /* Not yet supported, we'll use "%F". */
+ /* FALLTHROUGH */
+ case 'F':
+ flags |= PRINT_F_UP;
+ /* FALLTHROUGH */
+ case 'a':
+ /* Not yet supported, we'll use "%f". */
+ /* FALLTHROUGH */
+ case 'f':
+ if (cflags == PRINT_C_LDOUBLE)
+ fvalue = va_arg(args, LDOUBLE);
+ else
+ fvalue = va_arg(args, double);
+ fmtflt(str, &len, size, fvalue, width,
+ precision, flags, &overflow);
+ if (overflow)
+ goto out;
+ break;
+ case 'E':
+ flags |= PRINT_F_UP;
+ /* FALLTHROUGH */
+ case 'e':
+ flags |= PRINT_F_TYPE_E;
+ if (cflags == PRINT_C_LDOUBLE)
+ fvalue = va_arg(args, LDOUBLE);
+ else
+ fvalue = va_arg(args, double);
+ fmtflt(str, &len, size, fvalue, width,
+ precision, flags, &overflow);
+ if (overflow)
+ goto out;
+ break;
+ case 'G':
+ flags |= PRINT_F_UP;
+ /* FALLTHROUGH */
+ case 'g':
+ flags |= PRINT_F_TYPE_G;
+ if (cflags == PRINT_C_LDOUBLE)
+ fvalue = va_arg(args, LDOUBLE);
+ else
+ fvalue = va_arg(args, double);
+ /*
+ * If the precision is zero, it is treated as
+ * one (cf. C99: 7.19.6.1, 8).
+ */
+ if (precision == 0)
+ precision = 1;
+ fmtflt(str, &len, size, fvalue, width,
+ precision, flags, &overflow);
+ if (overflow)
+ goto out;
+ break;
+ case 'c':
+ cvalue = va_arg(args, int);
+ OUTCHAR(str, len, size, cvalue);
+ break;
+ case 's':
+ strvalue = va_arg(args, char *);
+ fmtstr(str, &len, size, strvalue, width,
+ precision, flags);
+ break;
+ case 'p':
+ /*
+ * C99 says: "The value of the pointer is
+ * converted to a sequence of printing
+ * characters, in an implementation-defined
+ * manner." (C99: 7.19.6.1, 8)
+ */
+ if ((strvalue = va_arg(args, void *)) == NULL)
+ /*
+ * We use the glibc format. BSD prints
+ * "0x0", SysV "0".
+ */
+ fmtstr(str, &len, size, "(nil)", width,
+ -1, flags);
+ else {
+ /*
+ * We use the BSD/glibc format. SysV
+ * omits the "0x" prefix (which we emit
+ * using the PRINT_F_NUM flag).
+ */
+ flags |= PRINT_F_NUM;
+ flags |= PRINT_F_UNSIGNED;
+ fmtint(str, &len, size,
+ (UINTPTR_T)strvalue, 16, width,
+ precision, flags);
+ }
+ break;
+ case 'n':
+ switch (cflags) {
+ case PRINT_C_CHAR:
+ charptr = va_arg(args, signed char *);
+ *charptr = len;
+ break;
+ case PRINT_C_SHORT:
+ shortptr = va_arg(args, short int *);
+ *shortptr = len;
+ break;
+ case PRINT_C_LONG:
+ longptr = va_arg(args, long int *);
+ *longptr = len;
+ break;
+ case PRINT_C_LLONG:
+ llongptr = va_arg(args, LLONG *);
+ *llongptr = len;
+ break;
+ case PRINT_C_SIZE:
+ /*
+ * C99 says that with the "z" length
+ * modifier, "a following `n' conversion
+ * specifier applies to a pointer to a
+ * signed integer type corresponding to
+ * size_t argument." (7.19.6.1, 7)
+ */
+ sizeptr = va_arg(args, SSIZE_T *);
+ *sizeptr = len;
+ break;
+ case PRINT_C_INTMAX:
+ intmaxptr = va_arg(args, INTMAX_T *);
+ *intmaxptr = len;
+ break;
+ case PRINT_C_PTRDIFF:
+ ptrdiffptr = va_arg(args, PTRDIFF_T *);
+ *ptrdiffptr = len;
+ break;
+ default:
+ intptr = va_arg(args, int *);
+ *intptr = len;
+ break;
+ }
+ break;
+ case '%': /* Print a "%" character verbatim. */
+ OUTCHAR(str, len, size, ch);
+ break;
+ default: /* Skip other characters. */
+ break;
+ }
+ ch = *format++;
+ state = PRINT_S_DEFAULT;
+ base = cflags = flags = width = 0;
+ precision = -1;
+ break;
+ }
+out:
+ if (len < size)
+ str[len] = '\0';
+ else if (size > 0)
+ str[size - 1] = '\0';
+
+ if (overflow || len >= INT_MAX) {
+ errno = overflow ? EOVERFLOW : ERANGE;
+ return -1;
+ }
+ return (int)len;
+}
+
+static void
+fmtstr(char *str, size_t *len, size_t size, const char *value, int width,
+ int precision, int flags)
+{
+ int padlen, strln; /* Amount to pad. */
+ int noprecision = (precision == -1);
+
+ if (value == NULL) /* We're forgiving. */
+ value = "(null)";
+
+ /* If a precision was specified, don't read the string past it. */
+ for (strln = 0; value[strln] != '\0' &&
+ (noprecision || strln < precision); strln++)
+ continue;
+
+ if ((padlen = width - strln) < 0)
+ padlen = 0;
+ if (flags & PRINT_F_MINUS) /* Left justify. */
+ padlen = -padlen;
+
+ while (padlen > 0) { /* Leading spaces. */
+ OUTCHAR(str, *len, size, ' ');
+ padlen--;
+ }
+ while (*value != '\0' && (noprecision || precision-- > 0)) {
+ OUTCHAR(str, *len, size, *value);
+ value++;
+ }
+ while (padlen < 0) { /* Trailing spaces. */
+ OUTCHAR(str, *len, size, ' ');
+ padlen++;
+ }
+}
+
+static void
+fmtint(char *str, size_t *len, size_t size, INTMAX_T value, int base, int width,
+ int precision, int flags)
+{
+ UINTMAX_T uvalue;
+ char iconvert[MAX_CONVERT_LENGTH];
+ char sign = 0;
+ char hexprefix = 0;
+ int spadlen = 0; /* Amount to space pad. */
+ int zpadlen = 0; /* Amount to zero pad. */
+ int pos;
+ int separators = (flags & PRINT_F_QUOTE);
+ int noprecision = (precision == -1);
+
+ if (flags & PRINT_F_UNSIGNED)
+ uvalue = value;
+ else {
+ uvalue = (value >= 0) ? value : -value;
+ if (value < 0)
+ sign = '-';
+ else if (flags & PRINT_F_PLUS) /* Do a sign. */
+ sign = '+';
+ else if (flags & PRINT_F_SPACE)
+ sign = ' ';
+ }
+
+ pos = convert(uvalue, iconvert, sizeof(iconvert), base,
+ flags & PRINT_F_UP);
+
+ if (flags & PRINT_F_NUM && uvalue != 0) {
+ /*
+ * C99 says: "The result is converted to an `alternative form'.
+ * For `o' conversion, it increases the precision, if and only
+ * if necessary, to force the first digit of the result to be a
+ * zero (if the value and precision are both 0, a single 0 is
+ * printed). For `x' (or `X') conversion, a nonzero result has
+ * `0x' (or `0X') prefixed to it." (7.19.6.1, 6)
+ */
+ switch (base) {
+ case 8:
+ if (precision <= pos)
+ precision = pos + 1;
+ break;
+ case 16:
+ hexprefix = (flags & PRINT_F_UP) ? 'X' : 'x';
+ break;
+ }
+ }
+
+ if (separators) /* Get the number of group separators we'll print. */
+ separators = getnumsep(pos);
+
+ zpadlen = precision - pos - separators;
+ spadlen = width /* Minimum field width. */
+ - separators /* Number of separators. */
+ - MAX(precision, pos) /* Number of integer digits. */
+ - ((sign != 0) ? 1 : 0) /* Will we print a sign? */
+ - ((hexprefix != 0) ? 2 : 0); /* Will we print a prefix? */
+
+ if (zpadlen < 0)
+ zpadlen = 0;
+ if (spadlen < 0)
+ spadlen = 0;
+
+ /*
+ * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
+ * ignored. For `d', `i', `o', `u', `x', and `X' conversions, if a
+ * precision is specified, the `0' flag is ignored." (7.19.6.1, 6)
+ */
+ if (flags & PRINT_F_MINUS) /* Left justify. */
+ spadlen = -spadlen;
+ else if (flags & PRINT_F_ZERO && noprecision) {
+ zpadlen += spadlen;
+ spadlen = 0;
+ }
+ while (spadlen > 0) { /* Leading spaces. */
+ OUTCHAR(str, *len, size, ' ');
+ spadlen--;
+ }
+ if (sign != 0) /* Sign. */
+ OUTCHAR(str, *len, size, sign);
+ if (hexprefix != 0) { /* A "0x" or "0X" prefix. */
+ OUTCHAR(str, *len, size, '0');
+ OUTCHAR(str, *len, size, hexprefix);
+ }
+ while (zpadlen > 0) { /* Leading zeros. */
+ OUTCHAR(str, *len, size, '0');
+ zpadlen--;
+ }
+ while (pos > 0) { /* The actual digits. */
+ pos--;
+ OUTCHAR(str, *len, size, iconvert[pos]);
+ if (separators > 0 && pos > 0 && pos % 3 == 0)
+ printsep(str, len, size);
+ }
+ while (spadlen < 0) { /* Trailing spaces. */
+ OUTCHAR(str, *len, size, ' ');
+ spadlen++;
+ }
+}
+
+static void
+fmtflt(char *str, size_t *len, size_t size, LDOUBLE fvalue, int width,
+ int precision, int flags, int *overflow)
+{
+ LDOUBLE ufvalue;
+ UINTMAX_T intpart;
+ UINTMAX_T fracpart;
+ UINTMAX_T mask;
+ const char *infnan = NULL;
+ char iconvert[MAX_CONVERT_LENGTH];
+ char fconvert[MAX_CONVERT_LENGTH];
+ char econvert[4]; /* "e-12" (without nul-termination). */
+ char esign = 0;
+ char sign = 0;
+ int leadfraczeros = 0;
+ int exponent = 0;
+ int emitpoint = 0;
+ int omitzeros = 0;
+ int omitcount = 0;
+ int padlen = 0;
+ int epos = 0;
+ int fpos = 0;
+ int ipos = 0;
+ int separators = (flags & PRINT_F_QUOTE);
+ int estyle = (flags & PRINT_F_TYPE_E);
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
+ struct lconv *lc = localeconv();
+#endif /* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */
+
+ /*
+ * AIX' man page says the default is 0, but C99 and at least Solaris'
+ * and NetBSD's man pages say the default is 6, and sprintf(3) on AIX
+ * defaults to 6.
+ */
+ if (precision == -1)
+ precision = 6;
+
+ if (fvalue < 0.0)
+ sign = '-';
+ else if (flags & PRINT_F_PLUS) /* Do a sign. */
+ sign = '+';
+ else if (flags & PRINT_F_SPACE)
+ sign = ' ';
+
+ if (ISNAN(fvalue))
+ infnan = (flags & PRINT_F_UP) ? "NAN" : "nan";
+ else if (ISINF(fvalue))
+ infnan = (flags & PRINT_F_UP) ? "INF" : "inf";
+
+ if (infnan != NULL) {
+ if (sign != 0)
+ iconvert[ipos++] = sign;
+ while (*infnan != '\0')
+ iconvert[ipos++] = *infnan++;
+ fmtstr(str, len, size, iconvert, width, ipos, flags);
+ return;
+ }
+
+ /* "%e" (or "%E") or "%g" (or "%G") conversion. */
+ if (flags & PRINT_F_TYPE_E || flags & PRINT_F_TYPE_G) {
+ if (flags & PRINT_F_TYPE_G) {
+ /*
+ * For "%g" (and "%G") conversions, the precision
+ * specifies the number of significant digits, which
+ * includes the digits in the integer part. The
+ * conversion will or will not be using "e-style" (like
+ * "%e" or "%E" conversions) depending on the precision
+ * and on the exponent. However, the exponent can be
+ * affected by rounding the converted value, so we'll
+ * leave this decision for later. Until then, we'll
+ * assume that we're going to do an "e-style" conversion
+ * (in order to get the exponent calculated). For
+ * "e-style", the precision must be decremented by one.
+ */
+ precision--;
+ /*
+ * For "%g" (and "%G") conversions, trailing zeros are
+ * removed from the fractional portion of the result
+ * unless the "#" flag was specified.
+ */
+ if (!(flags & PRINT_F_NUM))
+ omitzeros = 1;
+ }
+ exponent = getexponent(fvalue);
+ estyle = 1;
+ }
+
+again:
+ /*
+ * Sorry, we only support 9, 19, or 38 digits (that is, the number of
+ * digits of the 32-bit, the 64-bit, or the 128-bit UINTMAX_MAX value
+ * minus one) past the decimal point due to our conversion method.
+ */
+ switch (sizeof(UINTMAX_T)) {
+ case 16:
+ if (precision > 38)
+ precision = 38;
+ break;
+ case 8:
+ if (precision > 19)
+ precision = 19;
+ break;
+ default:
+ if (precision > 9)
+ precision = 9;
+ break;
+ }
+
+ ufvalue = (fvalue >= 0.0) ? fvalue : -fvalue;
+ if (estyle) /* We want exactly one integer digit. */
+ ufvalue /= mypow10(exponent);
+
+ if ((intpart = cast(ufvalue)) == UINTMAX_MAX) {
+ *overflow = 1;
+ return;
+ }
+
+ /*
+ * Factor of ten with the number of digits needed for the fractional
+ * part. For example, if the precision is 3, the mask will be 1000.
+ */
+ mask = mypow10(precision);
+ /*
+ * We "cheat" by converting the fractional part to integer by
+ * multiplying by a factor of ten.
+ */
+ if ((fracpart = myround(mask * (ufvalue - intpart))) >= mask) {
+ /*
+ * For example, ufvalue = 2.99962, intpart = 2, and mask = 1000
+ * (because precision = 3). Now, myround(1000 * 0.99962) will
+ * return 1000. So, the integer part must be incremented by one
+ * and the fractional part must be set to zero.
+ */
+ intpart++;
+ fracpart = 0;
+ if (estyle && intpart == 10) {
+ /*
+ * The value was rounded up to ten, but we only want one
+ * integer digit if using "e-style". So, the integer
+ * part must be set to one and the exponent must be
+ * incremented by one.
+ */
+ intpart = 1;
+ exponent++;
+ }
+ }
+
+ /*
+ * Now that we know the real exponent, we can check whether or not to
+ * use "e-style" for "%g" (and "%G") conversions. If we don't need
+ * "e-style", the precision must be adjusted and the integer and
+ * fractional parts must be recalculated from the original value.
+ *
+ * C99 says: "Let P equal the precision if nonzero, 6 if the precision
+ * is omitted, or 1 if the precision is zero. Then, if a conversion
+ * with style `E' would have an exponent of X:
+ *
+ * - if P > X >= -4, the conversion is with style `f' (or `F') and
+ * precision P - (X + 1).
+ *
+ * - otherwise, the conversion is with style `e' (or `E') and precision
+ * P - 1." (7.19.6.1, 8)
+ *
+ * Note that we had decremented the precision by one.
+ */
+ if (flags & PRINT_F_TYPE_G && estyle &&
+ precision + 1 > exponent && exponent >= -4) {
+ precision -= exponent;
+ estyle = 0;
+ goto again;
+ }
+
+ if (estyle) {
+ if (exponent < 0) {
+ exponent = -exponent;
+ esign = '-';
+ } else
+ esign = '+';
+
+ /*
+ * Convert the exponent. The sizeof(econvert) is 4. So, the
+ * econvert buffer can hold e.g. "e+99" and "e-99". We don't
+ * support an exponent which contains more than two digits.
+ * Therefore, the following stores are safe.
+ */
+ epos = convert(exponent, econvert, 2, 10, 0);
+ /*
+ * C99 says: "The exponent always contains at least two digits,
+ * and only as many more digits as necessary to represent the
+ * exponent." (7.19.6.1, 8)
+ */
+ if (epos == 1)
+ econvert[epos++] = '0';
+ econvert[epos++] = esign;
+ econvert[epos++] = (flags & PRINT_F_UP) ? 'E' : 'e';
+ }
+
+ /* Convert the integer part and the fractional part. */
+ ipos = convert(intpart, iconvert, sizeof(iconvert), 10, 0);
+ if (fracpart != 0) /* convert() would return 1 if fracpart == 0. */
+ fpos = convert(fracpart, fconvert, sizeof(fconvert), 10, 0);
+
+ leadfraczeros = precision - fpos;
+
+ if (omitzeros) {
+ if (fpos > 0) /* Omit trailing fractional part zeros. */
+ while (omitcount < fpos && fconvert[omitcount] == '0')
+ omitcount++;
+ else { /* The fractional part is zero, omit it completely. */
+ omitcount = precision;
+ leadfraczeros = 0;
+ }
+ precision -= omitcount;
+ }
+
+ /*
+ * Print a decimal point if either the fractional part is non-zero
+ * and/or the "#" flag was specified.
+ */
+ if (precision > 0 || flags & PRINT_F_NUM)
+ emitpoint = 1;
+ if (separators) /* Get the number of group separators we'll print. */
+ separators = getnumsep(ipos);
+
+ padlen = width /* Minimum field width. */
+ - ipos /* Number of integer digits. */
+ - epos /* Number of exponent characters. */
+ - precision /* Number of fractional digits. */
+ - separators /* Number of group separators. */
+ - (emitpoint ? 1 : 0) /* Will we print a decimal point? */
+ - ((sign != 0) ? 1 : 0); /* Will we print a sign character? */
+
+ if (padlen < 0)
+ padlen = 0;
+
+ /*
+ * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
+ * ignored." (7.19.6.1, 6)
+ */
+ if (flags & PRINT_F_MINUS) /* Left justifty. */
+ padlen = -padlen;
+ else if (flags & PRINT_F_ZERO && padlen > 0) {
+ if (sign != 0) { /* Sign. */
+ OUTCHAR(str, *len, size, sign);
+ sign = 0;
+ }
+ while (padlen > 0) { /* Leading zeros. */
+ OUTCHAR(str, *len, size, '0');
+ padlen--;
+ }
+ }
+ while (padlen > 0) { /* Leading spaces. */
+ OUTCHAR(str, *len, size, ' ');
+ padlen--;
+ }
+ if (sign != 0) /* Sign. */
+ OUTCHAR(str, *len, size, sign);
+ while (ipos > 0) { /* Integer part. */
+ ipos--;
+ OUTCHAR(str, *len, size, iconvert[ipos]);
+ if (separators > 0 && ipos > 0 && ipos % 3 == 0)
+ printsep(str, len, size);
+ }
+ if (emitpoint) { /* Decimal point. */
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
+ if (lc->decimal_point != NULL && *lc->decimal_point != '\0')
+ OUTCHAR(str, *len, size, *lc->decimal_point);
+ else /* We'll always print some decimal point character. */
+#endif /* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */
+ OUTCHAR(str, *len, size, '.');
+ }
+ while (leadfraczeros > 0) { /* Leading fractional part zeros. */
+ OUTCHAR(str, *len, size, '0');
+ leadfraczeros--;
+ }
+ while (fpos > omitcount) { /* The remaining fractional part. */
+ fpos--;
+ OUTCHAR(str, *len, size, fconvert[fpos]);
+ }
+ while (epos > 0) { /* Exponent. */
+ epos--;
+ OUTCHAR(str, *len, size, econvert[epos]);
+ }
+ while (padlen < 0) { /* Trailing spaces. */
+ OUTCHAR(str, *len, size, ' ');
+ padlen++;
+ }
+}
+
+static void
+printsep(char *str, size_t *len, size_t size)
+{
+#if HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP
+ struct lconv *lc = localeconv();
+ int i;
+
+ if (lc->thousands_sep != NULL)
+ for (i = 0; lc->thousands_sep[i] != '\0'; i++)
+ OUTCHAR(str, *len, size, lc->thousands_sep[i]);
+ else
+#endif /* HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP */
+ OUTCHAR(str, *len, size, ',');
+}
+
+static int
+getnumsep(int digits)
+{
+ int separators = (digits - ((digits % 3 == 0) ? 1 : 0)) / 3;
+#if HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP
+ int strln;
+ struct lconv *lc = localeconv();
+
+ /* We support an arbitrary separator length (including zero). */
+ if (lc->thousands_sep != NULL) {
+ for (strln = 0; lc->thousands_sep[strln] != '\0'; strln++)
+ continue;
+ separators *= strln;
+ }
+#endif /* HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP */
+ return separators;
+}
+
+static int
+getexponent(LDOUBLE value)
+{
+ LDOUBLE tmp = (value >= 0.0) ? value : -value;
+ int exponent = 0;
+
+ /*
+ * We check for 99 > exponent > -99 in order to work around possible
+ * endless loops which could happen (at least) in the second loop (at
+ * least) if we're called with an infinite value. However, we checked
+ * for infinity before calling this function using our ISINF() macro, so
+ * this might be somewhat paranoid.
+ */
+ while (tmp < 1.0 && tmp > 0.0 && --exponent > -99)
+ tmp *= 10;
+ while (tmp >= 10.0 && ++exponent < 99)
+ tmp /= 10;
+
+ return exponent;
+}
+
+static int
+convert(UINTMAX_T value, char *buf, size_t size, int base, int caps)
+{
+ const char *digits = caps ? "0123456789ABCDEF" : "0123456789abcdef";
+ size_t pos = 0;
+
+ /* We return an unterminated buffer with the digits in reverse order. */
+ do {
+ buf[pos++] = digits[value % base];
+ value /= base;
+ } while (value != 0 && pos < size);
+
+ return (int)pos;
+}
+
+static UINTMAX_T
+cast(LDOUBLE value)
+{
+ UINTMAX_T result;
+
+ /*
+ * We check for ">=" and not for ">" because if UINTMAX_MAX cannot be
+ * represented exactly as an LDOUBLE value (but is less than LDBL_MAX),
+ * it may be increased to the nearest higher representable value for the
+ * comparison (cf. C99: 6.3.1.4, 2). It might then equal the LDOUBLE
+ * value although converting the latter to UINTMAX_T would overflow.
+ */
+ if (value >= UINTMAX_MAX)
+ return UINTMAX_MAX;
+
+ result = value;
+ /*
+ * At least on NetBSD/sparc64 3.0.2 and 4.99.30, casting long double to
+ * an integer type converts e.g. 1.9 to 2 instead of 1 (which violates
+ * the standard). Sigh.
+ */
+ return (result <= value) ? result : result - 1;
+}
+
+static UINTMAX_T
+myround(LDOUBLE value)
+{
+ UINTMAX_T intpart = cast(value);
+
+ return ((value -= intpart) < 0.5) ? intpart : intpart + 1;
+}
+
+static LDOUBLE
+mypow10(int exponent)
+{
+ LDOUBLE result = 1;
+
+ while (exponent > 0) {
+ result *= 10;
+ exponent--;
+ }
+ while (exponent < 0) {
+ result /= 10;
+ exponent++;
+ }
+ return result;
+}
+#endif /* HW_WANT_RPL_VSNPRINTF */
+
+#if HW_WANT_RPL_VASPRINTF
+#if NEED_MYMEMCPY
+void *
+mymemcpy(void *dst, void *src, size_t len)
+{
+ const char *from = src;
+ char *to = dst;
+
+ /* No need for optimization, we use this only to replace va_copy(3). */
+ while (len-- > 0)
+ *to++ = *from++;
+ return dst;
+}
+#endif /* NEED_MYMEMCPY */
+
+int
+rpl_vasprintf(char **ret, const char *format, va_list ap);
+
+int
+rpl_vasprintf(char **ret, const char *format, va_list ap)
+{
+ size_t size;
+ int len;
+ va_list aq;
+
+ VA_COPY(aq, ap);
+ len = vsnprintf(NULL, 0, format, aq);
+ VA_END_COPY(aq);
+ if (len < 0 || (*ret = malloc(size = len + 1)) == NULL)
+ return -1;
+ return vsnprintf(*ret, size, format, ap);
+}
+#endif /* HW_WANT_RPL_VASPRINTF */
+
+#if HW_WANT_RPL_SNPRINTF
+#if HAVE_STDARG_H
+int
+rpl_snprintf(char *str, size_t size, const char *format, ...);
+
+int
+rpl_snprintf(char *str, size_t size, const char *format, ...)
+#else
+int
+rpl_snprintf(va_alist) va_dcl
+#endif /* HAVE_STDARG_H */
{
+#if !HAVE_STDARG_H
+ char *str;
+ size_t size;
+ char *format;
+#endif /* HAVE_STDARG_H */
va_list ap;
- int rval;
-#ifdef VSPRINTF_CHARSTAR
- char *rp;
-#endif
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-#ifdef VSPRINTF_CHARSTAR
- rp = vsprintf(str, fmt, ap);
+ int len;
+
+ VA_START(ap, format);
+ VA_SHIFT(ap, str, char *);
+ VA_SHIFT(ap, size, size_t);
+ VA_SHIFT(ap, format, const char *);
+ len = vsnprintf(str, size, format, ap);
va_end(ap);
- return (strlen(rp));
+ return len;
+}
+#endif /* HW_WANT_RPL_SNPRINTF */
+
+#if HW_WANT_RPL_ASPRINTF
+#if HAVE_STDARG_H
+int
+rpl_asprintf(char **ret, const char *format, ...);
+
+int
+rpl_asprintf(char **ret, const char *format, ...)
#else
- rval = vsprintf(str, fmt, ap);
+int
+rpl_asprintf(va_alist) va_dcl
+#endif /* HAVE_STDARG_H */
+{
+#if !HAVE_STDARG_H
+ char **ret;
+ char *format;
+#endif /* HAVE_STDARG_H */
+ va_list ap;
+ int len;
+
+ VA_START(ap, format);
+ VA_SHIFT(ap, ret, char **);
+ VA_SHIFT(ap, format, const char *);
+ len = vasprintf(ret, format, ap);
va_end(ap);
- return (rval);
-#endif
+ return len;
}
+#endif /* HW_WANT_RPL_ASPRINTF */
+#else /* Dummy declaration to avoid empty translation unit warnings. */
+int main(void);
+#endif /* HW_WANT_RPL_SNPRINTF || HW_WANT_RPL_VSNPRINTF || HW_WANT_RPL_ASPRINTF || [...] */
+#if TEST_SNPRINTF
int
-vsnprintf(
- char *str,
- size_t n,
- const char *fmt,
- va_list ap
- )
+main(void)
{
-#ifdef VSPRINTF_CHARSTAR
- return (strlen(vsprintf(str, fmt, ap)));
-#else
- return (vsprintf(str, fmt, ap));
-#endif
+ const char *float_fmt[] = {
+ /* "%E" and "%e" formats. */
+#if HAVE_LONG_LONG_INT && !OS_BSD && !OS_IRIX
+ "%.16e",
+ "%22.16e",
+ "%022.16e",
+ "%-22.16e",
+ "%#+'022.16e",
+#endif /* HAVE_LONG_LONG_INT && !OS_BSD && !OS_IRIX */
+ "foo|%#+0123.9E|bar",
+ "%-123.9e",
+ "%123.9e",
+ "%+23.9e",
+ "%+05.8e",
+ "%-05.8e",
+ "%05.8e",
+ "%+5.8e",
+ "%-5.8e",
+ "% 5.8e",
+ "%5.8e",
+ "%+4.9e",
+#if !OS_LINUX /* glibc sometimes gets these wrong. */
+ "%+#010.0e",
+ "%#10.1e",
+ "%10.5e",
+ "% 10.5e",
+ "%5.0e",
+ "%5.e",
+ "%#5.0e",
+ "%#5.e",
+ "%3.2e",
+ "%3.1e",
+ "%-1.5e",
+ "%1.5e",
+ "%01.3e",
+ "%1.e",
+ "%.1e",
+ "%#.0e",
+ "%+.0e",
+ "% .0e",
+ "%.0e",
+ "%#.e",
+ "%+.e",
+ "% .e",
+ "%.e",
+ "%4e",
+ "%e",
+ "%E",
+#endif /* !OS_LINUX */
+ /* "%F" and "%f" formats. */
+#if !OS_BSD && !OS_IRIX
+ "% '022f",
+ "%+'022f",
+ "%-'22f",
+ "%'22f",
+#if HAVE_LONG_LONG_INT
+ "%.16f",
+ "%22.16f",
+ "%022.16f",
+ "%-22.16f",
+ "%#+'022.16f",
+#endif /* HAVE_LONG_LONG_INT */
+#endif /* !OS_BSD && !OS_IRIX */
+ "foo|%#+0123.9F|bar",
+ "%-123.9f",
+ "%123.9f",
+ "%+23.9f",
+ "%+#010.0f",
+ "%#10.1f",
+ "%10.5f",
+ "% 10.5f",
+ "%+05.8f",
+ "%-05.8f",
+ "%05.8f",
+ "%+5.8f",
+ "%-5.8f",
+ "% 5.8f",
+ "%5.8f",
+ "%5.0f",
+ "%5.f",
+ "%#5.0f",
+ "%#5.f",
+ "%+4.9f",
+ "%3.2f",
+ "%3.1f",
+ "%-1.5f",
+ "%1.5f",
+ "%01.3f",
+ "%1.f",
+ "%.1f",
+ "%#.0f",
+ "%+.0f",
+ "% .0f",
+ "%.0f",
+ "%#.f",
+ "%+.f",
+ "% .f",
+ "%.f",
+ "%4f",
+ "%f",
+ "%F",
+ /* "%G" and "%g" formats. */
+#if !OS_BSD && !OS_IRIX && !OS_LINUX
+ "% '022g",
+ "%+'022g",
+ "%-'22g",
+ "%'22g",
+#if HAVE_LONG_LONG_INT
+ "%.16g",
+ "%22.16g",
+ "%022.16g",
+ "%-22.16g",
+ "%#+'022.16g",
+#endif /* HAVE_LONG_LONG_INT */
+#endif /* !OS_BSD && !OS_IRIX && !OS_LINUX */
+ "foo|%#+0123.9G|bar",
+ "%-123.9g",
+ "%123.9g",
+ "%+23.9g",
+ "%+05.8g",
+ "%-05.8g",
+ "%05.8g",
+ "%+5.8g",
+ "%-5.8g",
+ "% 5.8g",
+ "%5.8g",
+ "%+4.9g",
+#if !OS_LINUX /* glibc sometimes gets these wrong. */
+ "%+#010.0g",
+ "%#10.1g",
+ "%10.5g",
+ "% 10.5g",
+ "%5.0g",
+ "%5.g",
+ "%#5.0g",
+ "%#5.g",
+ "%3.2g",
+ "%3.1g",
+ "%-1.5g",
+ "%1.5g",
+ "%01.3g",
+ "%1.g",
+ "%.1g",
+ "%#.0g",
+ "%+.0g",
+ "% .0g",
+ "%.0g",
+ "%#.g",
+ "%+.g",
+ "% .g",
+ "%.g",
+ "%4g",
+ "%g",
+ "%G",
+#endif /* !OS_LINUX */
+ NULL
+ };
+ double float_val[] = {
+ -4.136,
+ -134.52,
+ -5.04030201,
+ -3410.01234,
+ -999999.999999,
+ -913450.29876,
+ -913450.2,
+ -91345.2,
+ -9134.2,
+ -913.2,
+ -91.2,
+ -9.2,
+ -9.9,
+ 4.136,
+ 134.52,
+ 5.04030201,
+ 3410.01234,
+ 999999.999999,
+ 913450.29876,
+ 913450.2,
+ 91345.2,
+ 9134.2,
+ 913.2,
+ 91.2,
+ 9.2,
+ 9.9,
+ 9.96,
+ 9.996,
+ 9.9996,
+ 9.99996,
+ 9.999996,
+ 9.9999996,
+ 9.99999996,
+ 0.99999996,
+ 0.99999999,
+ 0.09999999,
+ 0.00999999,
+ 0.00099999,
+ 0.00009999,
+ 0.00000999,
+ 0.00000099,
+ 0.00000009,
+ 0.00000001,
+ 0.0000001,
+ 0.000001,
+ 0.00001,
+ 0.0001,
+ 0.001,
+ 0.01,
+ 0.1,
+ 1.0,
+ 1.5,
+ -1.5,
+ -1.0,
+ -0.1,
+#if !OS_BSD /* BSD sometimes gets these wrong. */
+#ifdef INFINITY
+ INFINITY,
+ -INFINITY,
+#endif /* defined(INFINITY) */
+#ifdef NAN
+ NAN,
+#endif /* defined(NAN) */
+#endif /* !OS_BSD */
+ 0
+ };
+ const char *long_fmt[] = {
+ "foo|%0123ld|bar",
+#if !OS_IRIX
+ "% '0123ld",
+ "%+'0123ld",
+ "%-'123ld",
+ "%'123ld",
+#endif /* !OS_IRiX */
+ "%123.9ld",
+ "% 123.9ld",
+ "%+123.9ld",
+ "%-123.9ld",
+ "%0123ld",
+ "% 0123ld",
+ "%+0123ld",
+ "%-0123ld",
+ "%10.5ld",
+ "% 10.5ld",
+ "%+10.5ld",
+ "%-10.5ld",
+ "%010ld",
+ "% 010ld",
+ "%+010ld",
+ "%-010ld",
+ "%4.2ld",
+ "% 4.2ld",
+ "%+4.2ld",
+ "%-4.2ld",
+ "%04ld",
+ "% 04ld",
+ "%+04ld",
+ "%-04ld",
+ "%5.5ld",
+ "%+22.33ld",
+ "%01.3ld",
+ "%1.5ld",
+ "%-1.5ld",
+ "%44ld",
+ "%4ld",
+ "%4.0ld",
+ "%4.ld",
+ "%.44ld",
+ "%.4ld",
+ "%.0ld",
+ "%.ld",
+ "%ld",
+ NULL
+ };
+ long int long_val[] = {
+#ifdef LONG_MAX
+ LONG_MAX,
+#endif /* LONG_MAX */
+#ifdef LONG_MIN
+ LONG_MIN,
+#endif /* LONG_MIN */
+ -91340,
+ 91340,
+ 341,
+ 134,
+ 0203,
+ -1,
+ 1,
+ 0
+ };
+ const char *ulong_fmt[] = {
+ /* "%u" formats. */
+ "foo|%0123lu|bar",
+#if !OS_IRIX
+ "% '0123lu",
+ "%+'0123lu",
+ "%-'123lu",
+ "%'123lu",
+#endif /* !OS_IRiX */
+ "%123.9lu",
+ "% 123.9lu",
+ "%+123.9lu",
+ "%-123.9lu",
+ "%0123lu",
+ "% 0123lu",
+ "%+0123lu",
+ "%-0123lu",
+ "%5.5lu",
+ "%+22.33lu",
+ "%01.3lu",
+ "%1.5lu",
+ "%-1.5lu",
+ "%44lu",
+ "%lu",
+ /* "%o" formats. */
+ "foo|%#0123lo|bar",
+ "%#123.9lo",
+ "%# 123.9lo",
+ "%#+123.9lo",
+ "%#-123.9lo",
+ "%#0123lo",
+ "%# 0123lo",
+ "%#+0123lo",
+ "%#-0123lo",
+ "%#5.5lo",
+ "%#+22.33lo",
+ "%#01.3lo",
+ "%#1.5lo",
+ "%#-1.5lo",
+ "%#44lo",
+ "%#lo",
+ "%123.9lo",
+ "% 123.9lo",
+ "%+123.9lo",
+ "%-123.9lo",
+ "%0123lo",
+ "% 0123lo",
+ "%+0123lo",
+ "%-0123lo",
+ "%5.5lo",
+ "%+22.33lo",
+ "%01.3lo",
+ "%1.5lo",
+ "%-1.5lo",
+ "%44lo",
+ "%lo",
+ /* "%X" and "%x" formats. */
+ "foo|%#0123lX|bar",
+ "%#123.9lx",
+ "%# 123.9lx",
+ "%#+123.9lx",
+ "%#-123.9lx",
+ "%#0123lx",
+ "%# 0123lx",
+ "%#+0123lx",
+ "%#-0123lx",
+ "%#5.5lx",
+ "%#+22.33lx",
+ "%#01.3lx",
+ "%#1.5lx",
+ "%#-1.5lx",
+ "%#44lx",
+ "%#lx",
+ "%#lX",
+ "%123.9lx",
+ "% 123.9lx",
+ "%+123.9lx",
+ "%-123.9lx",
+ "%0123lx",
+ "% 0123lx",
+ "%+0123lx",
+ "%-0123lx",
+ "%5.5lx",
+ "%+22.33lx",
+ "%01.3lx",
+ "%1.5lx",
+ "%-1.5lx",
+ "%44lx",
+ "%lx",
+ "%lX",
+ NULL
+ };
+ unsigned long int ulong_val[] = {
+#ifdef ULONG_MAX
+ ULONG_MAX,
+#endif /* ULONG_MAX */
+ 91340,
+ 341,
+ 134,
+ 0203,
+ 1,
+ 0
+ };
+ const char *llong_fmt[] = {
+ "foo|%0123lld|bar",
+ "%123.9lld",
+ "% 123.9lld",
+ "%+123.9lld",
+ "%-123.9lld",
+ "%0123lld",
+ "% 0123lld",
+ "%+0123lld",
+ "%-0123lld",
+ "%5.5lld",
+ "%+22.33lld",
+ "%01.3lld",
+ "%1.5lld",
+ "%-1.5lld",
+ "%44lld",
+ "%lld",
+ NULL
+ };
+ LLONG llong_val[] = {
+#ifdef LLONG_MAX
+ LLONG_MAX,
+#endif /* LLONG_MAX */
+#ifdef LLONG_MIN
+ LLONG_MIN,
+#endif /* LLONG_MIN */
+ -91340,
+ 91340,
+ 341,
+ 134,
+ 0203,
+ -1,
+ 1,
+ 0
+ };
+ const char *string_fmt[] = {
+ "foo|%10.10s|bar",
+ "%-10.10s",
+ "%10.10s",
+ "%10.5s",
+ "%5.10s",
+ "%10.1s",
+ "%1.10s",
+ "%10.0s",
+ "%0.10s",
+ "%-42.5s",
+ "%2.s",
+ "%.10s",
+ "%.1s",
+ "%.0s",
+ "%.s",
+ "%4s",
+ "%s",
+ NULL
+ };
+ const char *string_val[] = {
+ "Hello",
+ "Hello, world!",
+ "Sound check: One, two, three.",
+ "This string is a little longer than the other strings.",
+ "1",
+ "",
+ NULL
+ };
+#if !OS_SYSV /* SysV uses a different format than we do. */
+ const char *pointer_fmt[] = {
+ "foo|%p|bar",
+ "%42p",
+ "%p",
+ NULL
+ };
+ const char *pointer_val[] = {
+ *pointer_fmt,
+ *string_fmt,
+ *string_val,
+ NULL
+ };
+#endif /* !OS_SYSV */
+ char buf1[1024], buf2[1024];
+ double value, digits = 9.123456789012345678901234567890123456789;
+ int i, j, r1, r2, failed = 0, num = 0;
+
+/*
+ * Use -DTEST_NILS in order to also test the conversion of nil values. Might
+ * segfault on systems which don't support converting a NULL pointer with "%s"
+ * and lets some test cases fail against BSD and glibc due to bugs in their
+ * implementations.
+ */
+#ifndef TEST_NILS
+#define TEST_NILS 0
+#elif TEST_NILS
+#undef TEST_NILS
+#define TEST_NILS 1
+#endif /* !defined(TEST_NILS) */
+#ifdef TEST
+#undef TEST
+#endif /* defined(TEST) */
+#define TEST(fmt, val) \
+do { \
+ for (i = 0; fmt[i] != NULL; i++) \
+ for (j = 0; j == 0 || val[j - TEST_NILS] != 0; j++) { \
+ r1 = sprintf(buf1, fmt[i], val[j]); \
+ r2 = snprintf(buf2, sizeof(buf2), fmt[i], val[j]); \
+ if (strcmp(buf1, buf2) != 0 || r1 != r2) { \
+ (void)printf("Results don't match, " \
+ "format string: %s\n" \
+ "\t sprintf(3): [%s] (%d)\n" \
+ "\tsnprintf(3): [%s] (%d)\n", \
+ fmt[i], buf1, r1, buf2, r2); \
+ failed++; \
+ } \
+ num++; \
+ } \
+} while (/* CONSTCOND */ 0)
+
+#if HAVE_LOCALE_H
+ (void)setlocale(LC_ALL, "");
+#endif /* HAVE_LOCALE_H */
+
+ (void)puts("Testing our snprintf(3) against your system's sprintf(3).");
+ TEST(float_fmt, float_val);
+ TEST(long_fmt, long_val);
+ TEST(ulong_fmt, ulong_val);
+ TEST(llong_fmt, llong_val);
+ TEST(string_fmt, string_val);
+#if !OS_SYSV /* SysV uses a different format than we do. */
+ TEST(pointer_fmt, pointer_val);
+#endif /* !OS_SYSV */
+ (void)printf("Result: %d out of %d tests failed.\n", failed, num);
+
+ (void)fputs("Checking how many digits we support: ", stdout);
+ for (i = 0; i < 100; i++) {
+ value = pow(10, i) * digits;
+ (void)sprintf(buf1, "%.1f", value);
+ (void)snprintf(buf2, sizeof(buf2), "%.1f", value);
+ if (strcmp(buf1, buf2) != 0) {
+ (void)printf("apparently %d.\n", i);
+ break;
+ }
+ }
+ return (failed == 0) ? 0 : 1;
}
-#else
-int snprintf_bs;
-#endif
+#endif /* TEST_SNPRINTF */
+
+/* vim: set joinspaces textwidth=80: */
diff --git a/contrib/ntp/libntp/socket.c b/contrib/ntp/libntp/socket.c
new file mode 100644
index 0000000..11fb0046
--- /dev/null
+++ b/contrib/ntp/libntp/socket.c
@@ -0,0 +1,218 @@
+/*
+ * socket.c - low-level socket operations
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
+#include "ntp.h"
+#include "ntp_io.h"
+#include "ntp_net.h"
+#include "ntp_debug.h"
+
+/*
+ * Windows C runtime ioctl() can't deal properly with sockets,
+ * map to ioctlsocket for this source file.
+ */
+#ifdef SYS_WINNT
+#define ioctl(fd, opt, val) ioctlsocket(fd, opt, (u_long *)(val))
+#endif
+
+/*
+ * on Unix systems the stdio library typically
+ * makes use of file descriptors in the lower
+ * integer range. stdio usually will make use
+ * of the file descriptors in the range of
+ * [0..FOPEN_MAX)
+ * in order to keep this range clean, for socket
+ * file descriptors we attempt to move them above
+ * FOPEN_MAX. This is not as easy as it sounds as
+ * FOPEN_MAX changes from implementation to implementation
+ * and may exceed to current file decriptor limits.
+ * We are using following strategy:
+ * - keep a current socket fd boundary initialized with
+ * max(0, min(GETDTABLESIZE() - FD_CHUNK, FOPEN_MAX))
+ * - attempt to move the descriptor to the boundary or
+ * above.
+ * - if that fails and boundary > 0 set boundary
+ * to min(0, socket_fd_boundary - FD_CHUNK)
+ * -> retry
+ * if failure and boundary == 0 return old fd
+ * - on success close old fd return new fd
+ *
+ * effects:
+ * - fds will be moved above the socket fd boundary
+ * if at all possible.
+ * - the socket boundary will be reduced until
+ * allocation is possible or 0 is reached - at this
+ * point the algrithm will be disabled
+ */
+SOCKET
+move_fd(
+ SOCKET fd
+ )
+{
+#if !defined(SYS_WINNT) && defined(F_DUPFD)
+#ifndef FD_CHUNK
+#define FD_CHUNK 10
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+/*
+ * number of fds we would like to have for
+ * stdio FILE* available.
+ * we can pick a "low" number as our use of
+ * FILE* is limited to log files and temporarily
+ * to data and config files. Except for log files
+ * we don't keep the other FILE* open beyond the
+ * scope of the function that opened it.
+ */
+#ifndef FD_PREFERRED_SOCKBOUNDARY
+#define FD_PREFERRED_SOCKBOUNDARY 48
+#endif
+
+ static SOCKET socket_boundary = -1;
+ SOCKET newfd;
+
+ REQUIRE((int)fd >= 0);
+
+ /*
+ * check whether boundary has be set up
+ * already
+ */
+ if (socket_boundary == -1) {
+ socket_boundary = max(0, min(GETDTABLESIZE() - FD_CHUNK,
+ min(FOPEN_MAX, FD_PREFERRED_SOCKBOUNDARY)));
+ TRACE(1, ("move_fd: estimated max descriptors: %d, "
+ "initial socket boundary: %d\n",
+ GETDTABLESIZE(), socket_boundary));
+ }
+
+ /*
+ * Leave a space for stdio to work in. potentially moving the
+ * socket_boundary lower until allocation succeeds.
+ */
+ do {
+ if (fd >= 0 && fd < socket_boundary) {
+ /* inside reserved range: attempt to move fd */
+ newfd = fcntl(fd, F_DUPFD, socket_boundary);
+
+ if (newfd != -1) {
+ /* success: drop the old one - return the new one */
+ close(fd);
+ return newfd;
+ }
+ } else {
+ /* outside reserved range: no work - return the original one */
+ return fd;
+ }
+ socket_boundary = max(0, socket_boundary - FD_CHUNK);
+ TRACE(1, ("move_fd: selecting new socket boundary: %d\n",
+ socket_boundary));
+ } while (socket_boundary > 0);
+#else
+ ENSURE((int)fd >= 0);
+#endif /* !defined(SYS_WINNT) && defined(F_DUPFD) */
+ return fd;
+}
+
+
+/*
+ * make_socket_nonblocking() - set up descriptor to be non blocking
+ */
+void
+make_socket_nonblocking(
+ SOCKET fd
+ )
+{
+ /*
+ * set non-blocking,
+ */
+
+#ifdef USE_FIONBIO
+ /* in vxWorks we use FIONBIO, but the others are defined for old
+ * systems, so all hell breaks loose if we leave them defined
+ */
+#undef O_NONBLOCK
+#undef FNDELAY
+#undef O_NDELAY
+#endif
+
+#if defined(O_NONBLOCK) /* POSIX */
+ if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
+ msyslog(LOG_ERR,
+ "fcntl(O_NONBLOCK) fails on fd #%d: %m", fd);
+ exit(1);
+ }
+#elif defined(FNDELAY)
+ if (fcntl(fd, F_SETFL, FNDELAY) < 0) {
+ msyslog(LOG_ERR, "fcntl(FNDELAY) fails on fd #%d: %m",
+ fd);
+ exit(1);
+ }
+#elif defined(O_NDELAY) /* generally the same as FNDELAY */
+ if (fcntl(fd, F_SETFL, O_NDELAY) < 0) {
+ msyslog(LOG_ERR, "fcntl(O_NDELAY) fails on fd #%d: %m",
+ fd);
+ exit(1);
+ }
+#elif defined(FIONBIO)
+ {
+ int on = 1;
+
+ if (ioctl(fd, FIONBIO, &on) < 0) {
+ msyslog(LOG_ERR,
+ "ioctl(FIONBIO) fails on fd #%d: %m",
+ fd);
+ exit(1);
+ }
+ }
+#elif defined(FIOSNBIO)
+ if (ioctl(fd, FIOSNBIO, &on) < 0) {
+ msyslog(LOG_ERR,
+ "ioctl(FIOSNBIO) fails on fd #%d: %m", fd);
+ exit(1);
+ }
+#else
+# include "Bletch: Need non-blocking I/O!"
+#endif
+}
+
+#if 0
+
+/* The following subroutines should probably be moved here */
+
+static SOCKET
+open_socket(
+ sockaddr_u * addr,
+ int bcast,
+ int turn_off_reuse,
+ endpt * interf
+ )
+void
+sendpkt(
+ sockaddr_u * dest,
+ struct interface * ep,
+ int ttl,
+ struct pkt * pkt,
+ int len
+ )
+
+static inline int
+read_refclock_packet(SOCKET fd, struct refclockio *rp, l_fp ts)
+
+static inline int
+read_network_packet(
+ SOCKET fd,
+ struct interface * itf,
+ l_fp ts
+ )
+
+void
+kill_asyncio(int startfd)
+
+#endif /* 0 */
diff --git a/contrib/ntp/libntp/socktoa.c b/contrib/ntp/libntp/socktoa.c
index fb41b22..98abe7c 100644
--- a/contrib/ntp/libntp/socktoa.c
+++ b/contrib/ntp/libntp/socktoa.c
@@ -1,56 +1,170 @@
/*
- * socktoa - return a numeric host name from a sockaddr_storage structure
+ * socktoa.c socktoa(), sockporttoa(), and sock_hash()
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
-
-#include <arpa/inet.h>
-
-#ifdef ISC_PLATFORM_NEEDNTOP
-#include <isc/net.h>
#endif
#include <stdio.h>
+#include <arpa/inet.h>
+#include <isc/result.h>
+#include <isc/netaddr.h>
+#include <isc/sockaddr.h>
#include "ntp_fp.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"
-char *
+/*
+ * socktoa - return a numeric host name from a sockaddr_storage structure
+ */
+const char *
socktoa(
- struct sockaddr_storage* sock
+ const sockaddr_u *sock
)
{
- register char *buffer;
+ int saved_errno;
+ char * res;
+ char * addr;
+ u_long scope;
- LIB_GETBUF(buffer);
+ saved_errno = socket_errno();
+ LIB_GETBUF(res);
- if (sock == NULL)
- strcpy(buffer, "null");
- else
- {
+ if (NULL == sock) {
+ strlcpy(res, "(null)", LIB_BUFLENGTH);
+ } else {
+ switch(AF(sock)) {
- switch(sock->ss_family) {
+ case AF_INET:
+ case AF_UNSPEC:
+ inet_ntop(AF_INET, PSOCK_ADDR4(sock), res,
+ LIB_BUFLENGTH);
+ break;
- default:
- case AF_INET :
- inet_ntop(AF_INET, &GET_INADDR(*sock), buffer,
- LIB_BUFLENGTH);
+ case AF_INET6:
+ inet_ntop(AF_INET6, PSOCK_ADDR6(sock), res,
+ LIB_BUFLENGTH);
+ scope = SCOPE_VAR(sock);
+ if (0 != scope && !strchr(res, '%')) {
+ addr = res;
+ LIB_GETBUF(res);
+ snprintf(res, LIB_BUFLENGTH, "%s%%%lu",
+ addr, scope);
+ res[LIB_BUFLENGTH - 1] = '\0';
+ }
break;
- case AF_INET6 :
- inet_ntop(AF_INET6, &GET_INADDR6(*sock), buffer,
- LIB_BUFLENGTH);
-#if 0
default:
- strcpy(buffer, "unknown");
-#endif
+ snprintf(res, LIB_BUFLENGTH,
+ "(socktoa unknown family %d)",
+ AF(sock));
}
}
- return buffer;
+ errno = saved_errno;
+
+ return res;
+}
+
+
+const char *
+sockporttoa(
+ const sockaddr_u *sock
+ )
+{
+ int saved_errno;
+ const char * atext;
+ char * buf;
+
+ saved_errno = socket_errno();
+ atext = socktoa(sock);
+ LIB_GETBUF(buf);
+ snprintf(buf, LIB_BUFLENGTH,
+ (IS_IPV6(sock))
+ ? "[%s]:%hu"
+ : "%s:%hu",
+ atext, SRCPORT(sock));
+ errno = saved_errno;
+
+ return buf;
+}
+
+
+/*
+ * sock_hash - hash a sockaddr_u structure
+ */
+u_short
+sock_hash(
+ const sockaddr_u *addr
+ )
+{
+ u_int hashVal;
+ u_int j;
+ size_t len;
+ const u_char *pch;
+
+ hashVal = 0;
+ len = 0;
+
+ /*
+ * We can't just hash the whole thing because there are hidden
+ * fields in sockaddr_in6 that might be filled in by recvfrom(),
+ * so just use the family, port and address.
+ */
+ pch = (const void *)&AF(addr);
+ hashVal = 37 * hashVal + *pch;
+ if (sizeof(AF(addr)) > 1) {
+ pch++;
+ hashVal = 37 * hashVal + *pch;
+ }
+ switch(AF(addr)) {
+ case AF_INET:
+ pch = (const void *)&SOCK_ADDR4(addr);
+ len = sizeof(SOCK_ADDR4(addr));
+ break;
+
+ case AF_INET6:
+ pch = (const void *)&SOCK_ADDR6(addr);
+ len = sizeof(SOCK_ADDR6(addr));
+ break;
+ }
+
+ for (j = 0; j < len ; j++)
+ hashVal = 37 * hashVal + pch[j];
+
+ return (u_short)(hashVal & USHRT_MAX);
+}
+
+
+int
+sockaddr_masktoprefixlen(
+ const sockaddr_u * psa
+ )
+{
+ isc_netaddr_t isc_na;
+ isc_sockaddr_t isc_sa;
+ u_int pfxlen;
+ isc_result_t result;
+ int rc;
+
+ ZERO(isc_sa);
+ memcpy(&isc_sa.type, psa,
+ min(sizeof(isc_sa.type), sizeof(*psa)));
+ isc_netaddr_fromsockaddr(&isc_na, &isc_sa);
+ result = isc_netaddr_masktoprefixlen(&isc_na, &pfxlen);
+ rc = (ISC_R_SUCCESS == result)
+ ? (int)pfxlen
+ : -1;
+
+ return rc;
}
diff --git a/contrib/ntp/libntp/socktohost.c b/contrib/ntp/libntp/socktohost.c
index 7aafdc7..3d9ab960 100644
--- a/contrib/ntp/libntp/socktohost.c
+++ b/contrib/ntp/libntp/socktohost.c
@@ -1,9 +1,14 @@
/*
* socktoa - return a numeric host name from a sockaddr_storage structure
*/
+#include <config.h>
#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
#include <arpa/inet.h>
@@ -13,19 +18,93 @@
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"
+#include "ntp_debug.h"
-char *
+const char *
socktohost(
- struct sockaddr_storage* sock
+ const sockaddr_u *sock
)
{
- register char *buffer;
+ const char svc[] = "ntp";
+ char * pbuf;
+ char * pliar;
+ int gni_flags;
+ struct addrinfo hints;
+ struct addrinfo * alist;
+ struct addrinfo * ai;
+ sockaddr_u addr;
+ size_t octets;
+ int a_info;
- LIB_GETBUF(buffer);
- if (getnameinfo((struct sockaddr *)sock, SOCKLEN(sock), buffer,
- LIB_BUFLENGTH /* NI_MAXHOST*/, NULL, 0, 0))
- return stoa(sock);
+ /* reverse the address to purported DNS name */
+ LIB_GETBUF(pbuf);
+ gni_flags = NI_DGRAM | NI_NAMEREQD;
+ if (getnameinfo(&sock->sa, SOCKLEN(sock), pbuf, LIB_BUFLENGTH,
+ NULL, 0, gni_flags))
+ return stoa(sock); /* use address */
- return buffer;
+ TRACE(1, ("%s reversed to %s\n", stoa(sock), pbuf));
+
+ /*
+ * Resolve the reversed name and make sure the reversed address
+ * is among the results.
+ */
+ ZERO(hints);
+ hints.ai_family = AF(sock);
+ hints.ai_protocol = IPPROTO_UDP;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = 0;
+ alist = NULL;
+
+ a_info = getaddrinfo(pbuf, svc, &hints, &alist);
+ if (a_info == EAI_NONAME
+#ifdef EAI_NODATA
+ || a_info == EAI_NODATA
+#endif
+ ) {
+ hints.ai_flags = AI_CANONNAME;
+#ifdef AI_ADDRCONFIG
+ hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+ a_info = getaddrinfo(pbuf, svc, &hints, &alist);
+ }
+#ifdef AI_ADDRCONFIG
+ /* Some older implementations don't like AI_ADDRCONFIG. */
+ if (a_info == EAI_BADFLAGS) {
+ hints.ai_flags &= ~AI_ADDRCONFIG;
+ a_info = getaddrinfo(pbuf, svc, &hints, &alist);
+ }
+#endif
+ if (a_info)
+ goto forward_fail;
+
+ INSIST(alist != NULL);
+
+ for (ai = alist; ai != NULL; ai = ai->ai_next) {
+ /*
+ * Make a convenience sockaddr_u copy from ai->ai_addr
+ * because casting from sockaddr * to sockaddr_u * is
+ * risking alignment problems on platforms where
+ * sockaddr_u has stricter alignment than sockaddr,
+ * such as sparc.
+ */
+ ZERO_SOCK(&addr);
+ octets = min(sizeof(addr), ai->ai_addrlen);
+ memcpy(&addr, ai->ai_addr, octets);
+ if (SOCK_EQ(sock, &addr))
+ break;
+ }
+ freeaddrinfo(alist);
+
+ if (ai != NULL)
+ return pbuf; /* forward check passed */
+
+ forward_fail:
+ TRACE(1, ("%s forward check lookup fail: %s\n", pbuf,
+ gai_strerror(a_info)));
+ LIB_GETBUF(pliar);
+ snprintf(pliar, LIB_BUFLENGTH, "%s (%s)", stoa(sock), pbuf);
+
+ return pliar;
}
diff --git a/contrib/ntp/libntp/ssl_init.c b/contrib/ntp/libntp/ssl_init.c
new file mode 100644
index 0000000..a9d1d54
--- /dev/null
+++ b/contrib/ntp/libntp/ssl_init.c
@@ -0,0 +1,187 @@
+/*
+ * ssl_init.c Common OpenSSL initialization code for the various
+ * programs which use it.
+ *
+ * Moved from ntpd/ntp_crypto.c crypto_setup()
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <ctype.h>
+#include <ntp.h>
+#include <ntp_debug.h>
+#include <lib_strbuf.h>
+
+#ifdef OPENSSL
+#include "openssl/err.h"
+#include "openssl/evp.h"
+
+void atexit_ssl_cleanup(void);
+
+int ssl_init_done;
+
+void
+ssl_init(void)
+{
+ init_lib();
+
+ if (ssl_init_done)
+ return;
+
+ ERR_load_crypto_strings();
+ OpenSSL_add_all_algorithms();
+ atexit(&atexit_ssl_cleanup);
+
+ ssl_init_done = TRUE;
+}
+
+
+void
+atexit_ssl_cleanup(void)
+{
+ if (!ssl_init_done)
+ return;
+
+ ssl_init_done = FALSE;
+ EVP_cleanup();
+ ERR_free_strings();
+}
+
+
+void
+ssl_check_version(void)
+{
+ if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
+ msyslog(LOG_WARNING,
+ "OpenSSL version mismatch. Built against %lx, you have %lx",
+ (u_long)OPENSSL_VERSION_NUMBER, SSLeay());
+ fprintf(stderr,
+ "OpenSSL version mismatch. Built against %lx, you have %lx\n",
+ (u_long)OPENSSL_VERSION_NUMBER, SSLeay());
+ }
+
+ INIT_SSL();
+}
+#endif /* OPENSSL */
+
+
+/*
+ * keytype_from_text returns OpenSSL NID for digest by name, and
+ * optionally the associated digest length.
+ *
+ * Used by ntpd authreadkeys(), ntpq and ntpdc keytype()
+ */
+int
+keytype_from_text(
+ const char *text,
+ size_t *pdigest_len
+ )
+{
+ int key_type;
+ u_int digest_len;
+#ifdef OPENSSL
+ const u_long max_digest_len = MAX_MAC_LEN - sizeof(keyid_t);
+ u_char digest[EVP_MAX_MD_SIZE];
+ char * upcased;
+ char * pch;
+ EVP_MD_CTX ctx;
+
+ /*
+ * OpenSSL digest short names are capitalized, so uppercase the
+ * digest name before passing to OBJ_sn2nid(). If it is not
+ * recognized but begins with 'M' use NID_md5 to be consistent
+ * with past behavior.
+ */
+ INIT_SSL();
+ LIB_GETBUF(upcased);
+ strlcpy(upcased, text, LIB_BUFLENGTH);
+ for (pch = upcased; '\0' != *pch; pch++)
+ *pch = (char)toupper((unsigned char)*pch);
+ key_type = OBJ_sn2nid(upcased);
+#else
+ key_type = 0;
+#endif
+
+ if (!key_type && 'm' == tolower((unsigned char)text[0]))
+ key_type = NID_md5;
+
+ if (!key_type)
+ return 0;
+
+ if (NULL != pdigest_len) {
+#ifdef OPENSSL
+ EVP_DigestInit(&ctx, EVP_get_digestbynid(key_type));
+ EVP_DigestFinal(&ctx, digest, &digest_len);
+ if (digest_len > max_digest_len) {
+ fprintf(stderr,
+ "key type %s %u octet digests are too big, max %lu\n",
+ keytype_name(key_type), digest_len,
+ max_digest_len);
+ msyslog(LOG_ERR,
+ "key type %s %u octet digests are too big, max %lu",
+ keytype_name(key_type), digest_len,
+ max_digest_len);
+ return 0;
+ }
+#else
+ digest_len = 16;
+#endif
+ *pdigest_len = digest_len;
+ }
+
+ return key_type;
+}
+
+
+/*
+ * keytype_name returns OpenSSL short name for digest by NID.
+ *
+ * Used by ntpq and ntpdc keytype()
+ */
+const char *
+keytype_name(
+ int nid
+ )
+{
+ static const char unknown_type[] = "(unknown key type)";
+ const char *name;
+
+#ifdef OPENSSL
+ INIT_SSL();
+ name = OBJ_nid2sn(nid);
+ if (NULL == name)
+ name = unknown_type;
+#else /* !OPENSSL follows */
+ if (NID_md5 == nid)
+ name = "MD5";
+ else
+ name = unknown_type;
+#endif
+ return name;
+}
+
+
+/*
+ * Use getpassphrase() if configure.ac detected it, as Suns that
+ * have it truncate the password in getpass() to 8 characters.
+ */
+#ifdef HAVE_GETPASSPHRASE
+# define getpass(str) getpassphrase(str)
+#endif
+
+/*
+ * getpass_keytype() -- shared between ntpq and ntpdc, only vaguely
+ * related to the rest of ssl_init.c.
+ */
+char *
+getpass_keytype(
+ int keytype
+ )
+{
+ char pass_prompt[64 + 11 + 1]; /* 11 for " Password: " */
+
+ snprintf(pass_prompt, sizeof(pass_prompt),
+ "%.64s Password: ", keytype_name(keytype));
+
+ return getpass(pass_prompt);
+}
diff --git a/contrib/ntp/libntp/statestr.c b/contrib/ntp/libntp/statestr.c
index 85552b3..313cd46 100644
--- a/contrib/ntp/libntp/statestr.c
+++ b/contrib/ntp/libntp/statestr.c
@@ -12,118 +12,191 @@
#include "ntp_refclock.h"
#include "ntp_control.h"
#include "ntp_string.h"
+#ifdef KERNEL_PLL
+# include "ntp_syscall.h"
+#endif
+
/*
* Structure for turning various constants into a readable string.
*/
struct codestring {
int code;
- const char *string;
+ const char * const string;
};
/*
- * Leap values
+ * Leap status (leap)
*/
-static
-struct codestring leap_codes[] = {
+static const struct codestring leap_codes[] = {
{ LEAP_NOWARNING, "leap_none" },
{ LEAP_ADDSECOND, "leap_add_sec" },
{ LEAP_DELSECOND, "leap_del_sec" },
- { LEAP_NOTINSYNC, "sync_alarm" },
- { -1, "leap" }
+ { LEAP_NOTINSYNC, "leap_alarm" },
+ { -1, "leap" }
};
/*
- * Clock source
+ * Clock source status (sync)
*/
-static
-struct codestring sync_codes[] = {
+static const struct codestring sync_codes[] = {
{ CTL_SST_TS_UNSPEC, "sync_unspec" },
- { CTL_SST_TS_ATOM, "sync_atomic" },
- { CTL_SST_TS_LF, "sync_lf_clock" },
- { CTL_SST_TS_HF, "sync_hf_clock" },
- { CTL_SST_TS_UHF, "sync_uhf_clock" },
- { CTL_SST_TS_LOCAL, "sync_local_proto" },
+ { CTL_SST_TS_ATOM, "sync_pps" },
+ { CTL_SST_TS_LF, "sync_lf_radio" },
+ { CTL_SST_TS_HF, "sync_hf_radio" },
+ { CTL_SST_TS_UHF, "sync_uhf_radio" },
+ { CTL_SST_TS_LOCAL, "sync_local" },
{ CTL_SST_TS_NTP, "sync_ntp" },
- { CTL_SST_TS_UDPTIME, "sync_udp/time" },
+ { CTL_SST_TS_UDPTIME, "sync_other" },
{ CTL_SST_TS_WRSTWTCH, "sync_wristwatch" },
{ CTL_SST_TS_TELEPHONE, "sync_telephone" },
{ -1, "sync" }
};
-
/*
- * Peer selection
+ * Peer selection status (sel)
*/
-static
-struct codestring select_codes[] = {
- { CTL_PST_SEL_REJECT, "selreject" },
+static const struct codestring select_codes[] = {
+ { CTL_PST_SEL_REJECT, "sel_reject" },
{ CTL_PST_SEL_SANE, "sel_falsetick" },
{ CTL_PST_SEL_CORRECT, "sel_excess" },
- { CTL_PST_SEL_SELCAND, "sel_outlyer" },
- { CTL_PST_SEL_SYNCCAND, "sel_candidat" },
- { CTL_PST_SEL_DISTSYSPEER, "sel_selected" },
+ { CTL_PST_SEL_SELCAND, "sel_outlier" },
+ { CTL_PST_SEL_SYNCCAND, "sel_candidate" },
+ { CTL_PST_SEL_EXCESS, "sel_backup" },
{ CTL_PST_SEL_SYSPEER, "sel_sys.peer" },
{ CTL_PST_SEL_PPS, "sel_pps.peer" },
{ -1, "sel" }
};
-
/*
- * Clock status
+ * Clock status (clk)
*/
-static
-struct codestring clock_codes[] = {
- { CTL_CLK_OKAY, "clk_okay" },
- { CTL_CLK_NOREPLY, "clk_noreply" },
- { CTL_CLK_BADFORMAT, "clk_badformat" },
+static const struct codestring clock_codes[] = {
+ { CTL_CLK_OKAY, "clk_unspec" },
+ { CTL_CLK_NOREPLY, "clk_no_reply" },
+ { CTL_CLK_BADFORMAT, "clk_bad_format" },
{ CTL_CLK_FAULT, "clk_fault" },
- { CTL_CLK_PROPAGATION, "clk_badsignal" },
- { CTL_CLK_BADDATE, "clk_baddate" },
- { CTL_CLK_BADTIME, "clk_badtime" },
+ { CTL_CLK_PROPAGATION, "clk_bad_signal" },
+ { CTL_CLK_BADDATE, "clk_bad_date" },
+ { CTL_CLK_BADTIME, "clk_bad_time" },
{ -1, "clk" }
};
+#ifdef FLASH_CODES_UNUSED
+/*
+ * Flash bits -- see ntpq.c tstflags & tstflagnames
+ */
+static const struct codestring flash_codes[] = {
+ { TEST1, "pkt_dup" },
+ { TEST2, "pkt_bogus" },
+ { TEST3, "pkt_unsync" },
+ { TEST4, "pkt_denied" },
+ { TEST5, "pkt_auth" },
+ { TEST6, "pkt_stratum" },
+ { TEST7, "pkt_header" },
+ { TEST8, "pkt_autokey" },
+ { TEST9, "pkt_crypto" },
+ { TEST10, "peer_stratum" },
+ { TEST11, "peer_dist" },
+ { TEST12, "peer_loop" },
+ { TEST13, "peer_unreach" },
+ { -1, "flash" }
+};
+#endif
+
+
/*
- * System Events
+ * System events (sys)
*/
-static
-struct codestring sys_codes[] = {
- { EVNT_UNSPEC, "event_unspec" },
- { EVNT_SYSRESTART, "event_restart" },
- { EVNT_SYSFAULT, "event_fault" },
- { EVNT_SYNCCHG, "event_sync_chg" },
- { EVNT_PEERSTCHG, "event_peer/strat_chg" },
- { EVNT_CLOCKRESET, "event_clock_reset" },
- { EVNT_BADDATETIM, "event_bad_date" },
- { EVNT_CLOCKEXCPT, "event_clock_excptn" },
- { -1, "event" }
+static const struct codestring sys_codes[] = {
+ { EVNT_UNSPEC, "unspecified" },
+ { EVNT_NSET, "freq_not_set" },
+ { EVNT_FSET, "freq_set" },
+ { EVNT_SPIK, "spike_detect" },
+ { EVNT_FREQ, "freq_mode" },
+ { EVNT_SYNC, "clock_sync" },
+ { EVNT_SYSRESTART, "restart" },
+ { EVNT_SYSFAULT, "panic_stop" },
+ { EVNT_NOPEER, "no_sys_peer" },
+ { EVNT_ARMED, "leap_armed" },
+ { EVNT_DISARMED, "leap_disarmed" },
+ { EVNT_LEAP, "leap_event" },
+ { EVNT_CLOCKRESET, "clock_step" },
+ { EVNT_KERN, "kern" },
+ { EVNT_TAI, "TAI" },
+ { EVNT_LEAPVAL, "stale_leapsecond_values" },
+ { -1, "" }
};
/*
- * Peer events
+ * Peer events (peer)
*/
-static
-struct codestring peer_codes[] = {
- { EVNT_UNSPEC, "event_unspec" },
- { EVNT_PEERIPERR & ~PEER_EVENT, "event_ip_err" },
- { EVNT_PEERAUTH & ~PEER_EVENT, "event_authen" },
- { EVNT_UNREACH & ~PEER_EVENT, "event_unreach" },
- { EVNT_REACH & ~PEER_EVENT, "event_reach" },
- { EVNT_PEERCLOCK & ~PEER_EVENT, "event_peer_clock" },
-#if 0
- { EVNT_PEERSTRAT & ~PEER_EVENT, "event_stratum_chg" },
-#endif
- { -1, "event" }
+static const struct codestring peer_codes[] = {
+ { PEVNT_MOBIL & ~PEER_EVENT, "mobilize" },
+ { PEVNT_DEMOBIL & ~PEER_EVENT, "demobilize" },
+ { PEVNT_UNREACH & ~PEER_EVENT, "unreachable" },
+ { PEVNT_REACH & ~PEER_EVENT, "reachable" },
+ { PEVNT_RESTART & ~PEER_EVENT, "restart" },
+ { PEVNT_REPLY & ~PEER_EVENT, "no_reply" },
+ { PEVNT_RATE & ~PEER_EVENT, "rate_exceeded" },
+ { PEVNT_DENY & ~PEER_EVENT, "access_denied" },
+ { PEVNT_ARMED & ~PEER_EVENT, "leap_armed" },
+ { PEVNT_NEWPEER & ~PEER_EVENT, "sys_peer" },
+ { PEVNT_CLOCK & ~PEER_EVENT, "clock_event" },
+ { PEVNT_AUTH & ~PEER_EVENT, "bad_auth" },
+ { PEVNT_POPCORN & ~PEER_EVENT, "popcorn" },
+ { PEVNT_XLEAVE & ~PEER_EVENT, "interleave_mode" },
+ { PEVNT_XERR & ~PEER_EVENT, "interleave_error" },
+ { -1, "" }
+};
+
+/*
+ * Peer status bits
+ */
+static const struct codestring peer_st_bits[] = {
+ { CTL_PST_CONFIG, "conf" },
+ { CTL_PST_AUTHENABLE, "authenb" },
+ { CTL_PST_AUTHENTIC, "auth" },
+ { CTL_PST_REACH, "reach" },
+ { CTL_PST_BCAST, "bcast" },
+ /* not used with getcode(), no terminating entry needed */
+};
+
+/*
+ * Restriction match bits
+ */
+static const struct codestring res_match_bits[] = {
+ { RESM_NTPONLY, "ntpport" },
+ { RESM_INTERFACE, "interface" },
+ { RESM_SOURCE, "source" },
+ /* not used with getcode(), no terminating entry needed */
+};
+
+/*
+ * Restriction access bits
+ */
+static const struct codestring res_access_bits[] = {
+ { RES_IGNORE, "ignore" },
+ { RES_DONTSERVE, "noserve" },
+ { RES_DONTTRUST, "notrust" },
+ { RES_NOQUERY, "noquery" },
+ { RES_NOMODIFY, "nomodify" },
+ { RES_NOPEER, "nopeer" },
+ { RES_NOTRAP, "notrap" },
+ { RES_LPTRAP, "lptrap" },
+ { RES_LIMITED, "limited" },
+ { RES_VERSION, "version" },
+ { RES_KOD, "kod" },
+ { RES_FLAKE, "flake" },
+ /* not used with getcode(), no terminating entry needed */
};
-#ifdef OPENSSL
+#ifdef AUTOKEY
/*
- * Crypto events
+ * Crypto events (cryp)
*/
-static
-struct codestring crypto_codes[] = {
+static const struct codestring crypto_codes[] = {
{ XEVNT_OK & ~CRPT_EVENT, "success" },
{ XEVNT_LEN & ~CRPT_EVENT, "bad_field_format_or_length" },
{ XEVNT_TSP & ~CRPT_EVENT, "bad_timestamp" },
@@ -134,38 +207,98 @@ struct codestring crypto_codes[] = {
{ XEVNT_SGL & ~CRPT_EVENT, "bad_signature_length" },
{ XEVNT_SIG & ~CRPT_EVENT, "signature_not_verified" },
{ XEVNT_VFY & ~CRPT_EVENT, "certificate_not_verified" },
- { XEVNT_PER & ~CRPT_EVENT, "host certificate_expired" },
+ { XEVNT_PER & ~CRPT_EVENT, "host_certificate_expired" },
{ XEVNT_CKY & ~CRPT_EVENT, "bad_or_missing_cookie" },
- { XEVNT_DAT & ~CRPT_EVENT, "bad_or_missing_leapsecond_table" },
+ { XEVNT_DAT & ~CRPT_EVENT, "bad_or_missing_leapseconds" },
{ XEVNT_CRT & ~CRPT_EVENT, "bad_or_missing_certificate" },
- { XEVNT_ID & ~CRPT_EVENT, "bad_or_missing_group_key" },
+ { XEVNT_ID & ~CRPT_EVENT, "bad_or_missing_group key" },
{ XEVNT_ERR & ~CRPT_EVENT, "protocol_error" },
- { XEVNT_SRV & ~CRPT_EVENT, "server certificate expired" },
- { -1, "crypto" }
+ { -1, "" }
+};
+#endif /* AUTOKEY */
+
+#ifdef KERNEL_PLL
+/*
+ * kernel discipline status bits
+ */
+static const struct codestring k_st_bits[] = {
+# ifdef STA_PLL
+ { STA_PLL, "pll" },
+# endif
+# ifdef STA_PPSFREQ
+ { STA_PPSFREQ, "ppsfreq" },
+# endif
+# ifdef STA_PPSTIME
+ { STA_PPSTIME, "ppstime" },
+# endif
+# ifdef STA_FLL
+ { STA_FLL, "fll" },
+# endif
+# ifdef STA_INS
+ { STA_INS, "ins" },
+# endif
+# ifdef STA_DEL
+ { STA_DEL, "del" },
+# endif
+# ifdef STA_UNSYNC
+ { STA_UNSYNC, "unsync" },
+# endif
+# ifdef STA_FREQHOLD
+ { STA_FREQHOLD, "freqhold" },
+# endif
+# ifdef STA_PPSSIGNAL
+ { STA_PPSSIGNAL, "ppssignal" },
+# endif
+# ifdef STA_PPSJITTER
+ { STA_PPSJITTER, "ppsjitter" },
+# endif
+# ifdef STA_PPSWANDER
+ { STA_PPSWANDER, "ppswander" },
+# endif
+# ifdef STA_PPSERROR
+ { STA_PPSERROR, "ppserror" },
+# endif
+# ifdef STA_CLOCKERR
+ { STA_CLOCKERR, "clockerr" },
+# endif
+# ifdef STA_NANO
+ { STA_NANO, "nano" },
+# endif
+# ifdef STA_MODE
+ { STA_MODE, "mode=fll" },
+# endif
+# ifdef STA_CLK
+ { STA_CLK, "src=B" },
+# endif
+ /* not used with getcode(), no terminating entry needed */
};
-#endif /* OPENSSL */
+#endif /* KERNEL_PLL */
/* Forwards */
-static const char *getcode P((int, struct codestring *));
-static const char *getevents P((int));
+static const char * getcode(int, const struct codestring *);
+static const char * getevents(int);
+static const char * peer_st_flags(u_char pst);
/*
* getcode - return string corresponding to code
*/
static const char *
getcode(
- int code,
- struct codestring *codetab
+ int code,
+ const struct codestring * codetab
)
{
- static char buf[30];
+ char * buf;
while (codetab->code != -1) {
if (codetab->code == code)
- return codetab->string;
+ return codetab->string;
codetab++;
}
- (void) sprintf(buf, "%s_%d", codetab->string, code);
+
+ LIB_GETBUF(buf);
+ snprintf(buf, LIB_BUFLENGTH, "%s_%d", codetab->string, code);
+
return buf;
}
@@ -177,14 +310,124 @@ getevents(
int cnt
)
{
- static char buf[20];
+ char * buf;
if (cnt == 0)
- return "no events";
- (void) sprintf(buf, "%d event%s", cnt, (cnt==1) ? "" : "s");
+ return "no events";
+
+ LIB_GETBUF(buf);
+ snprintf(buf, LIB_BUFLENGTH, "%d event%s", cnt,
+ (1 == cnt)
+ ? ""
+ : "s");
+
+ return buf;
+}
+
+
+/*
+ * decode_bitflags()
+ *
+ * returns a human-readable string with a keyword from tab for each bit
+ * set in bits, separating multiple entries with text of sep2.
+ */
+static const char *
+decode_bitflags(
+ int bits,
+ const char * sep2,
+ const struct codestring * tab,
+ size_t tab_ct
+ )
+{
+ const char * sep;
+ char * buf;
+ char * pch;
+ char * lim;
+ size_t b;
+ int rc;
+ int saved_errno; /* for use in DPRINTF with %m */
+
+ saved_errno = errno;
+ LIB_GETBUF(buf);
+ pch = buf;
+ lim = buf + LIB_BUFLENGTH;
+ sep = "";
+
+ for (b = 0; b < tab_ct; b++) {
+ if (tab[b].code & bits) {
+ rc = snprintf(pch, (lim - pch), "%s%s", sep,
+ tab[b].string);
+ if (rc < 0)
+ goto toosmall;
+ pch += (u_int)rc;
+ if (pch >= lim)
+ goto toosmall;
+ sep = sep2;
+ }
+ }
+
+ return buf;
+
+ toosmall:
+ snprintf(buf, LIB_BUFLENGTH,
+ "decode_bitflags(%s) can't decode 0x%x in %d bytes",
+ (tab == peer_st_bits)
+ ? "peer_st"
+ :
+#ifdef KERNEL_PLL
+ (tab == k_st_bits)
+ ? "kern_st"
+ :
+#endif
+ "",
+ bits, (int)LIB_BUFLENGTH);
+ errno = saved_errno;
+
return buf;
}
+
+static const char *
+peer_st_flags(
+ u_char pst
+ )
+{
+ return decode_bitflags(pst, ", ", peer_st_bits,
+ COUNTOF(peer_st_bits));
+}
+
+
+const char *
+res_match_flags(
+ u_short mf
+ )
+{
+ return decode_bitflags(mf, " ", res_match_bits,
+ COUNTOF(res_match_bits));
+}
+
+
+const char *
+res_access_flags(
+ u_short af
+ )
+{
+ return decode_bitflags(af, " ", res_access_bits,
+ COUNTOF(res_access_bits));
+}
+
+
+#ifdef KERNEL_PLL
+const char *
+k_st_flags(
+ u_int32 st
+ )
+{
+ return decode_bitflags(st, " ", k_st_bits, COUNTOF(k_st_bits));
+}
+#endif /* KERNEL_PLL */
+
+
/*
* statustoa - return a descriptive string for a peer status
*/
@@ -194,66 +437,43 @@ statustoa(
int st
)
{
- char *cb;
- u_char pst;
+ char * cb;
+ char * cc;
+ u_char pst;
LIB_GETBUF(cb);
switch (type) {
- case TYPE_SYS:
- (void)strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes));
- (void)strcat(cb, ", ");
- (void)strcat(cb, getcode(CTL_SYS_SOURCE(st) & ~CTL_SST_TS_PPS, sync_codes));
- if (CTL_SYS_SOURCE(st) & CTL_SST_TS_PPS)
- (void)strcat(cb, "/PPS");
- (void)strcat(cb, ", ");
- (void)strcat(cb, getevents(CTL_SYS_NEVNT(st)));
- (void)strcat(cb, ", ");
- (void)strcat(cb, getcode(CTL_SYS_EVENT(st), sys_codes));
+
+ case TYPE_SYS:
+ snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s, %s",
+ getcode(CTL_SYS_LI(st), leap_codes),
+ getcode(CTL_SYS_SOURCE(st), sync_codes),
+ getevents(CTL_SYS_NEVNT(st)),
+ getcode(CTL_SYS_EVENT(st), sys_codes));
break;
- case TYPE_PEER:
- /*
- * Handcraft the bits
- */
- pst = (u_char) CTL_PEER_STATVAL(st);
- if (!(pst & CTL_PST_REACH)) {
- (void)strcpy(cb, "unreach");
- } else {
- (void)strcpy(cb, "reach");
-
- }
- if (pst & CTL_PST_CONFIG)
- (void)strcat(cb, ", conf");
- if (pst & CTL_PST_AUTHENABLE) {
- if (!(pst & CTL_PST_REACH) || (pst & CTL_PST_AUTHENTIC))
- (void)strcat(cb, ", auth");
- else
- (void)strcat(cb, ", unauth");
- }
-
- /*
- * Now the codes
- */
- if ((pst & 0x7) != CTL_PST_SEL_REJECT) {
- (void)strcat(cb, ", ");
- (void)strcat(cb, getcode(pst & 0x7, select_codes));
- }
- (void)strcat(cb, ", ");
- (void)strcat(cb, getevents(CTL_PEER_NEVNT(st)));
+ case TYPE_PEER:
+ pst = (u_char)CTL_PEER_STATVAL(st);
+ snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s",
+ peer_st_flags(pst),
+ getcode(pst & 0x7, select_codes),
+ getevents(CTL_PEER_NEVNT(st)));
if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
- (void)strcat(cb, ", ");
- (void)strcat(cb, getcode(CTL_PEER_EVENT(st),
- peer_codes));
+ cc = cb + strlen(cb);
+ snprintf(cc, LIB_BUFLENGTH - (cc - cb), ", %s",
+ getcode(CTL_PEER_EVENT(st),
+ peer_codes));
}
break;
- case TYPE_CLOCK:
- (void)strcpy(cb, getcode(((st)>>8) & 0xff, clock_codes));
- (void)strcat(cb, ", last_");
- (void)strcat(cb, getcode((st) & 0xff, clock_codes));
+ case TYPE_CLOCK:
+ snprintf(cb, LIB_BUFLENGTH, "%s, %s",
+ getevents(CTL_SYS_NEVNT(st)),
+ getcode((st) & 0xf, clock_codes));
break;
}
+
return cb;
}
@@ -264,10 +484,10 @@ eventstr(
{
if (num & PEER_EVENT)
return (getcode(num & ~PEER_EVENT, peer_codes));
-#ifdef OPENSSL
+#ifdef AUTOKEY
else if (num & CRPT_EVENT)
return (getcode(num & ~CRPT_EVENT, crypto_codes));
-#endif /* OPENSSL */
+#endif /* AUTOKEY */
else
return (getcode(num, sys_codes));
}
@@ -279,27 +499,3 @@ ceventstr(
{
return getcode(num, clock_codes);
}
-
-const char *
-sysstatstr(
- int status
- )
-{
- return statustoa(TYPE_SYS, status);
-}
-
-const char *
-peerstatstr(
- int status
- )
-{
- return statustoa(TYPE_PEER, status);
-}
-
-const char *
-clockstatstr(
- int status
- )
-{
- return statustoa(TYPE_CLOCK, status);
-}
diff --git a/contrib/ntp/libntp/strdup.c b/contrib/ntp/libntp/strdup.c
index 2e26ba7..62d5a16 100644
--- a/contrib/ntp/libntp/strdup.c
+++ b/contrib/ntp/libntp/strdup.c
@@ -1,8 +1,10 @@
-#include "ntp_malloc.h"
+#include <config.h>
-#if !HAVE_STRDUP
+#include <ntp_assert.h>
+#include "ntp_malloc.h"
+#include <string.h>
-#define NULL 0
+#ifndef HAVE_STRDUP
char *strdup(const char *s);
@@ -11,18 +13,17 @@ strdup(
const char *s
)
{
- char *cp;
+ size_t octets;
+ char * cp;
+
+ REQUIRE(s);
+ octets = strlen(s) + 1;
+ if ((cp = malloc(octets)) == NULL)
+ return NULL;
+ memcpy(cp, s, octets);
- if (s) {
- cp = (char *) malloc((unsigned) (strlen(s)+1));
- if (cp) {
- (void) strcpy(cp, s);
- }
- } else {
- cp = (char *) NULL;
- }
- return(cp);
+ return cp;
}
#else
-int strdup_bs;
+int strdup_c_nonempty_compilation_unit;
#endif
diff --git a/contrib/ntp/libntp/strl_obsd.c b/contrib/ntp/libntp/strl_obsd.c
new file mode 100644
index 0000000..cb8d4f3
--- /dev/null
+++ b/contrib/ntp/libntp/strl_obsd.c
@@ -0,0 +1,123 @@
+/*
+ * Why use strlcpy()/strlcat() instead of standard strncpy()/strncat()?
+ * To reduce likelihood of bugs and avoid wasteful zero fills. See:
+ * http://www.gratisoft.us/todd/papers/strlcpy.html
+ */
+
+/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <config.h> /* + marks local changes */
+#ifdef HAVE_SYS_TYPES_H /* + */
+#include <sys/types.h>
+#endif /* + */
+#include <string.h>
+
+#include "ntp_stdlib.h" /* + strlcpy, strlcat prototypes */
+
+#ifndef HAVE_STRLCPY /* + */
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+#endif /* + */
+
+
+/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* #include <sys/types.h> */ /* + */
+/* #include <string.h> */ /* + */
+
+#ifndef HAVE_STRLCAT /* + */
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
+#endif /* + */
diff --git a/contrib/ntp/libntp/strstr.c b/contrib/ntp/libntp/strstr.c
deleted file mode 100644
index a4deb87..0000000
--- a/contrib/ntp/libntp/strstr.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <config.h>
-
-#if !HAVE_STRSTR
-
-/*
- * Amanda, The Advanced Maryland Automatic Network Disk Archiver
- * Copyright (c) 1991-1998 University of Maryland at College Park
- * All Rights Reserved.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of U.M. not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. U.M. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: James da Silva, Systems Design and Analysis Group
- * Computer Science Department
- * University of Maryland at College Park
- */
-/*
- * $Id$
- *
- * replacement for missing ANSI-C strstr function
- */
-
-char *strstr(a, b)
-char *a, *b;
-{
- int alen, blen, i;
-
- alen = strlen(a);
- blen = strlen(b);
-
- for(i=0; i <= alen-blen; i++, a++)
- if(strncmp(a, b, blen) == 0) return a;
-
- return NULL;
-}
-#else
-int strstr_bs;
-#endif
diff --git a/contrib/ntp/libntp/syssignal.c b/contrib/ntp/libntp/syssignal.c
index 6ec4c4c..5e496a9 100644
--- a/contrib/ntp/libntp/syssignal.c
+++ b/contrib/ntp/libntp/syssignal.c
@@ -9,64 +9,50 @@
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
+static ctrl_c_fn ctrl_c_hook;
+#ifndef SYS_WINNT
+RETSIGTYPE sigint_handler(int);
+#else
+BOOL WINAPI console_event_handler(DWORD);
+#endif
+
+
#ifdef HAVE_SIGACTION
+# ifdef SA_RESTART
+# define Z_SA_RESTART SA_RESTART
+# else
+# define Z_SA_RESTART 0
+# endif
+
void
signal_no_reset(
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
int sig,
- void (*func) (int)
-#else
- sig, func
-#endif
+ void (*func)(int)
)
-#if defined(__STDC__) || defined(HAVE_STDARG_H)
-#else
- int sig;
- void (*func) P((int));
-#endif
{
int n;
struct sigaction vec;
+ struct sigaction ovec;
- vec.sa_handler = func;
+ ZERO(vec);
sigemptyset(&vec.sa_mask);
-#if 0
-#ifdef SA_RESTART
- vec.sa_flags = SA_RESTART;
-#else
- vec.sa_flags = 0;
-#endif
-#else
- vec.sa_flags = 0;
-#endif
+ vec.sa_handler = func;
-#ifdef SA_RESTART
-/* Added for PPS clocks on Solaris 7 which get EINTR errors */
+ /* Added for PPS clocks on Solaris 7 which get EINTR errors */
# ifdef SIGPOLL
- if (sig == SIGPOLL) vec.sa_flags = SA_RESTART;
+ if (SIGPOLL == sig)
+ vec.sa_flags = Z_SA_RESTART;
# endif
# ifdef SIGIO
- if (sig == SIGIO) vec.sa_flags = SA_RESTART;
+ if (SIGIO == sig)
+ vec.sa_flags = Z_SA_RESTART;
# endif
-#endif
-
- while (1)
- {
- struct sigaction ovec;
+ do
n = sigaction(sig, &vec, &ovec);
- if (n == -1 && errno == EINTR) continue;
- if (ovec.sa_flags
-#ifdef SA_RESTART
- && ovec.sa_flags != SA_RESTART
-#endif
- )
- msyslog(LOG_DEBUG, "signal_no_reset: signal %d had flags %x",
- sig, ovec.sa_flags);
- break;
- }
- if (n == -1) {
+ while (-1 == n && EINTR == errno);
+ if (-1 == n) {
perror("sigaction");
exit(1);
}
@@ -77,16 +63,16 @@ signal_no_reset(
void
signal_no_reset(
int sig,
- RETSIGTYPE (*func) (int)
+ RETSIGTYPE (*func)(int)
)
{
struct sigvec sv;
int n;
- bzero((char *) &sv, sizeof(sv));
+ ZERO(sv);
sv.sv_handler = func;
n = sigvec(sig, &sv, (struct sigvec *)NULL);
- if (n == -1) {
+ if (-1 == n) {
perror("sigvec");
exit(1);
}
@@ -97,13 +83,13 @@ signal_no_reset(
void
signal_no_reset(
int sig,
- RETSIGTYPE (*func) (int)
+ RETSIGTYPE (*func)(int)
)
{
int n;
n = sigset(sig, func);
- if (n == -1) {
+ if (-1 == n) {
perror("sigset");
exit(1);
}
@@ -115,19 +101,88 @@ signal_no_reset(
void
signal_no_reset(
int sig,
- RETSIGTYPE (*func) (int)
+ RETSIGTYPE (*func)(int)
)
{
-#ifdef SIG_ERR
- if (SIG_ERR == signal(sig, func)) {
-#else
- int n;
- n = signal(sig, func);
- if (n == -1) {
+#ifndef SIG_ERR
+# define SIG_ERR (-1)
#endif
+ if (SIG_ERR == signal(sig, func)) {
perror("signal");
exit(1);
}
}
#endif
+
+#ifndef SYS_WINNT
+/*
+ * POSIX implementation of set_ctrl_c_hook()
+ */
+RETSIGTYPE
+sigint_handler(
+ int signum
+ )
+{
+ UNUSED_ARG(signum);
+ if (ctrl_c_hook != NULL)
+ (*ctrl_c_hook)();
+}
+
+void
+set_ctrl_c_hook(
+ ctrl_c_fn c_hook
+ )
+{
+ RETSIGTYPE (*handler)(int);
+
+ if (NULL == c_hook) {
+ handler = SIG_DFL;
+ ctrl_c_hook = NULL;
+ } else {
+ handler = &sigint_handler;
+ ctrl_c_hook = c_hook;
+ }
+ signal_no_reset(SIGINT, handler);
+}
+#else /* SYS_WINNT follows */
+/*
+ * Windows implementation of set_ctrl_c_hook()
+ */
+BOOL WINAPI
+console_event_handler(
+ DWORD dwCtrlType
+ )
+{
+ BOOL handled;
+
+ if (CTRL_C_EVENT == dwCtrlType && ctrl_c_hook != NULL) {
+ (*ctrl_c_hook)();
+ handled = TRUE;
+ } else {
+ handled = FALSE;
+ }
+
+ return handled;
+}
+void
+set_ctrl_c_hook(
+ ctrl_c_fn c_hook
+ )
+{
+ BOOL install;
+
+ if (NULL == c_hook) {
+ ctrl_c_hook = NULL;
+ install = FALSE;
+ } else {
+ ctrl_c_hook = c_hook;
+ install = TRUE;
+ }
+ if (!SetConsoleCtrlHandler(&console_event_handler, install))
+ msyslog(LOG_ERR, "Can't %s console control handler: %m",
+ (install)
+ ? "add"
+ : "remove");
+}
+#endif /* SYS_WINNT */
diff --git a/contrib/ntp/libntp/systime.c b/contrib/ntp/libntp/systime.c
index 4539b5f..f5eabcd 100644
--- a/contrib/ntp/libntp/systime.c
+++ b/contrib/ntp/libntp/systime.c
@@ -4,17 +4,16 @@
* ATTENTION: Get approval from Dave Mills on all changes to this file!
*
*/
-#include "ntp_machine.h"
-#include "ntp_fp.h"
+#include <config.h>
+
+#include "ntp.h"
#include "ntp_syslog.h"
-#include "ntp_unixtime.h"
#include "ntp_stdlib.h"
#include "ntp_random.h"
-#include "ntpd.h" /* for sys_precision */
-
-#ifdef SIM
-# include "ntpsim.h"
-#endif /*SIM */
+#include "iosignal.h"
+#include "timevalops.h"
+#include "timespecops.h"
+#include "ntp_calendar.h"
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
@@ -26,27 +25,135 @@
# include <utmpx.h>
#endif /* HAVE_UTMPX_H */
+
+#ifndef USE_COMPILETIME_PIVOT
+# define USE_COMPILETIME_PIVOT 1
+#endif
+
/*
* These routines (get_systime, step_systime, adj_systime) implement an
* interface between the system independent NTP clock and the Unix
- * system clock in various architectures and operating systems.
+ * system clock in various architectures and operating systems. Time is
+ * a precious quantity in these routines and every effort is made to
+ * minimize errors by unbiased rounding and amortizing adjustment
+ * residues.
+ *
+ * In order to improve the apparent resolution, provide unbiased
+ * rounding and most importantly ensure that the readings cannot be
+ * predicted, the low-order unused portion of the time below the minimum
+ * time to read the clock is filled with an unbiased random fuzz.
*
- * Time is a precious quantity in these routines and every effort is
- * made to minimize errors by always rounding toward zero and amortizing
- * adjustment residues. By default the adjustment quantum is 1 us for
- * the usual Unix tickadj() system call, but this can be increased if
- * necessary by the tick configuration command. For instance, when the
- * adjtime() quantum is a clock tick for a 100-Hz clock, the quantum
- * should be 10 ms.
+ * The sys_tick variable specifies the system clock tick interval in
+ * seconds, for stepping clocks, defined as those which return times
+ * less than MINSTEP greater than the previous reading. For systems that
+ * use a high-resolution counter such that each clock reading is always
+ * at least MINSTEP greater than the prior, sys_tick is the time to read
+ * the system clock.
+ *
+ * The sys_fuzz variable measures the minimum time to read the system
+ * clock, regardless of its precision. When reading the system clock
+ * using get_systime() after sys_tick and sys_fuzz have been determined,
+ * ntpd ensures each unprocessed clock reading is no less than sys_fuzz
+ * later than the prior unprocessed reading, and then fuzzes the bits
+ * below sys_fuzz in the timestamp returned, ensuring each of its
+ * resulting readings is strictly later than the previous.
+ *
+ * When slewing the system clock using adj_systime() (with the kernel
+ * loop discipline unavailable or disabled), adjtime() offsets are
+ * quantized to sys_tick, if sys_tick is greater than sys_fuzz, which
+ * is to say if the OS presents a stepping clock. Otherwise, offsets
+ * are quantized to the microsecond resolution of adjtime()'s timeval
+ * input. The remaining correction sys_residual is carried into the
+ * next adjtime() and meanwhile is also factored into get_systime()
+ * readings.
*/
-#if defined RELIANTUNIX_CLOCK || defined SCO5_CLOCK
-double sys_tick = 10e-3; /* 10 ms tickadj() */
-#else
-double sys_tick = 1e-6; /* 1 us tickadj() */
-#endif
+double sys_tick = 0; /* tick size or time to read (s) */
+double sys_fuzz = 0; /* min. time to read the clock (s) */
+long sys_fuzz_nsec = 0; /* min. time to read the clock (ns) */
+double measured_tick; /* non-overridable sys_tick (s) */
double sys_residual = 0; /* adjustment residue (s) */
+int trunc_os_clock; /* sys_tick > measured_tick */
+time_stepped_callback step_callback;
#ifndef SIM
+/* perlinger@ntp.org: As 'get_sysime()' does it's own check for clock
+ * backstepping, this could probably become a local variable in
+ * 'get_systime()' and the cruft associated with communicating via a
+ * static value could be removed after the v4.2.8 release.
+ */
+static int lamport_violated; /* clock was stepped back */
+#endif /* !SIM */
+
+#ifdef DEBUG
+static int systime_init_done;
+# define DONE_SYSTIME_INIT() systime_init_done = TRUE
+#else
+# define DONE_SYSTIME_INIT() do {} while (FALSE)
+#endif
+
+#ifdef HAVE_SIGNALED_IO
+int using_sigio;
+#endif
+
+#ifdef SYS_WINNT
+CRITICAL_SECTION get_systime_cs;
+#endif
+
+
+void
+set_sys_fuzz(
+ double fuzz_val
+ )
+{
+ sys_fuzz = fuzz_val;
+ INSIST(sys_fuzz >= 0);
+ INSIST(sys_fuzz <= 1.0);
+ sys_fuzz_nsec = (long)(sys_fuzz * 1e9 + 0.5);
+}
+
+
+void
+init_systime(void)
+{
+ INIT_GET_SYSTIME_CRITSEC();
+ INIT_WIN_PRECISE_TIME();
+ DONE_SYSTIME_INIT();
+}
+
+
+#ifndef SIM /* ntpsim.c has get_systime() and friends for sim */
+
+static inline void
+get_ostime(
+ struct timespec * tsp
+ )
+{
+ int rc;
+ long ticks;
+
+#if defined(HAVE_CLOCK_GETTIME)
+ rc = clock_gettime(CLOCK_REALTIME, tsp);
+#elif defined(HAVE_GETCLOCK)
+ rc = getclock(TIMEOFDAY, tsp);
+#else
+ struct timeval tv;
+
+ rc = GETTIMEOFDAY(&tv, NULL);
+ tsp->tv_sec = tv.tv_sec;
+ tsp->tv_nsec = tv.tv_usec * 1000;
+#endif
+ if (rc < 0) {
+ msyslog(LOG_ERR, "read system clock failed: %m (%d)",
+ errno);
+ exit(1);
+ }
+
+ if (trunc_os_clock) {
+ ticks = (long)((tsp->tv_nsec * 1e-9) / sys_tick);
+ tsp->tv_nsec = (long)(ticks * 1e9 * sys_tick);
+ }
+}
+
/*
* get_systime - return system time in NTP timestamp format.
@@ -56,59 +163,110 @@ get_systime(
l_fp *now /* system time */
)
{
- double dtemp;
-
-#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
+ static struct timespec ts_last; /* last sampled os time */
+ static struct timespec ts_prev; /* prior os time */
+ static l_fp lfp_prev; /* prior result */
+ static double dfuzz_prev; /* prior fuzz */
struct timespec ts; /* seconds and nanoseconds */
+ struct timespec ts_min; /* earliest permissible */
+ struct timespec ts_lam; /* lamport fictional increment */
+ struct timespec ts_prev_log; /* for msyslog only */
+ double dfuzz;
+ double ddelta;
+ l_fp result;
+ l_fp lfpfuzz;
+ l_fp lfpdelta;
+
+ get_ostime(&ts);
+ DEBUG_REQUIRE(systime_init_done);
+ ENTER_GET_SYSTIME_CRITSEC();
+
+ /* First check if here was a Lamport violation, that is, two
+ * successive calls to 'get_ostime()' resulted in negative
+ * time difference. Use a few milliseconds of permissible
+ * tolerance -- being too sharp can hurt here. (This is intented
+ * for the Win32 target, where the HPC interpolation might
+ * introduce small steps backward. It should not be an issue on
+ * systems where get_ostime() results in a true syscall.)
+ */
+ if (cmp_tspec(add_tspec_ns(ts, 50000000), ts_last) < 0)
+ lamport_violated = 1;
+ ts_last = ts;
/*
- * Convert Unix clock from seconds and nanoseconds to seconds.
- * The bottom is only two bits down, so no need for fuzz.
- * Some systems don't have that level of precision, however...
+ * After default_get_precision() has set a nonzero sys_fuzz,
+ * ensure every reading of the OS clock advances by at least
+ * sys_fuzz over the prior reading, thereby assuring each
+ * fuzzed result is strictly later than the prior. Limit the
+ * necessary fiction to 1 second.
*/
-# ifdef HAVE_CLOCK_GETTIME
- clock_gettime(CLOCK_REALTIME, &ts);
-# else
- getclock(TIMEOFDAY, &ts);
-# endif
- now->l_i = ts.tv_sec + JAN_1970;
- dtemp = ts.tv_nsec / 1e9;
+ if (!USING_SIGIO()) {
+ ts_min = add_tspec_ns(ts_prev, sys_fuzz_nsec);
+ if (cmp_tspec(ts, ts_min) < 0) {
+ ts_lam = sub_tspec(ts_min, ts);
+ if (ts_lam.tv_sec > 0 && !lamport_violated) {
+ msyslog(LOG_ERR,
+ "get_systime Lamport advance exceeds one second (%.9f)",
+ ts_lam.tv_sec +
+ 1e-9 * ts_lam.tv_nsec);
+ exit(1);
+ }
+ if (!lamport_violated)
+ ts = ts_min;
+ }
+ ts_prev_log = ts_prev;
+ ts_prev = ts;
+ } else {
+ /*
+ * Quiet "ts_prev_log.tv_sec may be used uninitialized"
+ * warning from x86 gcc 4.5.2.
+ */
+ ZERO(ts_prev_log);
+ }
-#else /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
- struct timeval tv; /* seconds and microseconds */
+ /* convert from timespec to l_fp fixed-point */
+ result = tspec_stamp_to_lfp(ts);
/*
- * Convert Unix clock from seconds and microseconds to seconds.
- * Add in unbiased random fuzz beneath the microsecond.
+ * Add in the fuzz.
*/
- GETTIMEOFDAY(&tv, NULL);
- now->l_i = tv.tv_sec + JAN_1970;
- dtemp = tv.tv_usec / 1e6;
-
-#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
+ dfuzz = ntp_random() * 2. / FRAC * sys_fuzz;
+ DTOLFP(dfuzz, &lfpfuzz);
+ L_ADD(&result, &lfpfuzz);
/*
- * ntp_random() produces 31 bits (always nonnegative).
- * This bit is done only after the precision has been
+ * Ensure result is strictly greater than prior result (ignoring
+ * sys_residual's effect for now) once sys_fuzz has been
* determined.
*/
- if (sys_precision != 0)
- dtemp += (ntp_random() / FRAC - .5) / (1 <<
- -sys_precision);
-
- /*
- * Renormalize to seconds past 1900 and fraction.
- */
- dtemp += sys_residual;
- if (dtemp >= 1) {
- dtemp -= 1;
- now->l_i++;
- } else if (dtemp < 0) {
- dtemp += 1;
- now->l_i--;
+ if (!USING_SIGIO()) {
+ if (!L_ISZERO(&lfp_prev) && !lamport_violated) {
+ if (!L_ISGTU(&result, &lfp_prev) &&
+ sys_fuzz > 0.) {
+ msyslog(LOG_ERR, "ts_prev %s ts_min %s",
+ tspectoa(ts_prev_log),
+ tspectoa(ts_min));
+ msyslog(LOG_ERR, "ts %s", tspectoa(ts));
+ msyslog(LOG_ERR, "sys_fuzz %ld nsec, prior fuzz %.9f",
+ sys_fuzz_nsec, dfuzz_prev);
+ msyslog(LOG_ERR, "this fuzz %.9f",
+ dfuzz);
+ lfpdelta = lfp_prev;
+ L_SUB(&lfpdelta, &result);
+ LFPTOD(&lfpdelta, ddelta);
+ msyslog(LOG_ERR,
+ "prev get_systime 0x%x.%08x is %.9f later than 0x%x.%08x",
+ lfp_prev.l_ui, lfp_prev.l_uf,
+ ddelta, result.l_ui, result.l_uf);
+ }
+ }
+ lfp_prev = result;
+ dfuzz_prev = dfuzz;
+ if (lamport_violated)
+ lamport_violated = FALSE;
}
- dtemp *= FRAC;
- now->l_uf = (u_int32)dtemp;
+ LEAVE_GET_SYSTIME_CRITSEC();
+ *now = result;
}
@@ -123,11 +281,24 @@ adj_systime(
{
struct timeval adjtv; /* new adjustment */
struct timeval oadjtv; /* residual adjustment */
+ double quant; /* quantize to multiples of */
double dtemp;
long ticks;
int isneg = 0;
/*
+ * The Windows port adj_systime() depends on being called each
+ * second even when there's no additional correction, to allow
+ * emulation of adjtime() behavior on top of an API that simply
+ * sets the current rate. This POSIX implementation needs to
+ * ignore invocations with zero correction, otherwise ongoing
+ * EVNT_NSET adjtime() can be aborted by a tiny adjtime()
+ * triggered by sys_residual.
+ */
+ if (0. == now)
+ return TRUE;
+
+ /*
* Most Unix adjtime() implementations adjust the system clock
* in microsecond quanta, but some adjust in 10-ms quanta. We
* carefully round the adjustment to the nearest quantum, then
@@ -140,8 +311,12 @@ adj_systime(
}
adjtv.tv_sec = (long)dtemp;
dtemp -= adjtv.tv_sec;
- ticks = (long)(dtemp / sys_tick + .5);
- adjtv.tv_usec = (long)(ticks * sys_tick * 1e6);
+ if (sys_tick > sys_fuzz)
+ quant = sys_tick;
+ else
+ quant = 1e-6;
+ ticks = (long)(dtemp / quant + .5);
+ adjtv.tv_usec = (long)(ticks * quant * 1e6);
dtemp -= adjtv.tv_usec / 1e6;
sys_residual = dtemp;
@@ -158,10 +333,10 @@ adj_systime(
if (adjtv.tv_sec != 0 || adjtv.tv_usec != 0) {
if (adjtime(&adjtv, &oadjtv) < 0) {
msyslog(LOG_ERR, "adj_systime: %m");
- return (0);
+ return FALSE;
}
}
- return (1);
+ return TRUE;
}
#endif
@@ -169,68 +344,90 @@ adj_systime(
/*
* step_systime - step the system clock.
*/
+
int
step_systime(
- double now
+ double step
)
{
- struct timeval timetv, adjtv, oldtimetv;
- int isneg = 0;
- double dtemp;
-#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
- struct timespec ts;
-#endif
+ time_t pivot; /* for ntp era unfolding */
+ struct timeval timetv, tvlast, tvdiff;
+ struct timespec timets;
+ struct calendar jd;
+ l_fp fp_ofs, fp_sys; /* offset and target system time in FP */
- dtemp = sys_residual + now;
- if (dtemp < 0) {
- isneg = 1;
- dtemp = - dtemp;
- adjtv.tv_sec = (int32)dtemp;
- adjtv.tv_usec = (u_int32)((dtemp -
- (double)adjtv.tv_sec) * 1e6 + .5);
+ /*
+ * Get pivot time for NTP era unfolding. Since we don't step
+ * very often, we can afford to do the whole calculation from
+ * scratch. And we're not in the time-critical path yet.
+ */
+#if SIZEOF_TIME_T > 4
+ /*
+ * This code makes sure the resulting time stamp for the new
+ * system time is in the 2^32 seconds starting at 1970-01-01,
+ * 00:00:00 UTC.
+ */
+ pivot = 0x80000000;
+#if USE_COMPILETIME_PIVOT
+ /*
+ * Add the compile time minus 10 years to get a possible target
+ * area of (compile time - 10 years) to (compile time + 126
+ * years). This should be sufficient for a given binary of
+ * NTPD.
+ */
+ if (ntpcal_get_build_date(&jd)) {
+ jd.year -= 10;
+ pivot += ntpcal_date_to_time(&jd);
} else {
- adjtv.tv_sec = (int32)dtemp;
- adjtv.tv_usec = (u_int32)((dtemp -
- (double)adjtv.tv_sec) * 1e6 + .5);
+ msyslog(LOG_ERR,
+ "step-systime: assume 1970-01-01 as build date");
}
-#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
-# ifdef HAVE_CLOCK_GETTIME
- (void) clock_gettime(CLOCK_REALTIME, &ts);
-# else
- (void) getclock(TIMEOFDAY, &ts);
-# endif
- timetv.tv_sec = ts.tv_sec;
- timetv.tv_usec = ts.tv_nsec / 1000;
-#else /* not HAVE_GETCLOCK */
- (void) GETTIMEOFDAY(&timetv, (struct timezone *)0);
-#endif /* not HAVE_GETCLOCK */
-
- oldtimetv = timetv;
-
-#ifdef DEBUG
- if (debug)
- printf("step_systime: step %.6f residual %.6f\n", now, sys_residual);
+#else
+ UNUSED_LOCAL(jd);
+#endif /* USE_COMPILETIME_PIVOT */
+#else
+ UNUSED_LOCAL(jd);
+ /* This makes sure the resulting time stamp is on or after
+ * 1969-12-31/23:59:59 UTC and gives us additional two years,
+ * from the change of NTP era in 2036 to the UNIX rollover in
+ * 2038. (Minus one second, but that won't hurt.) We *really*
+ * need a longer 'time_t' after that! Or a different baseline,
+ * but that would cause other serious trouble, too.
+ */
+ pivot = 0x7FFFFFFF;
#endif
- if (isneg) {
- timetv.tv_sec -= adjtv.tv_sec;
- timetv.tv_usec -= adjtv.tv_usec;
- if (timetv.tv_usec < 0) {
- timetv.tv_sec--;
- timetv.tv_usec += 1000000;
- }
- } else {
- timetv.tv_sec += adjtv.tv_sec;
- timetv.tv_usec += adjtv.tv_usec;
- if (timetv.tv_usec >= 1000000) {
- timetv.tv_sec++;
- timetv.tv_usec -= 1000000;
- }
- }
+
+ /* get the complete jump distance as l_fp */
+ DTOLFP(sys_residual, &fp_sys);
+ DTOLFP(step, &fp_ofs);
+ L_ADD(&fp_ofs, &fp_sys);
+
+ /* ---> time-critical path starts ---> */
+
+ /* get the current time as l_fp (without fuzz) and as struct timeval */
+ get_ostime(&timets);
+ fp_sys = tspec_stamp_to_lfp(timets);
+ tvlast.tv_sec = timets.tv_sec;
+ tvlast.tv_usec = (timets.tv_nsec + 500) / 1000;
+
+ /* get the target time as l_fp */
+ L_ADD(&fp_sys, &fp_ofs);
+
+ /* unfold the new system time */
+ timetv = lfp_stamp_to_tval(fp_sys, &pivot);
+
+ /* now set new system time */
if (ntp_set_tod(&timetv, NULL) != 0) {
msyslog(LOG_ERR, "step-systime: %m");
- return (0);
+ return FALSE;
}
+
+ /* <--- time-critical path ended with 'ntp_set_tod()' <--- */
+
sys_residual = 0;
+ lamport_violated = (step < 0);
+ if (step_callback)
+ (*step_callback)();
#ifdef NEED_HPUX_ADJTIME
/*
@@ -260,8 +457,8 @@ step_systime(
*
* This might become even Uglier...
*/
- if (oldtimetv.tv_sec != timetv.tv_sec)
- {
+ tvdiff = abs_tval(sub_tval(timetv, tvlast));
+ if (tvdiff.tv_sec > 0) {
#ifdef HAVE_UTMP_H
struct utmp ut;
#endif
@@ -270,24 +467,29 @@ step_systime(
#endif
#ifdef HAVE_UTMP_H
- memset((char *)&ut, 0, sizeof(ut));
+ ZERO(ut);
#endif
#ifdef HAVE_UTMPX_H
- memset((char *)&utx, 0, sizeof(utx));
+ ZERO(utx);
#endif
/* UTMP */
#ifdef UPDATE_UTMP
# ifdef HAVE_PUTUTLINE
+# ifndef _PATH_UTMP
+# define _PATH_UTMP UTMP_FILE
+# endif
+ utmpname(_PATH_UTMP);
ut.ut_type = OLD_TIME;
- (void)strcpy(ut.ut_line, OTIME_MSG);
- ut.ut_time = oldtimetv.tv_sec;
- pututline(&ut);
+ strlcpy(ut.ut_line, OTIME_MSG, sizeof(ut.ut_line));
+ ut.ut_time = tvlast.tv_sec;
setutent();
+ pututline(&ut);
ut.ut_type = NEW_TIME;
- (void)strcpy(ut.ut_line, NTIME_MSG);
+ strlcpy(ut.ut_line, NTIME_MSG, sizeof(ut.ut_line));
ut.ut_time = timetv.tv_sec;
+ setutent();
pututline(&ut);
endutent();
# else /* not HAVE_PUTUTLINE */
@@ -299,13 +501,14 @@ step_systime(
#ifdef UPDATE_UTMPX
# ifdef HAVE_PUTUTXLINE
utx.ut_type = OLD_TIME;
- (void)strcpy(utx.ut_line, OTIME_MSG);
- utx.ut_tv = oldtimetv;
- pututxline(&utx);
+ strlcpy(utx.ut_line, OTIME_MSG, sizeof(utx.ut_line));
+ utx.ut_tv = tvlast;
setutxent();
+ pututxline(&utx);
utx.ut_type = NEW_TIME;
- (void)strcpy(utx.ut_line, NTIME_MSG);
+ strlcpy(utx.ut_line, NTIME_MSG, sizeof(utx.ut_line));
utx.ut_tv = timetv;
+ setutxent();
pututxline(&utx);
endutxent();
# else /* not HAVE_PUTUTXLINE */
@@ -316,14 +519,19 @@ step_systime(
#ifdef UPDATE_WTMP
# ifdef HAVE_PUTUTLINE
- utmpname(WTMP_FILE);
+# ifndef _PATH_WTMP
+# define _PATH_WTMP WTMP_FILE
+# endif
+ utmpname(_PATH_WTMP);
ut.ut_type = OLD_TIME;
- (void)strcpy(ut.ut_line, OTIME_MSG);
- ut.ut_time = oldtimetv.tv_sec;
+ strlcpy(ut.ut_line, OTIME_MSG, sizeof(ut.ut_line));
+ ut.ut_time = tvlast.tv_sec;
+ setutent();
pututline(&ut);
ut.ut_type = NEW_TIME;
- (void)strcpy(ut.ut_line, NTIME_MSG);
+ strlcpy(ut.ut_line, NTIME_MSG, sizeof(ut.ut_line));
ut.ut_time = timetv.tv_sec;
+ setutent();
pututline(&ut);
endutent();
# else /* not HAVE_PUTUTLINE */
@@ -335,8 +543,8 @@ step_systime(
#ifdef UPDATE_WTMPX
# ifdef HAVE_PUTUTXLINE
utx.ut_type = OLD_TIME;
- utx.ut_tv = oldtimetv;
- (void)strcpy(utx.ut_line, OTIME_MSG);
+ utx.ut_tv = tvlast;
+ strlcpy(utx.ut_line, OTIME_MSG, sizeof(utx.ut_line));
# ifdef HAVE_UPDWTMPX
updwtmpx(WTMPX_FILE, &utx);
# else /* not HAVE_UPDWTMPX */
@@ -346,7 +554,7 @@ step_systime(
# ifdef HAVE_PUTUTXLINE
utx.ut_type = NEW_TIME;
utx.ut_tv = timetv;
- (void)strcpy(utx.ut_line, NTIME_MSG);
+ strlcpy(utx.ut_line, NTIME_MSG, sizeof(utx.ut_line));
# ifdef HAVE_UPDWTMPX
updwtmpx(WTMPX_FILE, &utx);
# else /* not HAVE_UPDWTMPX */
@@ -356,187 +564,7 @@ step_systime(
#endif /* UPDATE_WTMPX */
}
- return (1);
-}
-
-#else /* SIM */
-/*
- * Clock routines for the simulator - Harish Nair, with help
- */
-/*
- * get_systime - return the system time in NTP timestamp format
- */
-void
-get_systime(
- l_fp *now /* current system time in l_fp */ )
-{
- /*
- * To fool the code that determines the local clock precision,
- * we advance the clock a minimum of 200 nanoseconds on every
- * clock read. This is appropriate for a typical modern machine
- * with nanosecond clocks. Note we make no attempt here to
- * simulate reading error, since the error is so small. This may
- * change when the need comes to implement picosecond clocks.
- */
- if (ntp_node.ntp_time == ntp_node.last_time)
- ntp_node.ntp_time += 200e-9;
- ntp_node.last_time = ntp_node.ntp_time;
- DTOLFP(ntp_node.ntp_time, now);
-}
-
-
-/*
- * adj_systime - advance or retard the system clock exactly like the
- * real thng.
- */
-int /* always succeeds */
-adj_systime(
- double now /* time adjustment (s) */
- )
-{
- struct timeval adjtv; /* new adjustment */
- double dtemp;
- long ticks;
- int isneg = 0;
-
- /*
- * Most Unix adjtime() implementations adjust the system clock
- * in microsecond quanta, but some adjust in 10-ms quanta. We
- * carefully round the adjustment to the nearest quantum, then
- * adjust in quanta and keep the residue for later.
- */
- dtemp = now + sys_residual;
- if (dtemp < 0) {
- isneg = 1;
- dtemp = -dtemp;
- }
- adjtv.tv_sec = (long)dtemp;
- dtemp -= adjtv.tv_sec;
- ticks = (long)(dtemp / sys_tick + .5);
- adjtv.tv_usec = (long)(ticks * sys_tick * 1e6);
- dtemp -= adjtv.tv_usec / 1e6;
- sys_residual = dtemp;
-
- /*
- * Convert to signed seconds and microseconds for the Unix
- * adjtime() system call. Note we purposely lose the adjtime()
- * leftover.
- */
- if (isneg) {
- adjtv.tv_sec = -adjtv.tv_sec;
- adjtv.tv_usec = -adjtv.tv_usec;
- sys_residual = -sys_residual;
- }
- ntp_node.adj = now;
- return (1);
-}
-
-
-/*
- * step_systime - step the system clock. We are religious here.
- */
-int /* always succeeds */
-step_systime(
- double now /* step adjustment (s) */
- )
-{
-#ifdef DEBUG
- if (debug)
- printf("step_systime: time %.6f adj %.6f\n",
- ntp_node.ntp_time, now);
-#endif
- ntp_node.ntp_time += now;
- return (1);
-}
-
-/*
- * node_clock - update the clocks
- */
-int /* always succeeds */
-node_clock(
- Node *n, /* global node pointer */
- double t /* node time */
- )
-{
- double dtemp;
-
- /*
- * Advance client clock (ntp_time). Advance server clock
- * (clk_time) adjusted for systematic and random frequency
- * errors. The random error is a random walk computed as the
- * integral of samples from a Gaussian distribution.
- */
- dtemp = t - n->ntp_time;
- n->time = t;
- n->ntp_time += dtemp;
- n->ferr += gauss(0, dtemp * n->fnse);
- n->clk_time += dtemp * (1 + n->ferr);
-
- /*
- * Perform the adjtime() function. If the adjustment completed
- * in the previous interval, amortize the entire amount; if not,
- * carry the leftover to the next interval.
- */
- dtemp *= n->slew;
- if (dtemp < fabs(n->adj)) {
- if (n->adj < 0) {
- n->adj += dtemp;
- n->ntp_time -= dtemp;
- } else {
- n->adj -= dtemp;
- n->ntp_time += dtemp;
- }
- } else {
- n->ntp_time += n->adj;
- n->adj = 0;
- }
- return (0);
-}
-
-
-/*
- * gauss() - returns samples from a gaussion distribution
- */
-double /* Gaussian sample */
-gauss(
- double m, /* sample mean */
- double s /* sample standard deviation (sigma) */
- )
-{
- double q1, q2;
-
- /*
- * Roll a sample from a Gaussian distribution with mean m and
- * standard deviation s. For m = 0, s = 1, mean(y) = 0,
- * std(y) = 1.
- */
- if (s == 0)
- return (m);
- while ((q1 = drand48()) == 0);
- q2 = drand48();
- return (m + s * sqrt(-2. * log(q1)) * cos(2. * PI * q2));
+ return TRUE;
}
-
-/*
- * poisson() - returns samples from a network delay distribution
- */
-double /* delay sample (s) */
-poisson(
- double m, /* fixed propagation delay (s) */
- double s /* exponential parameter (mu) */
- )
-{
- double q1;
-
- /*
- * Roll a sample from a composite distribution with propagation
- * delay m and exponential distribution time with parameter s.
- * For m = 0, s = 1, mean(y) = std(y) = 1.
- */
- if (s == 0)
- return (m);
- while ((q1 = drand48()) == 0);
- return (m - s * log(q1 * s));
-}
-#endif /* SIM */
+#endif /* !SIM */
diff --git a/contrib/ntp/libntp/timetoa.c b/contrib/ntp/libntp/timetoa.c
new file mode 100644
index 0000000..f294e16
--- /dev/null
+++ b/contrib/ntp/libntp/timetoa.c
@@ -0,0 +1,106 @@
+/*
+ * timetoa.c -- time_t related string formatting
+ *
+ * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
+ * The contents of 'html/copyright.html' apply.
+ *
+ * Printing a 'time_t' has a lot of portability pitfalls, due to it's
+ * opaque base type. The only requirement imposed by the standard is
+ * that it must be a numeric type. For all practical purposes it's a
+ * signed int, and 32 bits are common.
+ *
+ * Since the UN*X time epoch will cause a signed integer overflow for
+ * 32-bit signed int in the year 2038, implementations slowly move to
+ * 64bit base types for time_t, even in 32-bit environments.
+ *
+ * As the printf() family has no standardised type specifier for time_t,
+ * guessing the right output format specifier is a bit troublesome and
+ * best done with the help of the preprocessor and "config.h".
+ */
+
+#include "config.h"
+
+#include <math.h>
+#include <stdio.h>
+
+#include "timetoa.h"
+#include "ntp_assert.h"
+#include "lib_strbuf.h"
+
+/*
+ * Formatting to string needs at max 40 bytes (even with 64 bit time_t),
+ * so we check LIB_BUFLENGTH is big enough for our purpose.
+ */
+#if LIB_BUFLENGTH < 40
+# include "GRONK: LIB_BUFLENGTH is not sufficient"
+#endif
+
+/*
+ * general fractional timestamp formatting
+ *
+ * Many pieces of ntpd require a machine with two's complement
+ * representation of signed integers, so we don't go through the whole
+ * rigamarole of creating fully portable code here. But we have to stay
+ * away from signed integer overflow, as this might cause trouble even
+ * with two's complement representation.
+ */
+const char *
+format_time_fraction(
+ time_t secs,
+ long frac,
+ int prec
+ )
+{
+ char * cp;
+ u_int prec_u;
+ u_time secs_u;
+ u_int u;
+ long fraclimit;
+ int notneg; /* flag for non-negative value */
+ ldiv_t qr;
+
+ DEBUG_REQUIRE(prec != 0);
+
+ LIB_GETBUF(cp);
+ secs_u = (u_time)secs;
+
+ /* check if we need signed or unsigned mode */
+ notneg = (prec < 0);
+ prec_u = abs(prec);
+ /* fraclimit = (long)pow(10, prec_u); */
+ for (fraclimit = 10, u = 1; u < prec_u; u++) {
+ DEBUG_INSIST(fraclimit < fraclimit * 10);
+ fraclimit *= 10;
+ }
+
+ /*
+ * Since conversion to string uses lots of divisions anyway,
+ * there's no big extra penalty for normalisation. We do it for
+ * consistency.
+ */
+ if (frac < 0 || frac >= fraclimit) {
+ qr = ldiv(frac, fraclimit);
+ if (qr.rem < 0) {
+ qr.quot--;
+ qr.rem += fraclimit;
+ }
+ secs_u += (time_t)qr.quot;
+ frac = qr.rem;
+ }
+
+ /* Get the absolute value of the split representation time. */
+ notneg = notneg || ((time_t)secs_u >= 0);
+ if (!notneg) {
+ secs_u = ~secs_u;
+ if (0 == frac)
+ secs_u++;
+ else
+ frac = fraclimit - frac;
+ }
+
+ /* finally format the data and return the result */
+ snprintf(cp, LIB_BUFLENGTH, "%s%" UTIME_FORMAT ".%0*ld",
+ notneg? "" : "-", secs_u, prec_u, frac);
+
+ return cp;
+}
diff --git a/contrib/ntp/libntp/timevalops.c b/contrib/ntp/libntp/timevalops.c
new file mode 100644
index 0000000..55f7bb5
--- /dev/null
+++ b/contrib/ntp/libntp/timevalops.c
@@ -0,0 +1,297 @@
+/*
+ * timevalops.c -- calculations on 'struct timeval' values
+ *
+ * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
+ * The contents of 'html/copyright.html' apply.
+ */
+
+#include <config.h>
+
+#include "timevalops.h"
+
+#ifdef USE_TSF_USEC_TABLES
+/*
+ * Tables to calculate time stamp fractions from usecs. The entries
+ * in these tables are offset into using each of the two low order
+ * bytes plus the next 4 bits in a usec value (from a struct timeval).
+ * These are summed to produce the time stamp fraction.
+ *
+ * Note that these tables are rounded (not truncated) to the nearest
+ * low order bit in the fraction. The timestamp computed should be
+ * +- 1.5 low order bits.
+ */
+
+const u_int32 ustotslo[256] = {
+ 0x00000000, 0x000010c7, 0x0000218e, 0x00003255,
+ 0x0000431c, 0x000053e3, 0x000064aa, 0x00007571,
+ 0x00008638, 0x000096ff, 0x0000a7c6, 0x0000b88d,
+ 0x0000c954, 0x0000da1b, 0x0000eae2, 0x0000fba9,
+ 0x00010c6f, 0x00011d36, 0x00012dfd, 0x00013ec4,
+ 0x00014f8b, 0x00016052, 0x00017119, 0x000181e0,
+ 0x000192a7, 0x0001a36e, 0x0001b435, 0x0001c4fc,
+ 0x0001d5c3, 0x0001e68a, 0x0001f751, 0x00020818,
+ 0x000218df, 0x000229a6, 0x00023a6d, 0x00024b34,
+ 0x00025bfb, 0x00026cc2, 0x00027d89, 0x00028e50,
+ 0x00029f17, 0x0002afde, 0x0002c0a5, 0x0002d16c,
+ 0x0002e233, 0x0002f2fa, 0x000303c0, 0x00031487,
+ 0x0003254e, 0x00033615, 0x000346dc, 0x000357a3,
+ 0x0003686a, 0x00037931, 0x000389f8, 0x00039abf,
+ 0x0003ab86, 0x0003bc4d, 0x0003cd14, 0x0003dddb,
+ 0x0003eea2, 0x0003ff69, 0x00041030, 0x000420f7,
+ 0x000431be, 0x00044285, 0x0004534c, 0x00046413,
+ 0x000474da, 0x000485a1, 0x00049668, 0x0004a72f,
+ 0x0004b7f6, 0x0004c8bd, 0x0004d984, 0x0004ea4b,
+ 0x0004fb12, 0x00050bd8, 0x00051c9f, 0x00052d66,
+ 0x00053e2d, 0x00054ef4, 0x00055fbb, 0x00057082,
+ 0x00058149, 0x00059210, 0x0005a2d7, 0x0005b39e,
+ 0x0005c465, 0x0005d52c, 0x0005e5f3, 0x0005f6ba,
+ 0x00060781, 0x00061848, 0x0006290f, 0x000639d6,
+ 0x00064a9d, 0x00065b64, 0x00066c2b, 0x00067cf2,
+ 0x00068db9, 0x00069e80, 0x0006af47, 0x0006c00e,
+ 0x0006d0d5, 0x0006e19c, 0x0006f263, 0x0007032a,
+ 0x000713f0, 0x000724b7, 0x0007357e, 0x00074645,
+ 0x0007570c, 0x000767d3, 0x0007789a, 0x00078961,
+ 0x00079a28, 0x0007aaef, 0x0007bbb6, 0x0007cc7d,
+ 0x0007dd44, 0x0007ee0b, 0x0007fed2, 0x00080f99,
+ 0x00082060, 0x00083127, 0x000841ee, 0x000852b5,
+ 0x0008637c, 0x00087443, 0x0008850a, 0x000895d1,
+ 0x0008a698, 0x0008b75f, 0x0008c826, 0x0008d8ed,
+ 0x0008e9b4, 0x0008fa7b, 0x00090b41, 0x00091c08,
+ 0x00092ccf, 0x00093d96, 0x00094e5d, 0x00095f24,
+ 0x00096feb, 0x000980b2, 0x00099179, 0x0009a240,
+ 0x0009b307, 0x0009c3ce, 0x0009d495, 0x0009e55c,
+ 0x0009f623, 0x000a06ea, 0x000a17b1, 0x000a2878,
+ 0x000a393f, 0x000a4a06, 0x000a5acd, 0x000a6b94,
+ 0x000a7c5b, 0x000a8d22, 0x000a9de9, 0x000aaeb0,
+ 0x000abf77, 0x000ad03e, 0x000ae105, 0x000af1cc,
+ 0x000b0293, 0x000b1359, 0x000b2420, 0x000b34e7,
+ 0x000b45ae, 0x000b5675, 0x000b673c, 0x000b7803,
+ 0x000b88ca, 0x000b9991, 0x000baa58, 0x000bbb1f,
+ 0x000bcbe6, 0x000bdcad, 0x000bed74, 0x000bfe3b,
+ 0x000c0f02, 0x000c1fc9, 0x000c3090, 0x000c4157,
+ 0x000c521e, 0x000c62e5, 0x000c73ac, 0x000c8473,
+ 0x000c953a, 0x000ca601, 0x000cb6c8, 0x000cc78f,
+ 0x000cd856, 0x000ce91d, 0x000cf9e4, 0x000d0aaa,
+ 0x000d1b71, 0x000d2c38, 0x000d3cff, 0x000d4dc6,
+ 0x000d5e8d, 0x000d6f54, 0x000d801b, 0x000d90e2,
+ 0x000da1a9, 0x000db270, 0x000dc337, 0x000dd3fe,
+ 0x000de4c5, 0x000df58c, 0x000e0653, 0x000e171a,
+ 0x000e27e1, 0x000e38a8, 0x000e496f, 0x000e5a36,
+ 0x000e6afd, 0x000e7bc4, 0x000e8c8b, 0x000e9d52,
+ 0x000eae19, 0x000ebee0, 0x000ecfa7, 0x000ee06e,
+ 0x000ef135, 0x000f01fc, 0x000f12c2, 0x000f2389,
+ 0x000f3450, 0x000f4517, 0x000f55de, 0x000f66a5,
+ 0x000f776c, 0x000f8833, 0x000f98fa, 0x000fa9c1,
+ 0x000fba88, 0x000fcb4f, 0x000fdc16, 0x000fecdd,
+ 0x000ffda4, 0x00100e6b, 0x00101f32, 0x00102ff9,
+ 0x001040c0, 0x00105187, 0x0010624e, 0x00107315,
+ 0x001083dc, 0x001094a3, 0x0010a56a, 0x0010b631
+};
+
+const u_int32 ustotsmid[256] = {
+ 0x00000000, 0x0010c6f8, 0x00218def, 0x003254e7,
+ 0x00431bdf, 0x0053e2d6, 0x0064a9ce, 0x007570c5,
+ 0x008637bd, 0x0096feb5, 0x00a7c5ac, 0x00b88ca4,
+ 0x00c9539c, 0x00da1a93, 0x00eae18b, 0x00fba882,
+ 0x010c6f7a, 0x011d3672, 0x012dfd69, 0x013ec461,
+ 0x014f8b59, 0x01605250, 0x01711948, 0x0181e03f,
+ 0x0192a737, 0x01a36e2f, 0x01b43526, 0x01c4fc1e,
+ 0x01d5c316, 0x01e68a0d, 0x01f75105, 0x020817fc,
+ 0x0218def4, 0x0229a5ec, 0x023a6ce3, 0x024b33db,
+ 0x025bfad3, 0x026cc1ca, 0x027d88c2, 0x028e4fb9,
+ 0x029f16b1, 0x02afdda9, 0x02c0a4a0, 0x02d16b98,
+ 0x02e23290, 0x02f2f987, 0x0303c07f, 0x03148777,
+ 0x03254e6e, 0x03361566, 0x0346dc5d, 0x0357a355,
+ 0x03686a4d, 0x03793144, 0x0389f83c, 0x039abf34,
+ 0x03ab862b, 0x03bc4d23, 0x03cd141a, 0x03dddb12,
+ 0x03eea20a, 0x03ff6901, 0x04102ff9, 0x0420f6f1,
+ 0x0431bde8, 0x044284e0, 0x04534bd7, 0x046412cf,
+ 0x0474d9c7, 0x0485a0be, 0x049667b6, 0x04a72eae,
+ 0x04b7f5a5, 0x04c8bc9d, 0x04d98394, 0x04ea4a8c,
+ 0x04fb1184, 0x050bd87b, 0x051c9f73, 0x052d666b,
+ 0x053e2d62, 0x054ef45a, 0x055fbb51, 0x05708249,
+ 0x05814941, 0x05921038, 0x05a2d730, 0x05b39e28,
+ 0x05c4651f, 0x05d52c17, 0x05e5f30e, 0x05f6ba06,
+ 0x060780fe, 0x061847f5, 0x06290eed, 0x0639d5e5,
+ 0x064a9cdc, 0x065b63d4, 0x066c2acc, 0x067cf1c3,
+ 0x068db8bb, 0x069e7fb2, 0x06af46aa, 0x06c00da2,
+ 0x06d0d499, 0x06e19b91, 0x06f26289, 0x07032980,
+ 0x0713f078, 0x0724b76f, 0x07357e67, 0x0746455f,
+ 0x07570c56, 0x0767d34e, 0x07789a46, 0x0789613d,
+ 0x079a2835, 0x07aaef2c, 0x07bbb624, 0x07cc7d1c,
+ 0x07dd4413, 0x07ee0b0b, 0x07fed203, 0x080f98fa,
+ 0x08205ff2, 0x083126e9, 0x0841ede1, 0x0852b4d9,
+ 0x08637bd0, 0x087442c8, 0x088509c0, 0x0895d0b7,
+ 0x08a697af, 0x08b75ea6, 0x08c8259e, 0x08d8ec96,
+ 0x08e9b38d, 0x08fa7a85, 0x090b417d, 0x091c0874,
+ 0x092ccf6c, 0x093d9664, 0x094e5d5b, 0x095f2453,
+ 0x096feb4a, 0x0980b242, 0x0991793a, 0x09a24031,
+ 0x09b30729, 0x09c3ce21, 0x09d49518, 0x09e55c10,
+ 0x09f62307, 0x0a06e9ff, 0x0a17b0f7, 0x0a2877ee,
+ 0x0a393ee6, 0x0a4a05de, 0x0a5accd5, 0x0a6b93cd,
+ 0x0a7c5ac4, 0x0a8d21bc, 0x0a9de8b4, 0x0aaeafab,
+ 0x0abf76a3, 0x0ad03d9b, 0x0ae10492, 0x0af1cb8a,
+ 0x0b029281, 0x0b135979, 0x0b242071, 0x0b34e768,
+ 0x0b45ae60, 0x0b567558, 0x0b673c4f, 0x0b780347,
+ 0x0b88ca3e, 0x0b999136, 0x0baa582e, 0x0bbb1f25,
+ 0x0bcbe61d, 0x0bdcad15, 0x0bed740c, 0x0bfe3b04,
+ 0x0c0f01fc, 0x0c1fc8f3, 0x0c308feb, 0x0c4156e2,
+ 0x0c521dda, 0x0c62e4d2, 0x0c73abc9, 0x0c8472c1,
+ 0x0c9539b9, 0x0ca600b0, 0x0cb6c7a8, 0x0cc78e9f,
+ 0x0cd85597, 0x0ce91c8f, 0x0cf9e386, 0x0d0aaa7e,
+ 0x0d1b7176, 0x0d2c386d, 0x0d3cff65, 0x0d4dc65c,
+ 0x0d5e8d54, 0x0d6f544c, 0x0d801b43, 0x0d90e23b,
+ 0x0da1a933, 0x0db2702a, 0x0dc33722, 0x0dd3fe19,
+ 0x0de4c511, 0x0df58c09, 0x0e065300, 0x0e1719f8,
+ 0x0e27e0f0, 0x0e38a7e7, 0x0e496edf, 0x0e5a35d6,
+ 0x0e6afcce, 0x0e7bc3c6, 0x0e8c8abd, 0x0e9d51b5,
+ 0x0eae18ad, 0x0ebedfa4, 0x0ecfa69c, 0x0ee06d94,
+ 0x0ef1348b, 0x0f01fb83, 0x0f12c27a, 0x0f238972,
+ 0x0f34506a, 0x0f451761, 0x0f55de59, 0x0f66a551,
+ 0x0f776c48, 0x0f883340, 0x0f98fa37, 0x0fa9c12f,
+ 0x0fba8827, 0x0fcb4f1e, 0x0fdc1616, 0x0fecdd0e,
+ 0x0ffda405, 0x100e6afd, 0x101f31f4, 0x102ff8ec,
+ 0x1040bfe4, 0x105186db, 0x10624dd3, 0x107314cb,
+ 0x1083dbc2, 0x1094a2ba, 0x10a569b1, 0x10b630a9
+};
+
+const u_int32 ustotshi[16] = {
+ 0x00000000, 0x10c6f7a1, 0x218def41, 0x3254e6e2,
+ 0x431bde83, 0x53e2d624, 0x64a9cdc4, 0x7570c565,
+ 0x8637bd06, 0x96feb4a6, 0xa7c5ac47, 0xb88ca3e8,
+ 0xc9539b89, 0xda1a9329, 0xeae18aca, 0xfba8826b
+};
+
+/*
+ * Tables to convert from a time stamp fraction to usecs. Note that
+ * the units of these tables are actually (usec<<3). We carry three
+ * guard bits so that the result can be properly truncated (or rounded)
+ * to be correct to the least significant bit.
+ *
+ * These tables are rounded.
+ */
+
+const u_int32 tstoushi[256] = {
+ 0x000000, 0x007a12, 0x00f424, 0x016e36,
+ 0x01e848, 0x02625a, 0x02dc6c, 0x03567e,
+ 0x03d090, 0x044aa2, 0x04c4b4, 0x053ec6,
+ 0x05b8d8, 0x0632ea, 0x06acfc, 0x07270e,
+ 0x07a120, 0x081b32, 0x089544, 0x090f56,
+ 0x098968, 0x0a037a, 0x0a7d8c, 0x0af79e,
+ 0x0b71b0, 0x0bebc2, 0x0c65d4, 0x0cdfe6,
+ 0x0d59f8, 0x0dd40a, 0x0e4e1c, 0x0ec82e,
+ 0x0f4240, 0x0fbc52, 0x103664, 0x10b076,
+ 0x112a88, 0x11a49a, 0x121eac, 0x1298be,
+ 0x1312d0, 0x138ce2, 0x1406f4, 0x148106,
+ 0x14fb18, 0x15752a, 0x15ef3c, 0x16694e,
+ 0x16e360, 0x175d72, 0x17d784, 0x185196,
+ 0x18cba8, 0x1945ba, 0x19bfcc, 0x1a39de,
+ 0x1ab3f0, 0x1b2e02, 0x1ba814, 0x1c2226,
+ 0x1c9c38, 0x1d164a, 0x1d905c, 0x1e0a6e,
+ 0x1e8480, 0x1efe92, 0x1f78a4, 0x1ff2b6,
+ 0x206cc8, 0x20e6da, 0x2160ec, 0x21dafe,
+ 0x225510, 0x22cf22, 0x234934, 0x23c346,
+ 0x243d58, 0x24b76a, 0x25317c, 0x25ab8e,
+ 0x2625a0, 0x269fb2, 0x2719c4, 0x2793d6,
+ 0x280de8, 0x2887fa, 0x29020c, 0x297c1e,
+ 0x29f630, 0x2a7042, 0x2aea54, 0x2b6466,
+ 0x2bde78, 0x2c588a, 0x2cd29c, 0x2d4cae,
+ 0x2dc6c0, 0x2e40d2, 0x2ebae4, 0x2f34f6,
+ 0x2faf08, 0x30291a, 0x30a32c, 0x311d3e,
+ 0x319750, 0x321162, 0x328b74, 0x330586,
+ 0x337f98, 0x33f9aa, 0x3473bc, 0x34edce,
+ 0x3567e0, 0x35e1f2, 0x365c04, 0x36d616,
+ 0x375028, 0x37ca3a, 0x38444c, 0x38be5e,
+ 0x393870, 0x39b282, 0x3a2c94, 0x3aa6a6,
+ 0x3b20b8, 0x3b9aca, 0x3c14dc, 0x3c8eee,
+ 0x3d0900, 0x3d8312, 0x3dfd24, 0x3e7736,
+ 0x3ef148, 0x3f6b5a, 0x3fe56c, 0x405f7e,
+ 0x40d990, 0x4153a2, 0x41cdb4, 0x4247c6,
+ 0x42c1d8, 0x433bea, 0x43b5fc, 0x44300e,
+ 0x44aa20, 0x452432, 0x459e44, 0x461856,
+ 0x469268, 0x470c7a, 0x47868c, 0x48009e,
+ 0x487ab0, 0x48f4c2, 0x496ed4, 0x49e8e6,
+ 0x4a62f8, 0x4add0a, 0x4b571c, 0x4bd12e,
+ 0x4c4b40, 0x4cc552, 0x4d3f64, 0x4db976,
+ 0x4e3388, 0x4ead9a, 0x4f27ac, 0x4fa1be,
+ 0x501bd0, 0x5095e2, 0x510ff4, 0x518a06,
+ 0x520418, 0x527e2a, 0x52f83c, 0x53724e,
+ 0x53ec60, 0x546672, 0x54e084, 0x555a96,
+ 0x55d4a8, 0x564eba, 0x56c8cc, 0x5742de,
+ 0x57bcf0, 0x583702, 0x58b114, 0x592b26,
+ 0x59a538, 0x5a1f4a, 0x5a995c, 0x5b136e,
+ 0x5b8d80, 0x5c0792, 0x5c81a4, 0x5cfbb6,
+ 0x5d75c8, 0x5defda, 0x5e69ec, 0x5ee3fe,
+ 0x5f5e10, 0x5fd822, 0x605234, 0x60cc46,
+ 0x614658, 0x61c06a, 0x623a7c, 0x62b48e,
+ 0x632ea0, 0x63a8b2, 0x6422c4, 0x649cd6,
+ 0x6516e8, 0x6590fa, 0x660b0c, 0x66851e,
+ 0x66ff30, 0x677942, 0x67f354, 0x686d66,
+ 0x68e778, 0x69618a, 0x69db9c, 0x6a55ae,
+ 0x6acfc0, 0x6b49d2, 0x6bc3e4, 0x6c3df6,
+ 0x6cb808, 0x6d321a, 0x6dac2c, 0x6e263e,
+ 0x6ea050, 0x6f1a62, 0x6f9474, 0x700e86,
+ 0x708898, 0x7102aa, 0x717cbc, 0x71f6ce,
+ 0x7270e0, 0x72eaf2, 0x736504, 0x73df16,
+ 0x745928, 0x74d33a, 0x754d4c, 0x75c75e,
+ 0x764170, 0x76bb82, 0x773594, 0x77afa6,
+ 0x7829b8, 0x78a3ca, 0x791ddc, 0x7997ee
+};
+
+const u_int32 tstousmid[256] = {
+ 0x0000, 0x007a, 0x00f4, 0x016e, 0x01e8, 0x0262, 0x02dc, 0x0356,
+ 0x03d1, 0x044b, 0x04c5, 0x053f, 0x05b9, 0x0633, 0x06ad, 0x0727,
+ 0x07a1, 0x081b, 0x0895, 0x090f, 0x0989, 0x0a03, 0x0a7e, 0x0af8,
+ 0x0b72, 0x0bec, 0x0c66, 0x0ce0, 0x0d5a, 0x0dd4, 0x0e4e, 0x0ec8,
+ 0x0f42, 0x0fbc, 0x1036, 0x10b0, 0x112b, 0x11a5, 0x121f, 0x1299,
+ 0x1313, 0x138d, 0x1407, 0x1481, 0x14fb, 0x1575, 0x15ef, 0x1669,
+ 0x16e3, 0x175d, 0x17d8, 0x1852, 0x18cc, 0x1946, 0x19c0, 0x1a3a,
+ 0x1ab4, 0x1b2e, 0x1ba8, 0x1c22, 0x1c9c, 0x1d16, 0x1d90, 0x1e0a,
+ 0x1e84, 0x1eff, 0x1f79, 0x1ff3, 0x206d, 0x20e7, 0x2161, 0x21db,
+ 0x2255, 0x22cf, 0x2349, 0x23c3, 0x243d, 0x24b7, 0x2531, 0x25ac,
+ 0x2626, 0x26a0, 0x271a, 0x2794, 0x280e, 0x2888, 0x2902, 0x297c,
+ 0x29f6, 0x2a70, 0x2aea, 0x2b64, 0x2bde, 0x2c59, 0x2cd3, 0x2d4d,
+ 0x2dc7, 0x2e41, 0x2ebb, 0x2f35, 0x2faf, 0x3029, 0x30a3, 0x311d,
+ 0x3197, 0x3211, 0x328b, 0x3306, 0x3380, 0x33fa, 0x3474, 0x34ee,
+ 0x3568, 0x35e2, 0x365c, 0x36d6, 0x3750, 0x37ca, 0x3844, 0x38be,
+ 0x3938, 0x39b3, 0x3a2d, 0x3aa7, 0x3b21, 0x3b9b, 0x3c15, 0x3c8f,
+ 0x3d09, 0x3d83, 0x3dfd, 0x3e77, 0x3ef1, 0x3f6b, 0x3fe5, 0x405f,
+ 0x40da, 0x4154, 0x41ce, 0x4248, 0x42c2, 0x433c, 0x43b6, 0x4430,
+ 0x44aa, 0x4524, 0x459e, 0x4618, 0x4692, 0x470c, 0x4787, 0x4801,
+ 0x487b, 0x48f5, 0x496f, 0x49e9, 0x4a63, 0x4add, 0x4b57, 0x4bd1,
+ 0x4c4b, 0x4cc5, 0x4d3f, 0x4db9, 0x4e34, 0x4eae, 0x4f28, 0x4fa2,
+ 0x501c, 0x5096, 0x5110, 0x518a, 0x5204, 0x527e, 0x52f8, 0x5372,
+ 0x53ec, 0x5466, 0x54e1, 0x555b, 0x55d5, 0x564f, 0x56c9, 0x5743,
+ 0x57bd, 0x5837, 0x58b1, 0x592b, 0x59a5, 0x5a1f, 0x5a99, 0x5b13,
+ 0x5b8d, 0x5c08, 0x5c82, 0x5cfc, 0x5d76, 0x5df0, 0x5e6a, 0x5ee4,
+ 0x5f5e, 0x5fd8, 0x6052, 0x60cc, 0x6146, 0x61c0, 0x623a, 0x62b5,
+ 0x632f, 0x63a9, 0x6423, 0x649d, 0x6517, 0x6591, 0x660b, 0x6685,
+ 0x66ff, 0x6779, 0x67f3, 0x686d, 0x68e7, 0x6962, 0x69dc, 0x6a56,
+ 0x6ad0, 0x6b4a, 0x6bc4, 0x6c3e, 0x6cb8, 0x6d32, 0x6dac, 0x6e26,
+ 0x6ea0, 0x6f1a, 0x6f94, 0x700f, 0x7089, 0x7103, 0x717d, 0x71f7,
+ 0x7271, 0x72eb, 0x7365, 0x73df, 0x7459, 0x74d3, 0x754d, 0x75c7,
+ 0x7641, 0x76bc, 0x7736, 0x77b0, 0x782a, 0x78a4, 0x791e, 0x7998
+};
+
+const u_int32 tstouslo[128] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
+ 0x1f, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
+ 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x33, 0x34,
+ 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
+ 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44,
+ 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b,
+ 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
+ 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
+ 0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62,
+ 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
+ 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x71,
+ 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79
+};
+#else /* !USE_TSF_USEC_TABLES follows */
+NONEMPTY_TRANSLATION_UNIT
+#endif /* !USE_TSF_USEC_TABLES */
+/* -*- EOF -*- */
diff --git a/contrib/ntp/libntp/tsftomsu.c b/contrib/ntp/libntp/tsftomsu.c
deleted file mode 100644
index 5926aab..0000000
--- a/contrib/ntp/libntp/tsftomsu.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * tsftomsu - convert from a time stamp fraction to milliseconds
- */
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-
-int
-tsftomsu(
- u_long tsf,
- int round
- )
-{
- register long val_ui, val_uf;
- register long tmp_ui, tmp_uf;
- register int i;
-
- /*
- * Essentially, multiply by 10 three times in l_fp form.
- * The integral part is the milliseconds.
- */
- val_ui = 0;
- val_uf = tsf;
- for (i = 3; i > 0; i--) {
- M_LSHIFT(val_ui, val_uf);
- tmp_ui = val_ui;
- tmp_uf = val_uf;
- M_LSHIFT(val_ui, val_uf);
- M_LSHIFT(val_ui, val_uf);
- M_ADD(val_ui, val_uf, tmp_ui, tmp_uf);
- }
-
- /*
- * Round the value if need be, then return it.
- */
- if (round && (val_uf & 0x80000000))
- val_ui++;
- return (int)val_ui;
-}
diff --git a/contrib/ntp/libntp/tstotv.c b/contrib/ntp/libntp/tstotv.c
deleted file mode 100644
index be4bdd4..0000000
--- a/contrib/ntp/libntp/tstotv.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * tstotv - tables for converting from NTP time stamps to struct timeval
- */
-
-#include "ntp_types.h"
-
-/*
- * Tables to convert from a time stamp fraction to usecs. Note that
- * the units of these tables are actually (usec<<3). We carry three
- * guard bits so that the result can be properly truncated (or rounded)
- * to be correct to the least significant bit.
- *
- * These tables are rounded.
- */
-
-long tstoushi[256] = {
- 0x000000, 0x007a12, 0x00f424, 0x016e36,
- 0x01e848, 0x02625a, 0x02dc6c, 0x03567e,
- 0x03d090, 0x044aa2, 0x04c4b4, 0x053ec6,
- 0x05b8d8, 0x0632ea, 0x06acfc, 0x07270e,
- 0x07a120, 0x081b32, 0x089544, 0x090f56,
- 0x098968, 0x0a037a, 0x0a7d8c, 0x0af79e,
- 0x0b71b0, 0x0bebc2, 0x0c65d4, 0x0cdfe6,
- 0x0d59f8, 0x0dd40a, 0x0e4e1c, 0x0ec82e,
- 0x0f4240, 0x0fbc52, 0x103664, 0x10b076,
- 0x112a88, 0x11a49a, 0x121eac, 0x1298be,
- 0x1312d0, 0x138ce2, 0x1406f4, 0x148106,
- 0x14fb18, 0x15752a, 0x15ef3c, 0x16694e,
- 0x16e360, 0x175d72, 0x17d784, 0x185196,
- 0x18cba8, 0x1945ba, 0x19bfcc, 0x1a39de,
- 0x1ab3f0, 0x1b2e02, 0x1ba814, 0x1c2226,
- 0x1c9c38, 0x1d164a, 0x1d905c, 0x1e0a6e,
- 0x1e8480, 0x1efe92, 0x1f78a4, 0x1ff2b6,
- 0x206cc8, 0x20e6da, 0x2160ec, 0x21dafe,
- 0x225510, 0x22cf22, 0x234934, 0x23c346,
- 0x243d58, 0x24b76a, 0x25317c, 0x25ab8e,
- 0x2625a0, 0x269fb2, 0x2719c4, 0x2793d6,
- 0x280de8, 0x2887fa, 0x29020c, 0x297c1e,
- 0x29f630, 0x2a7042, 0x2aea54, 0x2b6466,
- 0x2bde78, 0x2c588a, 0x2cd29c, 0x2d4cae,
- 0x2dc6c0, 0x2e40d2, 0x2ebae4, 0x2f34f6,
- 0x2faf08, 0x30291a, 0x30a32c, 0x311d3e,
- 0x319750, 0x321162, 0x328b74, 0x330586,
- 0x337f98, 0x33f9aa, 0x3473bc, 0x34edce,
- 0x3567e0, 0x35e1f2, 0x365c04, 0x36d616,
- 0x375028, 0x37ca3a, 0x38444c, 0x38be5e,
- 0x393870, 0x39b282, 0x3a2c94, 0x3aa6a6,
- 0x3b20b8, 0x3b9aca, 0x3c14dc, 0x3c8eee,
- 0x3d0900, 0x3d8312, 0x3dfd24, 0x3e7736,
- 0x3ef148, 0x3f6b5a, 0x3fe56c, 0x405f7e,
- 0x40d990, 0x4153a2, 0x41cdb4, 0x4247c6,
- 0x42c1d8, 0x433bea, 0x43b5fc, 0x44300e,
- 0x44aa20, 0x452432, 0x459e44, 0x461856,
- 0x469268, 0x470c7a, 0x47868c, 0x48009e,
- 0x487ab0, 0x48f4c2, 0x496ed4, 0x49e8e6,
- 0x4a62f8, 0x4add0a, 0x4b571c, 0x4bd12e,
- 0x4c4b40, 0x4cc552, 0x4d3f64, 0x4db976,
- 0x4e3388, 0x4ead9a, 0x4f27ac, 0x4fa1be,
- 0x501bd0, 0x5095e2, 0x510ff4, 0x518a06,
- 0x520418, 0x527e2a, 0x52f83c, 0x53724e,
- 0x53ec60, 0x546672, 0x54e084, 0x555a96,
- 0x55d4a8, 0x564eba, 0x56c8cc, 0x5742de,
- 0x57bcf0, 0x583702, 0x58b114, 0x592b26,
- 0x59a538, 0x5a1f4a, 0x5a995c, 0x5b136e,
- 0x5b8d80, 0x5c0792, 0x5c81a4, 0x5cfbb6,
- 0x5d75c8, 0x5defda, 0x5e69ec, 0x5ee3fe,
- 0x5f5e10, 0x5fd822, 0x605234, 0x60cc46,
- 0x614658, 0x61c06a, 0x623a7c, 0x62b48e,
- 0x632ea0, 0x63a8b2, 0x6422c4, 0x649cd6,
- 0x6516e8, 0x6590fa, 0x660b0c, 0x66851e,
- 0x66ff30, 0x677942, 0x67f354, 0x686d66,
- 0x68e778, 0x69618a, 0x69db9c, 0x6a55ae,
- 0x6acfc0, 0x6b49d2, 0x6bc3e4, 0x6c3df6,
- 0x6cb808, 0x6d321a, 0x6dac2c, 0x6e263e,
- 0x6ea050, 0x6f1a62, 0x6f9474, 0x700e86,
- 0x708898, 0x7102aa, 0x717cbc, 0x71f6ce,
- 0x7270e0, 0x72eaf2, 0x736504, 0x73df16,
- 0x745928, 0x74d33a, 0x754d4c, 0x75c75e,
- 0x764170, 0x76bb82, 0x773594, 0x77afa6,
- 0x7829b8, 0x78a3ca, 0x791ddc, 0x7997ee
-};
-
-long tstousmid[256] = {
- 0x0000, 0x007a, 0x00f4, 0x016e, 0x01e8, 0x0262, 0x02dc, 0x0356,
- 0x03d1, 0x044b, 0x04c5, 0x053f, 0x05b9, 0x0633, 0x06ad, 0x0727,
- 0x07a1, 0x081b, 0x0895, 0x090f, 0x0989, 0x0a03, 0x0a7e, 0x0af8,
- 0x0b72, 0x0bec, 0x0c66, 0x0ce0, 0x0d5a, 0x0dd4, 0x0e4e, 0x0ec8,
- 0x0f42, 0x0fbc, 0x1036, 0x10b0, 0x112b, 0x11a5, 0x121f, 0x1299,
- 0x1313, 0x138d, 0x1407, 0x1481, 0x14fb, 0x1575, 0x15ef, 0x1669,
- 0x16e3, 0x175d, 0x17d8, 0x1852, 0x18cc, 0x1946, 0x19c0, 0x1a3a,
- 0x1ab4, 0x1b2e, 0x1ba8, 0x1c22, 0x1c9c, 0x1d16, 0x1d90, 0x1e0a,
- 0x1e84, 0x1eff, 0x1f79, 0x1ff3, 0x206d, 0x20e7, 0x2161, 0x21db,
- 0x2255, 0x22cf, 0x2349, 0x23c3, 0x243d, 0x24b7, 0x2531, 0x25ac,
- 0x2626, 0x26a0, 0x271a, 0x2794, 0x280e, 0x2888, 0x2902, 0x297c,
- 0x29f6, 0x2a70, 0x2aea, 0x2b64, 0x2bde, 0x2c59, 0x2cd3, 0x2d4d,
- 0x2dc7, 0x2e41, 0x2ebb, 0x2f35, 0x2faf, 0x3029, 0x30a3, 0x311d,
- 0x3197, 0x3211, 0x328b, 0x3306, 0x3380, 0x33fa, 0x3474, 0x34ee,
- 0x3568, 0x35e2, 0x365c, 0x36d6, 0x3750, 0x37ca, 0x3844, 0x38be,
- 0x3938, 0x39b3, 0x3a2d, 0x3aa7, 0x3b21, 0x3b9b, 0x3c15, 0x3c8f,
- 0x3d09, 0x3d83, 0x3dfd, 0x3e77, 0x3ef1, 0x3f6b, 0x3fe5, 0x405f,
- 0x40da, 0x4154, 0x41ce, 0x4248, 0x42c2, 0x433c, 0x43b6, 0x4430,
- 0x44aa, 0x4524, 0x459e, 0x4618, 0x4692, 0x470c, 0x4787, 0x4801,
- 0x487b, 0x48f5, 0x496f, 0x49e9, 0x4a63, 0x4add, 0x4b57, 0x4bd1,
- 0x4c4b, 0x4cc5, 0x4d3f, 0x4db9, 0x4e34, 0x4eae, 0x4f28, 0x4fa2,
- 0x501c, 0x5096, 0x5110, 0x518a, 0x5204, 0x527e, 0x52f8, 0x5372,
- 0x53ec, 0x5466, 0x54e1, 0x555b, 0x55d5, 0x564f, 0x56c9, 0x5743,
- 0x57bd, 0x5837, 0x58b1, 0x592b, 0x59a5, 0x5a1f, 0x5a99, 0x5b13,
- 0x5b8d, 0x5c08, 0x5c82, 0x5cfc, 0x5d76, 0x5df0, 0x5e6a, 0x5ee4,
- 0x5f5e, 0x5fd8, 0x6052, 0x60cc, 0x6146, 0x61c0, 0x623a, 0x62b5,
- 0x632f, 0x63a9, 0x6423, 0x649d, 0x6517, 0x6591, 0x660b, 0x6685,
- 0x66ff, 0x6779, 0x67f3, 0x686d, 0x68e7, 0x6962, 0x69dc, 0x6a56,
- 0x6ad0, 0x6b4a, 0x6bc4, 0x6c3e, 0x6cb8, 0x6d32, 0x6dac, 0x6e26,
- 0x6ea0, 0x6f1a, 0x6f94, 0x700f, 0x7089, 0x7103, 0x717d, 0x71f7,
- 0x7271, 0x72eb, 0x7365, 0x73df, 0x7459, 0x74d3, 0x754d, 0x75c7,
- 0x7641, 0x76bc, 0x7736, 0x77b0, 0x782a, 0x78a4, 0x791e, 0x7998
-};
-
-long tstouslo[128] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
- 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
- 0x1f, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
- 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
- 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x33, 0x34,
- 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
- 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44,
- 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b,
- 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
- 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
- 0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62,
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x71,
- 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79
-};
diff --git a/contrib/ntp/libntp/tvtoa.c b/contrib/ntp/libntp/tvtoa.c
deleted file mode 100644
index 19d4a94..0000000
--- a/contrib/ntp/libntp/tvtoa.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * tvtoa - return an asciized representation of a struct timeval
- */
-
-#include "lib_strbuf.h"
-
-#if defined(VMS)
-# include "ntp_fp.h"
-#endif /* VMS */
-#include "ntp_stdlib.h"
-#include "ntp_unixtime.h"
-
-#include <stdio.h>
-
-char *
-tvtoa(
- const struct timeval *tv
- )
-{
- register char *buf;
- register u_long sec;
- register u_long usec;
- register int isneg;
-
- if (tv->tv_sec < 0 || tv->tv_usec < 0) {
- sec = -tv->tv_sec;
- usec = -tv->tv_usec;
- isneg = 1;
- } else {
- sec = tv->tv_sec;
- usec = tv->tv_usec;
- isneg = 0;
- }
-
- LIB_GETBUF(buf);
-
- (void) sprintf(buf, "%s%lu.%06lu", (isneg?"-":""), sec, usec);
- return buf;
-}
diff --git a/contrib/ntp/libntp/tvtots.c b/contrib/ntp/libntp/tvtots.c
deleted file mode 100644
index 0bd2b69..0000000
--- a/contrib/ntp/libntp/tvtots.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * tvtots - tables for converting from Unix struct timeval's to
- * NTP time stamp format.
- */
-#include <sys/types.h>
-
-#include "ntp_types.h"
-
-/*
- * Tables to calculate time stamp fractions from usecs. The entries
- * in these tables are offset into using each of the two low order
- * bytes plus the next 4 bits in a usec value (from a struct timeval).
- * These are summed to produce the time stamp fraction.
- *
- * Note that these tables are rounded (not truncated) to the nearest
- * low order bit in the fraction. The timestamp computed should be
- * +- 1.5 low order bits.
- */
-
-u_long ustotslo[256] = {
- 0x00000000, 0x000010c7, 0x0000218e, 0x00003255,
- 0x0000431c, 0x000053e3, 0x000064aa, 0x00007571,
- 0x00008638, 0x000096ff, 0x0000a7c6, 0x0000b88d,
- 0x0000c954, 0x0000da1b, 0x0000eae2, 0x0000fba9,
- 0x00010c6f, 0x00011d36, 0x00012dfd, 0x00013ec4,
- 0x00014f8b, 0x00016052, 0x00017119, 0x000181e0,
- 0x000192a7, 0x0001a36e, 0x0001b435, 0x0001c4fc,
- 0x0001d5c3, 0x0001e68a, 0x0001f751, 0x00020818,
- 0x000218df, 0x000229a6, 0x00023a6d, 0x00024b34,
- 0x00025bfb, 0x00026cc2, 0x00027d89, 0x00028e50,
- 0x00029f17, 0x0002afde, 0x0002c0a5, 0x0002d16c,
- 0x0002e233, 0x0002f2fa, 0x000303c0, 0x00031487,
- 0x0003254e, 0x00033615, 0x000346dc, 0x000357a3,
- 0x0003686a, 0x00037931, 0x000389f8, 0x00039abf,
- 0x0003ab86, 0x0003bc4d, 0x0003cd14, 0x0003dddb,
- 0x0003eea2, 0x0003ff69, 0x00041030, 0x000420f7,
- 0x000431be, 0x00044285, 0x0004534c, 0x00046413,
- 0x000474da, 0x000485a1, 0x00049668, 0x0004a72f,
- 0x0004b7f6, 0x0004c8bd, 0x0004d984, 0x0004ea4b,
- 0x0004fb12, 0x00050bd8, 0x00051c9f, 0x00052d66,
- 0x00053e2d, 0x00054ef4, 0x00055fbb, 0x00057082,
- 0x00058149, 0x00059210, 0x0005a2d7, 0x0005b39e,
- 0x0005c465, 0x0005d52c, 0x0005e5f3, 0x0005f6ba,
- 0x00060781, 0x00061848, 0x0006290f, 0x000639d6,
- 0x00064a9d, 0x00065b64, 0x00066c2b, 0x00067cf2,
- 0x00068db9, 0x00069e80, 0x0006af47, 0x0006c00e,
- 0x0006d0d5, 0x0006e19c, 0x0006f263, 0x00070329,
- 0x000713f0, 0x000724b7, 0x0007357e, 0x00074645,
- 0x0007570c, 0x000767d3, 0x0007789a, 0x00078961,
- 0x00079a28, 0x0007aaef, 0x0007bbb6, 0x0007cc7d,
- 0x0007dd44, 0x0007ee0b, 0x0007fed2, 0x00080f99,
- 0x00082060, 0x00083127, 0x000841ee, 0x000852b5,
- 0x0008637c, 0x00087443, 0x0008850a, 0x000895d1,
- 0x0008a698, 0x0008b75f, 0x0008c826, 0x0008d8ed,
- 0x0008e9b4, 0x0008fa7b, 0x00090b41, 0x00091c08,
- 0x00092ccf, 0x00093d96, 0x00094e5d, 0x00095f24,
- 0x00096feb, 0x000980b2, 0x00099179, 0x0009a240,
- 0x0009b307, 0x0009c3ce, 0x0009d495, 0x0009e55c,
- 0x0009f623, 0x000a06ea, 0x000a17b1, 0x000a2878,
- 0x000a393f, 0x000a4a06, 0x000a5acd, 0x000a6b94,
- 0x000a7c5b, 0x000a8d22, 0x000a9de9, 0x000aaeb0,
- 0x000abf77, 0x000ad03e, 0x000ae105, 0x000af1cc,
- 0x000b0292, 0x000b1359, 0x000b2420, 0x000b34e7,
- 0x000b45ae, 0x000b5675, 0x000b673c, 0x000b7803,
- 0x000b88ca, 0x000b9991, 0x000baa58, 0x000bbb1f,
- 0x000bcbe6, 0x000bdcad, 0x000bed74, 0x000bfe3b,
- 0x000c0f02, 0x000c1fc9, 0x000c3090, 0x000c4157,
- 0x000c521e, 0x000c62e5, 0x000c73ac, 0x000c8473,
- 0x000c953a, 0x000ca601, 0x000cb6c8, 0x000cc78f,
- 0x000cd856, 0x000ce91d, 0x000cf9e4, 0x000d0aaa,
- 0x000d1b71, 0x000d2c38, 0x000d3cff, 0x000d4dc6,
- 0x000d5e8d, 0x000d6f54, 0x000d801b, 0x000d90e2,
- 0x000da1a9, 0x000db270, 0x000dc337, 0x000dd3fe,
- 0x000de4c5, 0x000df58c, 0x000e0653, 0x000e171a,
- 0x000e27e1, 0x000e38a8, 0x000e496f, 0x000e5a36,
- 0x000e6afd, 0x000e7bc4, 0x000e8c8b, 0x000e9d52,
- 0x000eae19, 0x000ebee0, 0x000ecfa7, 0x000ee06e,
- 0x000ef135, 0x000f01fb, 0x000f12c2, 0x000f2389,
- 0x000f3450, 0x000f4517, 0x000f55de, 0x000f66a5,
- 0x000f776c, 0x000f8833, 0x000f98fa, 0x000fa9c1,
- 0x000fba88, 0x000fcb4f, 0x000fdc16, 0x000fecdd,
- 0x000ffda4, 0x00100e6b, 0x00101f32, 0x00102ff9,
- 0x001040c0, 0x00105187, 0x0010624e, 0x00107315,
- 0x001083dc, 0x001094a3, 0x0010a56a, 0x0010b631,
-};
-
-u_long ustotsmid[256] = {
- 0x00000000, 0x0010c6f8, 0x00218def, 0x003254e7,
- 0x00431bde, 0x0053e2d6, 0x0064a9ce, 0x007570c5,
- 0x008637bd, 0x0096feb4, 0x00a7c5ac, 0x00b88ca4,
- 0x00c9539b, 0x00da1a93, 0x00eae18a, 0x00fba882,
- 0x010c6f7a, 0x011d3671, 0x012dfd69, 0x013ec460,
- 0x014f8b58, 0x01605250, 0x01711947, 0x0181e03f,
- 0x0192a736, 0x01a36e2e, 0x01b43526, 0x01c4fc1d,
- 0x01d5c315, 0x01e68a0c, 0x01f75104, 0x020817fc,
- 0x0218def3, 0x0229a5eb, 0x023a6ce3, 0x024b33da,
- 0x025bfad2, 0x026cc1c9, 0x027d88c1, 0x028e4fb9,
- 0x029f16b0, 0x02afdda8, 0x02c0a49f, 0x02d16b97,
- 0x02e2328f, 0x02f2f986, 0x0303c07e, 0x03148775,
- 0x03254e6d, 0x03361565, 0x0346dc5c, 0x0357a354,
- 0x03686a4b, 0x03793143, 0x0389f83b, 0x039abf32,
- 0x03ab862a, 0x03bc4d21, 0x03cd1419, 0x03dddb11,
- 0x03eea208, 0x03ff6900, 0x04102ff7, 0x0420f6ef,
- 0x0431bde7, 0x044284de, 0x04534bd6, 0x046412cd,
- 0x0474d9c5, 0x0485a0bd, 0x049667b4, 0x04a72eac,
- 0x04b7f5a3, 0x04c8bc9b, 0x04d98393, 0x04ea4a8a,
- 0x04fb1182, 0x050bd879, 0x051c9f71, 0x052d6669,
- 0x053e2d60, 0x054ef458, 0x055fbb4f, 0x05708247,
- 0x0581493f, 0x05921036, 0x05a2d72e, 0x05b39e25,
- 0x05c4651d, 0x05d52c15, 0x05e5f30c, 0x05f6ba04,
- 0x060780fb, 0x061847f3, 0x06290eeb, 0x0639d5e2,
- 0x064a9cda, 0x065b63d2, 0x066c2ac9, 0x067cf1c1,
- 0x068db8b8, 0x069e7fb0, 0x06af46a8, 0x06c00d9f,
- 0x06d0d497, 0x06e19b8e, 0x06f26286, 0x0703297e,
- 0x0713f075, 0x0724b76d, 0x07357e64, 0x0746455c,
- 0x07570c54, 0x0767d34b, 0x07789a43, 0x0789613a,
- 0x079a2832, 0x07aaef2a, 0x07bbb621, 0x07cc7d19,
- 0x07dd4410, 0x07ee0b08, 0x07fed200, 0x080f98f7,
- 0x08205fef, 0x083126e6, 0x0841edde, 0x0852b4d6,
- 0x08637bcd, 0x087442c5, 0x088509bc, 0x0895d0b4,
- 0x08a697ac, 0x08b75ea3, 0x08c8259b, 0x08d8ec92,
- 0x08e9b38a, 0x08fa7a82, 0x090b4179, 0x091c0871,
- 0x092ccf68, 0x093d9660, 0x094e5d58, 0x095f244f,
- 0x096feb47, 0x0980b23e, 0x09917936, 0x09a2402e,
- 0x09b30725, 0x09c3ce1d, 0x09d49514, 0x09e55c0c,
- 0x09f62304, 0x0a06e9fb, 0x0a17b0f3, 0x0a2877ea,
- 0x0a393ee2, 0x0a4a05da, 0x0a5accd1, 0x0a6b93c9,
- 0x0a7c5ac1, 0x0a8d21b8, 0x0a9de8b0, 0x0aaeafa7,
- 0x0abf769f, 0x0ad03d97, 0x0ae1048e, 0x0af1cb86,
- 0x0b02927d, 0x0b135975, 0x0b24206d, 0x0b34e764,
- 0x0b45ae5c, 0x0b567553, 0x0b673c4b, 0x0b780343,
- 0x0b88ca3a, 0x0b999132, 0x0baa5829, 0x0bbb1f21,
- 0x0bcbe619, 0x0bdcad10, 0x0bed7408, 0x0bfe3aff,
- 0x0c0f01f7, 0x0c1fc8ef, 0x0c308fe6, 0x0c4156de,
- 0x0c521dd5, 0x0c62e4cd, 0x0c73abc5, 0x0c8472bc,
- 0x0c9539b4, 0x0ca600ab, 0x0cb6c7a3, 0x0cc78e9b,
- 0x0cd85592, 0x0ce91c8a, 0x0cf9e381, 0x0d0aaa79,
- 0x0d1b7171, 0x0d2c3868, 0x0d3cff60, 0x0d4dc657,
- 0x0d5e8d4f, 0x0d6f5447, 0x0d801b3e, 0x0d90e236,
- 0x0da1a92d, 0x0db27025, 0x0dc3371d, 0x0dd3fe14,
- 0x0de4c50c, 0x0df58c03, 0x0e0652fb, 0x0e1719f3,
- 0x0e27e0ea, 0x0e38a7e2, 0x0e496ed9, 0x0e5a35d1,
- 0x0e6afcc9, 0x0e7bc3c0, 0x0e8c8ab8, 0x0e9d51b0,
- 0x0eae18a7, 0x0ebedf9f, 0x0ecfa696, 0x0ee06d8e,
- 0x0ef13486, 0x0f01fb7d, 0x0f12c275, 0x0f23896c,
- 0x0f345064, 0x0f45175c, 0x0f55de53, 0x0f66a54b,
- 0x0f776c42, 0x0f88333a, 0x0f98fa32, 0x0fa9c129,
- 0x0fba8821, 0x0fcb4f18, 0x0fdc1610, 0x0fecdd08,
- 0x0ffda3ff, 0x100e6af7, 0x101f31ee, 0x102ff8e6,
- 0x1040bfde, 0x105186d5, 0x10624dcd, 0x107314c4,
- 0x1083dbbc, 0x1094a2b4, 0x10a569ab, 0x10b630a3,
-};
-
-u_long ustotshi[16] = {
- 0x00000000, 0x10c6f79a, 0x218def35, 0x3254e6cf,
- 0x431bde6a, 0x53e2d604, 0x64a9cd9f, 0x7570c539,
- 0x8637bcd3, 0x96feb46e, 0xa7c5ac08, 0xb88ca3a3,
- 0xc9539b3d, 0xda1a92d7, 0xeae18a72, 0xfba8820c,
-};
diff --git a/contrib/ntp/libntp/uglydate.c b/contrib/ntp/libntp/uglydate.c
index 676a5fd..66b5139 100644
--- a/contrib/ntp/libntp/uglydate.c
+++ b/contrib/ntp/libntp/uglydate.c
@@ -2,6 +2,7 @@
* uglydate - convert a time stamp to something barely readable
* The string returned is 37 characters long.
*/
+#include <config.h>
#include <stdio.h>
#include "ntp_fp.h"
@@ -41,8 +42,10 @@ uglydate(
while (year >= 100)
year -= 100;
}
- (void) sprintf(bp, "%17s %02d:%03d:%02d:%02d:%02d.%03ld",
- timep, year, tm->tm_yday, tm->tm_hour, tm->tm_min,
- tm->tm_sec, msec);
+ snprintf(bp, LIB_BUFLENGTH,
+ "%17s %02d:%03d:%02d:%02d:%02d.%03ld", timep, year,
+ tm->tm_yday, tm->tm_hour, tm->tm_min, tm->tm_sec,
+ msec);
+
return bp;
}
diff --git a/contrib/ntp/libntp/uinttoa.c b/contrib/ntp/libntp/uinttoa.c
deleted file mode 100644
index be48ea5..0000000
--- a/contrib/ntp/libntp/uinttoa.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * uinttoa - return an asciized unsigned integer
- */
-#include <stdio.h>
-
-#include "lib_strbuf.h"
-#include "ntp_stdlib.h"
-
-char *
-uinttoa(
- u_long uval
- )
-{
- register char *buf;
-
- LIB_GETBUF(buf);
-
- (void) sprintf(buf, "%lu", (u_long)uval);
- return buf;
-}
diff --git a/contrib/ntp/libntp/utvtoa.c b/contrib/ntp/libntp/utvtoa.c
deleted file mode 100644
index a441c49..0000000
--- a/contrib/ntp/libntp/utvtoa.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * utvtoa - return an asciized representation of an unsigned struct timeval
- */
-#include <stdio.h>
-
-#include "lib_strbuf.h"
-
-#if defined(VMS)
-# include "ntp_fp.h"
-#endif
-#include "ntp_stdlib.h"
-#include "ntp_unixtime.h"
-
-char *
-utvtoa(
- const struct timeval *tv
- )
-{
- register char *buf;
-
- LIB_GETBUF(buf);
-
- (void) sprintf(buf, "%lu.%06lu", (u_long)tv->tv_sec,
- (u_long)tv->tv_usec);
- return buf;
-}
diff --git a/contrib/ntp/libntp/vint64ops.c b/contrib/ntp/libntp/vint64ops.c
new file mode 100644
index 0000000..5adbebb
--- /dev/null
+++ b/contrib/ntp/libntp/vint64ops.c
@@ -0,0 +1,284 @@
+/*
+ * vint64ops.c - operations on 'vint64' values
+ *
+ * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
+ * The contents of 'html/copyright.html' apply.
+ * ----------------------------------------------------------------------
+ * This is an attempt to get the vint64 calculations stuff centralised.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#include "ntp_types.h"
+#include "ntp_fp.h"
+#include "vint64ops.h"
+
+/* ---------------------------------------------------------------------
+ * GCC is rather sticky with its 'const' attribute. We have to do it more
+ * explicit than with a cast if we want to get rid of a CONST qualifier.
+ * Greetings from the PASCAL world, where casting was only possible via
+ * untagged unions...
+ */
+static inline void*
+noconst(
+ const void* ptr
+ )
+{
+ union {
+ const void * cp;
+ void * vp;
+ } tmp;
+ tmp.cp = ptr;
+ return tmp.vp;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+strtouv64(
+ const char * begp,
+ char ** endp,
+ int base
+ )
+{
+ vint64 res;
+ u_char digit;
+ int sig, num;
+ const u_char *src;
+
+ num = sig = 0;
+ src = (const u_char*)begp;
+ while (isspace(*src))
+ src++;
+
+ if (*src == '-') {
+ src++;
+ sig = 1;
+ } else if (*src == '+') {
+ src++;
+ }
+
+ if (base == 0) {
+ base = 10;
+ if (*src == '0') {
+ base = 8;
+ if (toupper(*++src) == 'X') {
+ src++;
+ base = 16;
+ }
+ }
+ } else if (base == 16) { /* remove optional leading '0x' or '0X' */
+ if (src[0] == '0' && toupper(src[1]) == 'X')
+ src += 2;
+ } else if (base <= 2 || base > 36) {
+ memset(&res, 0xFF, sizeof(res));
+ errno = ERANGE;
+ return res;
+ }
+
+ memset(&res, 0, sizeof(res));
+ while (*src) {
+ if (isdigit(*src))
+ digit = *src - '0';
+ else if (isupper(*src))
+ digit = *src - 'A' + 10;
+ else if (islower(*src))
+ digit = *src - 'a' + 10;
+ else
+ break;
+ if (digit >= base)
+ break;
+ num = 1;
+#if defined(HAVE_INT64)
+ res.Q_s = res.Q_s * base + digit;
+#else
+ /* res *= base, using 16x16->32 bit
+ * multiplication. Slow but portable.
+ */
+ {
+ uint32_t accu;
+ accu = (uint32_t)res.W_s.ll * base;
+ res.W_s.ll = (uint16_t)accu;
+ accu = (accu >> 16)
+ + (uint32_t)res.W_s.lh * base;
+ res.W_s.lh = (uint16_t)accu;
+ /* the upper bits can be done in one step: */
+ res.D_s.hi = res.D_s.hi * base + (accu >> 16);
+ }
+ M_ADD(res.D_s.hi, res.D_s.lo, 0, digit);
+#endif
+ src++;
+ }
+ if (!num)
+ errno = EINVAL;
+ if (endp)
+ *endp = (char*)noconst(src);
+ if (sig)
+ M_NEG(res.D_s.hi, res.D_s.lo);
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+int
+icmpv64(
+ const vint64 * lhs,
+ const vint64 * rhs
+ )
+{
+ int res;
+
+#if defined(HAVE_INT64)
+ res = (lhs->q_s > rhs->q_s)
+ - (lhs->q_s < rhs->q_s);
+#else
+ res = (lhs->d_s.hi > rhs->d_s.hi)
+ - (lhs->d_s.hi < rhs->d_s.hi);
+ if ( ! res )
+ res = (lhs->D_s.lo > rhs->D_s.lo)
+ - (lhs->D_s.lo < rhs->D_s.lo);
+#endif
+
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+int
+ucmpv64(
+ const vint64 * lhs,
+ const vint64 * rhs
+ )
+{
+ int res;
+
+#if defined(HAVE_INT64)
+ res = (lhs->Q_s > rhs->Q_s)
+ - (lhs->Q_s < rhs->Q_s);
+#else
+ res = (lhs->D_s.hi > rhs->D_s.hi)
+ - (lhs->D_s.hi < rhs->D_s.hi);
+ if ( ! res )
+ res = (lhs->D_s.lo > rhs->D_s.lo)
+ - (lhs->D_s.lo < rhs->D_s.lo);
+#endif
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+addv64(
+ const vint64 *lhs,
+ const vint64 *rhs
+ )
+{
+ vint64 res;
+
+#if defined(HAVE_INT64)
+ res.Q_s = lhs->Q_s + rhs->Q_s;
+#else
+ res = *lhs;
+ M_ADD(res.D_s.hi, res.D_s.lo, rhs->D_s.hi, rhs->D_s.lo);
+#endif
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+subv64(
+ const vint64 *lhs,
+ const vint64 *rhs
+ )
+{
+ vint64 res;
+
+#if defined(HAVE_INT64)
+ res.Q_s = lhs->Q_s - rhs->Q_s;
+#else
+ res = *lhs;
+ M_SUB(res.D_s.hi, res.D_s.lo, rhs->D_s.hi, rhs->D_s.lo);
+#endif
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+addv64i32(
+ const vint64 * lhs,
+ int32_t rhs
+ )
+{
+ vint64 res;
+
+ res = *lhs;
+#if defined(HAVE_INT64)
+ res.q_s += rhs;
+#else
+ M_ADD(res.D_s.hi, res.D_s.lo, -(rhs < 0), rhs);
+#endif
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+subv64i32(
+ const vint64 * lhs,
+ int32_t rhs
+ )
+{
+ vint64 res;
+
+ res = *lhs;
+#if defined(HAVE_INT64)
+ res.q_s -= rhs;
+#else
+ M_SUB(res.D_s.hi, res.D_s.lo, -(rhs < 0), rhs);
+#endif
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+addv64u32(
+ const vint64 * lhs,
+ uint32_t rhs
+ )
+{
+ vint64 res;
+
+ res = *lhs;
+#if defined(HAVE_INT64)
+ res.Q_s += rhs;
+#else
+ M_ADD(res.D_s.hi, res.D_s.lo, 0, rhs);
+#endif
+ return res;
+}
+
+/* -------------------------------------------------------------------------*/
+
+vint64
+subv64u32(
+ const vint64 * lhs,
+ uint32_t rhs
+ )
+{
+ vint64 res;
+
+ res = *lhs;
+#if defined(HAVE_INT64)
+ res.Q_s -= rhs;
+#else
+ M_SUB(res.D_s.hi, res.D_s.lo, 0, rhs);
+#endif
+ return res;
+}
diff --git a/contrib/ntp/libntp/work_fork.c b/contrib/ntp/libntp/work_fork.c
new file mode 100644
index 0000000..96c550e
--- /dev/null
+++ b/contrib/ntp/libntp/work_fork.c
@@ -0,0 +1,545 @@
+/*
+ * work_fork.c - fork implementation for blocking worker child.
+ */
+#include <config.h>
+#include "ntp_workimpl.h"
+
+#ifdef WORK_FORK
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+#include "iosignal.h"
+#include "ntp_stdlib.h"
+#include "ntp_malloc.h"
+#include "ntp_syslog.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_assert.h"
+#include "ntp_unixtime.h"
+#include "ntp_worker.h"
+
+/* === variables === */
+ int worker_process;
+ addremove_io_fd_func addremove_io_fd;
+static volatile int worker_sighup_received;
+
+/* === function prototypes === */
+static void fork_blocking_child(blocking_child *);
+static RETSIGTYPE worker_sighup(int);
+static void send_worker_home_atexit(void);
+static void cleanup_after_child(blocking_child *);
+
+/* === functions === */
+/*
+ * exit_worker()
+ *
+ * On some systems _exit() is preferred to exit() for forked children.
+ * For example, http://netbsd.gw.com/cgi-bin/man-cgi?fork++NetBSD-5.0
+ * recommends _exit() to avoid double-flushing C runtime stream buffers
+ * and also to avoid calling the parent's atexit() routines in the
+ * child. On those systems WORKER_CHILD_EXIT is _exit. Since _exit
+ * bypasses CRT cleanup, fflush() files we know might have output
+ * buffered.
+ */
+void
+exit_worker(
+ int exitcode
+ )
+{
+ if (syslog_file != NULL)
+ fflush(syslog_file);
+ fflush(stdout);
+ fflush(stderr);
+ WORKER_CHILD_EXIT (exitcode); /* space before ( required */
+}
+
+
+static RETSIGTYPE
+worker_sighup(
+ int sig
+ )
+{
+ if (SIGHUP == sig)
+ worker_sighup_received = 1;
+}
+
+
+int
+worker_sleep(
+ blocking_child * c,
+ time_t seconds
+ )
+{
+ u_int sleep_remain;
+
+ sleep_remain = (u_int)seconds;
+ do {
+ if (!worker_sighup_received)
+ sleep_remain = sleep(sleep_remain);
+ if (worker_sighup_received) {
+ TRACE(1, ("worker SIGHUP with %us left to sleep",
+ sleep_remain));
+ worker_sighup_received = 0;
+ return -1;
+ }
+ } while (sleep_remain);
+
+ return 0;
+}
+
+
+void
+interrupt_worker_sleep(void)
+{
+ u_int idx;
+ blocking_child * c;
+ int rc;
+
+ for (idx = 0; idx < blocking_children_alloc; idx++) {
+ c = blocking_children[idx];
+
+ if (NULL == c || c->reusable == TRUE)
+ continue;
+
+ rc = kill(c->pid, SIGHUP);
+ if (rc < 0)
+ msyslog(LOG_ERR,
+ "Unable to signal HUP to wake child pid %d: %m",
+ c->pid);
+ }
+}
+
+
+/*
+ * harvest_child_status() runs in the parent.
+ */
+static void
+harvest_child_status(
+ blocking_child * c
+ )
+{
+ if (c->pid)
+ {
+ /* Wait on the child so it can finish terminating */
+ if (waitpid(c->pid, NULL, 0) == c->pid)
+ TRACE(4, ("harvested child %d\n", c->pid));
+ else msyslog(LOG_ERR, "error waiting on child %d: %m", c->pid);
+ }
+}
+
+/*
+ * req_child_exit() runs in the parent.
+ */
+int
+req_child_exit(
+ blocking_child * c
+ )
+{
+ if (-1 != c->req_write_pipe) {
+ close(c->req_write_pipe);
+ c->req_write_pipe = -1;
+ return 0;
+ }
+ /* Closing the pipe forces the child to exit */
+ harvest_child_status(c);
+ return -1;
+}
+
+
+/*
+ * cleanup_after_child() runs in parent.
+ */
+static void
+cleanup_after_child(
+ blocking_child * c
+ )
+{
+ harvest_child_status(c);
+ if (-1 != c->resp_read_pipe) {
+ (*addremove_io_fd)(c->resp_read_pipe, c->ispipe, TRUE);
+ close(c->resp_read_pipe);
+ c->resp_read_pipe = -1;
+ }
+ c->pid = 0;
+ c->resp_read_ctx = NULL;
+ DEBUG_INSIST(-1 == c->req_read_pipe);
+ DEBUG_INSIST(-1 == c->resp_write_pipe);
+ c->reusable = TRUE;
+}
+
+
+static void
+send_worker_home_atexit(void)
+{
+ u_int idx;
+ blocking_child * c;
+
+ if (worker_process)
+ return;
+
+ for (idx = 0; idx < blocking_children_alloc; idx++) {
+ c = blocking_children[idx];
+ if (NULL == c)
+ continue;
+ req_child_exit(c);
+ }
+}
+
+
+int
+send_blocking_req_internal(
+ blocking_child * c,
+ blocking_pipe_header * hdr,
+ void * data
+ )
+{
+ int octets;
+ int rc;
+
+ DEBUG_REQUIRE(hdr != NULL);
+ DEBUG_REQUIRE(data != NULL);
+ DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == hdr->magic_sig);
+
+ if (-1 == c->req_write_pipe) {
+ fork_blocking_child(c);
+ DEBUG_INSIST(-1 != c->req_write_pipe);
+ }
+
+ octets = sizeof(*hdr);
+ rc = write(c->req_write_pipe, hdr, octets);
+
+ if (rc == octets) {
+ octets = hdr->octets - sizeof(*hdr);
+ rc = write(c->req_write_pipe, data, octets);
+
+ if (rc == octets)
+ return 0;
+ }
+
+ if (rc < 0)
+ msyslog(LOG_ERR,
+ "send_blocking_req_internal: pipe write: %m");
+ else
+ msyslog(LOG_ERR,
+ "send_blocking_req_internal: short write %d of %d",
+ rc, octets);
+
+ /* Fatal error. Clean up the child process. */
+ req_child_exit(c);
+ exit(1); /* otherwise would be return -1 */
+}
+
+
+blocking_pipe_header *
+receive_blocking_req_internal(
+ blocking_child * c
+ )
+{
+ blocking_pipe_header hdr;
+ blocking_pipe_header * req;
+ int rc;
+ long octets;
+
+ DEBUG_REQUIRE(-1 != c->req_read_pipe);
+
+ req = NULL;
+
+ do {
+ rc = read(c->req_read_pipe, &hdr, sizeof(hdr));
+ } while (rc < 0 && EINTR == errno);
+
+ if (rc < 0) {
+ msyslog(LOG_ERR,
+ "receive_blocking_req_internal: pipe read %m");
+ } else if (0 == rc) {
+ TRACE(4, ("parent closed request pipe, child %d terminating\n",
+ c->pid));
+ } else if (rc != sizeof(hdr)) {
+ msyslog(LOG_ERR,
+ "receive_blocking_req_internal: short header read %d of %lu",
+ rc, (u_long)sizeof(hdr));
+ } else {
+ INSIST(sizeof(hdr) < hdr.octets && hdr.octets < 4 * 1024);
+ req = emalloc(hdr.octets);
+ memcpy(req, &hdr, sizeof(*req));
+ octets = hdr.octets - sizeof(hdr);
+ rc = read(c->req_read_pipe, (char *)req + sizeof(*req),
+ octets);
+
+ if (rc < 0)
+ msyslog(LOG_ERR,
+ "receive_blocking_req_internal: pipe data read %m");
+ else if (rc != octets)
+ msyslog(LOG_ERR,
+ "receive_blocking_req_internal: short read %d of %ld",
+ rc, octets);
+ else if (BLOCKING_REQ_MAGIC != req->magic_sig)
+ msyslog(LOG_ERR,
+ "receive_blocking_req_internal: packet header mismatch (0x%x)",
+ req->magic_sig);
+ else
+ return req;
+ }
+
+ if (req != NULL)
+ free(req);
+
+ return NULL;
+}
+
+
+int
+send_blocking_resp_internal(
+ blocking_child * c,
+ blocking_pipe_header * resp
+ )
+{
+ long octets;
+ int rc;
+
+ DEBUG_REQUIRE(-1 != c->resp_write_pipe);
+
+ octets = resp->octets;
+ rc = write(c->resp_write_pipe, resp, octets);
+ free(resp);
+
+ if (octets == rc)
+ return 0;
+
+ if (rc < 0)
+ TRACE(1, ("send_blocking_resp_internal: pipe write %m\n"));
+ else
+ TRACE(1, ("send_blocking_resp_internal: short write %d of %ld\n",
+ rc, octets));
+
+ return -1;
+}
+
+
+blocking_pipe_header *
+receive_blocking_resp_internal(
+ blocking_child * c
+ )
+{
+ blocking_pipe_header hdr;
+ blocking_pipe_header * resp;
+ int rc;
+ long octets;
+
+ DEBUG_REQUIRE(c->resp_read_pipe != -1);
+
+ resp = NULL;
+ rc = read(c->resp_read_pipe, &hdr, sizeof(hdr));
+
+ if (rc < 0) {
+ TRACE(1, ("receive_blocking_resp_internal: pipe read %m\n"));
+ } else if (0 == rc) {
+ /* this is the normal child exited indication */
+ } else if (rc != sizeof(hdr)) {
+ TRACE(1, ("receive_blocking_resp_internal: short header read %d of %lu\n",
+ rc, (u_long)sizeof(hdr)));
+ } else if (BLOCKING_RESP_MAGIC != hdr.magic_sig) {
+ TRACE(1, ("receive_blocking_resp_internal: header mismatch (0x%x)\n",
+ hdr.magic_sig));
+ } else {
+ INSIST(sizeof(hdr) < hdr.octets &&
+ hdr.octets < 16 * 1024);
+ resp = emalloc(hdr.octets);
+ memcpy(resp, &hdr, sizeof(*resp));
+ octets = hdr.octets - sizeof(hdr);
+ rc = read(c->resp_read_pipe,
+ (char *)resp + sizeof(*resp),
+ octets);
+
+ if (rc < 0)
+ TRACE(1, ("receive_blocking_resp_internal: pipe data read %m\n"));
+ else if (rc < octets)
+ TRACE(1, ("receive_blocking_resp_internal: short read %d of %ld\n",
+ rc, octets));
+ else
+ return resp;
+ }
+
+ cleanup_after_child(c);
+
+ if (resp != NULL)
+ free(resp);
+
+ return NULL;
+}
+
+
+#if defined(HAVE_DROPROOT) && defined(WORK_FORK)
+void
+fork_deferred_worker(void)
+{
+ u_int idx;
+ blocking_child * c;
+
+ REQUIRE(droproot && root_dropped);
+
+ for (idx = 0; idx < blocking_children_alloc; idx++) {
+ c = blocking_children[idx];
+ if (NULL == c)
+ continue;
+ if (-1 != c->req_write_pipe && 0 == c->pid)
+ fork_blocking_child(c);
+ }
+}
+#endif
+
+
+static void
+fork_blocking_child(
+ blocking_child * c
+ )
+{
+ static int atexit_installed;
+ static int blocking_pipes[4] = { -1, -1, -1, -1 };
+ int rc;
+ int was_pipe;
+ int is_pipe;
+ int saved_errno = 0;
+ int childpid;
+ int keep_fd;
+ int fd;
+
+ /*
+ * parent and child communicate via a pair of pipes.
+ *
+ * 0 child read request
+ * 1 parent write request
+ * 2 parent read response
+ * 3 child write response
+ */
+ if (-1 == c->req_write_pipe) {
+ rc = pipe_socketpair(&blocking_pipes[0], &was_pipe);
+ if (0 != rc) {
+ saved_errno = errno;
+ } else {
+ rc = pipe_socketpair(&blocking_pipes[2], &is_pipe);
+ if (0 != rc) {
+ saved_errno = errno;
+ close(blocking_pipes[0]);
+ close(blocking_pipes[1]);
+ } else {
+ INSIST(was_pipe == is_pipe);
+ }
+ }
+ if (0 != rc) {
+ errno = saved_errno;
+ msyslog(LOG_ERR, "unable to create worker pipes: %m");
+ exit(1);
+ }
+
+ /*
+ * Move the descriptors the parent will keep open out of the
+ * low descriptors preferred by C runtime buffered FILE *.
+ */
+ c->req_write_pipe = move_fd(blocking_pipes[1]);
+ c->resp_read_pipe = move_fd(blocking_pipes[2]);
+ /*
+ * wake any worker child on orderly shutdown of the
+ * daemon so that it can notice the broken pipes and
+ * go away promptly.
+ */
+ if (!atexit_installed) {
+ atexit(&send_worker_home_atexit);
+ atexit_installed = TRUE;
+ }
+ }
+
+#ifdef HAVE_DROPROOT
+ /* defer the fork until after root is dropped */
+ if (droproot && !root_dropped)
+ return;
+#endif
+ if (syslog_file != NULL)
+ fflush(syslog_file);
+ fflush(stdout);
+ fflush(stderr);
+
+ signal_no_reset(SIGCHLD, SIG_IGN);
+
+ childpid = fork();
+ if (-1 == childpid) {
+ msyslog(LOG_ERR, "unable to fork worker: %m");
+ exit(1);
+ }
+
+ if (childpid) {
+ /* this is the parent */
+ TRACE(1, ("forked worker child (pid %d)\n", childpid));
+ c->pid = childpid;
+ c->ispipe = is_pipe;
+
+ /* close the child's pipe descriptors. */
+ close(blocking_pipes[0]);
+ close(blocking_pipes[3]);
+
+ memset(blocking_pipes, -1, sizeof(blocking_pipes));
+
+ /* wire into I/O loop */
+ (*addremove_io_fd)(c->resp_read_pipe, is_pipe, FALSE);
+
+ return; /* parent returns */
+ }
+
+ /*
+ * The parent gets the child pid as the return value of fork().
+ * The child must work for it.
+ */
+ c->pid = getpid();
+ worker_process = TRUE;
+
+ /*
+ * In the child, close all files except stdin, stdout, stderr,
+ * and the two child ends of the pipes.
+ */
+ DEBUG_INSIST(-1 == c->req_read_pipe);
+ DEBUG_INSIST(-1 == c->resp_write_pipe);
+ c->req_read_pipe = blocking_pipes[0];
+ c->resp_write_pipe = blocking_pipes[3];
+
+ kill_asyncio(0);
+ closelog();
+ if (syslog_file != NULL) {
+ fclose(syslog_file);
+ syslog_file = NULL;
+ syslogit = TRUE;
+ }
+ keep_fd = max(c->req_read_pipe, c->resp_write_pipe);
+ for (fd = 3; fd < keep_fd; fd++)
+ if (fd != c->req_read_pipe &&
+ fd != c->resp_write_pipe)
+ close(fd);
+ close_all_beyond(keep_fd);
+ /*
+ * We get signals from refclock serial I/O on NetBSD in the
+ * worker if we do not reset SIGIO's handler to the default.
+ * It is not conditionalized for NetBSD alone because on
+ * systems where it is not needed, it is harmless, and that
+ * allows us to handle unknown others with NetBSD behavior.
+ * [Bug 1386]
+ */
+#if defined(USE_SIGIO)
+ signal_no_reset(SIGIO, SIG_DFL);
+#elif defined(USE_SIGPOLL)
+ signal_no_reset(SIGPOLL, SIG_DFL);
+#endif
+ signal_no_reset(SIGHUP, worker_sighup);
+ init_logging("ntp_intres", 0, FALSE);
+ setup_logfile(NULL);
+
+ /*
+ * And now back to the portable code
+ */
+ exit_worker(blocking_child_common(c));
+}
+
+
+#else /* !WORK_FORK follows */
+char work_fork_nonempty_compilation_unit;
+#endif
diff --git a/contrib/ntp/libntp/work_thread.c b/contrib/ntp/libntp/work_thread.c
new file mode 100644
index 0000000..38d8747
--- /dev/null
+++ b/contrib/ntp/libntp/work_thread.c
@@ -0,0 +1,726 @@
+/*
+ * work_thread.c - threads implementation for blocking worker child.
+ */
+#include <config.h>
+#include "ntp_workimpl.h"
+
+#ifdef WORK_THREAD
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#ifndef SYS_WINNT
+#include <pthread.h>
+#endif
+
+#include "ntp_stdlib.h"
+#include "ntp_malloc.h"
+#include "ntp_syslog.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_assert.h"
+#include "ntp_unixtime.h"
+#include "timespecops.h"
+#include "ntp_worker.h"
+
+#define CHILD_EXIT_REQ ((blocking_pipe_header *)(intptr_t)-1)
+#define CHILD_GONE_RESP CHILD_EXIT_REQ
+#define WORKITEMS_ALLOC_INC 16
+#define RESPONSES_ALLOC_INC 4
+
+#ifndef THREAD_MINSTACKSIZE
+#define THREAD_MINSTACKSIZE (64U * 1024)
+#endif
+
+#ifndef DEVOLATILE
+#define DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
+#endif
+
+#ifdef SYS_WINNT
+# define thread_exit(c) _endthreadex(c)
+# define tickle_sem SetEvent
+#else
+# define thread_exit(c) pthread_exit((void*)(size_t)(c))
+# define tickle_sem sem_post
+#endif
+
+#ifdef WORK_PIPE
+addremove_io_fd_func addremove_io_fd;
+#else
+addremove_io_semaphore_func addremove_io_semaphore;
+#endif
+
+static void start_blocking_thread(blocking_child *);
+static void start_blocking_thread_internal(blocking_child *);
+static void prepare_child_sems(blocking_child *);
+static int wait_for_sem(sem_ref, struct timespec *);
+static void ensure_workitems_empty_slot(blocking_child *);
+static void ensure_workresp_empty_slot(blocking_child *);
+static int queue_req_pointer(blocking_child *, blocking_pipe_header *);
+static void cleanup_after_child(blocking_child *);
+#ifdef SYS_WINNT
+u_int WINAPI blocking_thread(void *);
+#else
+void * blocking_thread(void *);
+#endif
+#ifndef SYS_WINNT
+static void block_thread_signals(sigset_t *);
+#endif
+
+
+void
+exit_worker(
+ int exitcode
+ )
+{
+ thread_exit(exitcode); /* see #define thread_exit */
+}
+
+
+int
+worker_sleep(
+ blocking_child * c,
+ time_t seconds
+ )
+{
+ struct timespec until;
+ int rc;
+
+# ifdef HAVE_CLOCK_GETTIME
+ if (0 != clock_gettime(CLOCK_REALTIME, &until)) {
+ msyslog(LOG_ERR, "worker_sleep: clock_gettime() failed: %m");
+ return -1;
+ }
+# else
+ if (0 != getclock(TIMEOFDAY, &until)) {
+ msyslog(LOG_ERR, "worker_sleep: getclock() failed: %m");
+ return -1;
+ }
+# endif
+ until.tv_sec += seconds;
+ do {
+ rc = wait_for_sem(c->wake_scheduled_sleep, &until);
+ } while (-1 == rc && EINTR == errno);
+ if (0 == rc)
+ return -1;
+ if (-1 == rc && ETIMEDOUT == errno)
+ return 0;
+ msyslog(LOG_ERR, "worker_sleep: sem_timedwait: %m");
+ return -1;
+}
+
+
+void
+interrupt_worker_sleep(void)
+{
+ u_int idx;
+ blocking_child * c;
+
+ for (idx = 0; idx < blocking_children_alloc; idx++) {
+ c = blocking_children[idx];
+ if (NULL == c || NULL == c->wake_scheduled_sleep)
+ continue;
+ tickle_sem(c->wake_scheduled_sleep);
+ }
+}
+
+
+static void
+ensure_workitems_empty_slot(
+ blocking_child *c
+ )
+{
+ const size_t each = sizeof(blocking_children[0]->workitems[0]);
+ size_t new_alloc;
+ size_t old_octets;
+ size_t new_octets;
+ void * nonvol_workitems;
+
+
+ if (c->workitems != NULL &&
+ NULL == c->workitems[c->next_workitem])
+ return;
+
+ new_alloc = c->workitems_alloc + WORKITEMS_ALLOC_INC;
+ old_octets = c->workitems_alloc * each;
+ new_octets = new_alloc * each;
+ nonvol_workitems = DEVOLATILE(void *, c->workitems);
+ c->workitems = erealloc_zero(nonvol_workitems, new_octets,
+ old_octets);
+ if (0 == c->next_workitem)
+ c->next_workitem = c->workitems_alloc;
+ c->workitems_alloc = new_alloc;
+}
+
+
+static void
+ensure_workresp_empty_slot(
+ blocking_child *c
+ )
+{
+ const size_t each = sizeof(blocking_children[0]->responses[0]);
+ size_t new_alloc;
+ size_t old_octets;
+ size_t new_octets;
+ void * nonvol_responses;
+
+ if (c->responses != NULL &&
+ NULL == c->responses[c->next_response])
+ return;
+
+ new_alloc = c->responses_alloc + RESPONSES_ALLOC_INC;
+ old_octets = c->responses_alloc * each;
+ new_octets = new_alloc * each;
+ nonvol_responses = DEVOLATILE(void *, c->responses);
+ c->responses = erealloc_zero(nonvol_responses, new_octets,
+ old_octets);
+ if (0 == c->next_response)
+ c->next_response = c->responses_alloc;
+ c->responses_alloc = new_alloc;
+}
+
+
+/*
+ * queue_req_pointer() - append a work item or idle exit request to
+ * blocking_workitems[].
+ */
+static int
+queue_req_pointer(
+ blocking_child * c,
+ blocking_pipe_header * hdr
+ )
+{
+ c->workitems[c->next_workitem] = hdr;
+ c->next_workitem = (1 + c->next_workitem) % c->workitems_alloc;
+
+ /*
+ * We only want to signal the wakeup event if the child is
+ * blocking on it, which is indicated by setting the blocking
+ * event. Wait with zero timeout to test.
+ */
+ /* !!!! if (WAIT_OBJECT_0 == WaitForSingleObject(c->child_is_blocking, 0)) */
+ tickle_sem(c->blocking_req_ready);
+
+ return 0;
+}
+
+
+int
+send_blocking_req_internal(
+ blocking_child * c,
+ blocking_pipe_header * hdr,
+ void * data
+ )
+{
+ blocking_pipe_header * threadcopy;
+ size_t payload_octets;
+
+ REQUIRE(hdr != NULL);
+ REQUIRE(data != NULL);
+ DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == hdr->magic_sig);
+
+ if (hdr->octets <= sizeof(*hdr))
+ return 1; /* failure */
+ payload_octets = hdr->octets - sizeof(*hdr);
+
+ ensure_workitems_empty_slot(c);
+ if (NULL == c->thread_ref) {
+ ensure_workresp_empty_slot(c);
+ start_blocking_thread(c);
+ }
+
+ threadcopy = emalloc(hdr->octets);
+ memcpy(threadcopy, hdr, sizeof(*hdr));
+ memcpy((char *)threadcopy + sizeof(*hdr), data, payload_octets);
+
+ return queue_req_pointer(c, threadcopy);
+}
+
+
+blocking_pipe_header *
+receive_blocking_req_internal(
+ blocking_child * c
+ )
+{
+ blocking_pipe_header * req;
+ int rc;
+
+ /*
+ * Child blocks here when idle. SysV semaphores maintain a
+ * count and release from sem_wait() only when it reaches 0.
+ * Windows auto-reset events are simpler, and multiple SetEvent
+ * calls before any thread waits result in a single wakeup.
+ * On Windows, the child drains all workitems each wakeup, while
+ * with SysV semaphores wait_sem() is used before each item.
+ */
+#ifdef SYS_WINNT
+ while (NULL == c->workitems[c->next_workeritem]) {
+ /* !!!! SetEvent(c->child_is_blocking); */
+ rc = wait_for_sem(c->blocking_req_ready, NULL);
+ INSIST(0 == rc);
+ /* !!!! ResetEvent(c->child_is_blocking); */
+ }
+#else
+ do {
+ rc = wait_for_sem(c->blocking_req_ready, NULL);
+ } while (-1 == rc && EINTR == errno);
+ INSIST(0 == rc);
+#endif
+
+ req = c->workitems[c->next_workeritem];
+ INSIST(NULL != req);
+ c->workitems[c->next_workeritem] = NULL;
+ c->next_workeritem = (1 + c->next_workeritem) %
+ c->workitems_alloc;
+
+ if (CHILD_EXIT_REQ == req) { /* idled out */
+ send_blocking_resp_internal(c, CHILD_GONE_RESP);
+ req = NULL;
+ }
+
+ return req;
+}
+
+
+int
+send_blocking_resp_internal(
+ blocking_child * c,
+ blocking_pipe_header * resp
+ )
+{
+ ensure_workresp_empty_slot(c);
+
+ c->responses[c->next_response] = resp;
+ c->next_response = (1 + c->next_response) % c->responses_alloc;
+
+#ifdef WORK_PIPE
+ write(c->resp_write_pipe, "", 1);
+#else
+ tickle_sem(c->blocking_response_ready);
+#endif
+
+ return 0;
+}
+
+
+#ifndef WORK_PIPE
+void
+handle_blocking_resp_sem(
+ void * context
+ )
+{
+ HANDLE ready;
+ blocking_child * c;
+ u_int idx;
+
+ ready = (HANDLE)context;
+ c = NULL;
+ for (idx = 0; idx < blocking_children_alloc; idx++) {
+ c = blocking_children[idx];
+ if (c != NULL && c->thread_ref != NULL &&
+ ready == c->blocking_response_ready)
+ break;
+ }
+ if (idx < blocking_children_alloc)
+ process_blocking_resp(c);
+}
+#endif /* !WORK_PIPE */
+
+
+blocking_pipe_header *
+receive_blocking_resp_internal(
+ blocking_child * c
+ )
+{
+ blocking_pipe_header * removed;
+#ifdef WORK_PIPE
+ int rc;
+ char scratch[32];
+
+ do {
+ rc = read(c->resp_read_pipe, scratch, sizeof(scratch));
+ } while (-1 == rc && EINTR == errno);
+#endif
+ removed = c->responses[c->next_workresp];
+ if (NULL != removed) {
+ c->responses[c->next_workresp] = NULL;
+ c->next_workresp = (1 + c->next_workresp) %
+ c->responses_alloc;
+ DEBUG_ENSURE(CHILD_GONE_RESP == removed ||
+ BLOCKING_RESP_MAGIC == removed->magic_sig);
+ }
+ if (CHILD_GONE_RESP == removed) {
+ cleanup_after_child(c);
+ removed = NULL;
+ }
+
+ return removed;
+}
+
+
+static void
+start_blocking_thread(
+ blocking_child * c
+ )
+{
+
+ DEBUG_INSIST(!c->reusable);
+
+ prepare_child_sems(c);
+ start_blocking_thread_internal(c);
+}
+
+
+static void
+start_blocking_thread_internal(
+ blocking_child * c
+ )
+#ifdef SYS_WINNT
+{
+ thr_ref blocking_child_thread;
+ u_int blocking_thread_id;
+ BOOL resumed;
+
+ (*addremove_io_semaphore)(c->blocking_response_ready, FALSE);
+ blocking_child_thread =
+ (HANDLE)_beginthreadex(
+ NULL,
+ 0,
+ &blocking_thread,
+ c,
+ CREATE_SUSPENDED,
+ &blocking_thread_id);
+
+ if (NULL == blocking_child_thread) {
+ msyslog(LOG_ERR, "start blocking thread failed: %m");
+ exit(-1);
+ }
+ c->thread_id = blocking_thread_id;
+ c->thread_ref = blocking_child_thread;
+ /* remember the thread priority is only within the process class */
+ if (!SetThreadPriority(blocking_child_thread,
+ THREAD_PRIORITY_BELOW_NORMAL))
+ msyslog(LOG_ERR, "Error lowering blocking thread priority: %m");
+
+ resumed = ResumeThread(blocking_child_thread);
+ DEBUG_INSIST(resumed);
+}
+#else /* pthreads start_blocking_thread_internal() follows */
+{
+# ifdef NEED_PTHREAD_INIT
+ static int pthread_init_called;
+# endif
+ pthread_attr_t thr_attr;
+ int rc;
+ int saved_errno;
+ int pipe_ends[2]; /* read then write */
+ int is_pipe;
+ int flags;
+ size_t stacksize;
+ sigset_t saved_sig_mask;
+
+# ifdef NEED_PTHREAD_INIT
+ /*
+ * from lib/isc/unix/app.c:
+ * BSDI 3.1 seg faults in pthread_sigmask() if we don't do this.
+ */
+ if (!pthread_init_called) {
+ pthread_init();
+ pthread_init_called = TRUE;
+ }
+# endif
+
+ rc = pipe_socketpair(&pipe_ends[0], &is_pipe);
+ if (0 != rc) {
+ msyslog(LOG_ERR, "start_blocking_thread: pipe_socketpair() %m");
+ exit(1);
+ }
+ c->resp_read_pipe = move_fd(pipe_ends[0]);
+ c->resp_write_pipe = move_fd(pipe_ends[1]);
+ c->ispipe = is_pipe;
+ flags = fcntl(c->resp_read_pipe, F_GETFL, 0);
+ if (-1 == flags) {
+ msyslog(LOG_ERR, "start_blocking_thread: fcntl(F_GETFL) %m");
+ exit(1);
+ }
+ rc = fcntl(c->resp_read_pipe, F_SETFL, O_NONBLOCK | flags);
+ if (-1 == rc) {
+ msyslog(LOG_ERR,
+ "start_blocking_thread: fcntl(F_SETFL, O_NONBLOCK) %m");
+ exit(1);
+ }
+ (*addremove_io_fd)(c->resp_read_pipe, c->ispipe, FALSE);
+ pthread_attr_init(&thr_attr);
+ pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
+#if defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE) && \
+ defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE)
+ rc = pthread_attr_getstacksize(&thr_attr, &stacksize);
+ if (-1 == rc) {
+ msyslog(LOG_ERR,
+ "start_blocking_thread: pthread_attr_getstacksize %m");
+ } else if (stacksize < THREAD_MINSTACKSIZE) {
+ rc = pthread_attr_setstacksize(&thr_attr,
+ THREAD_MINSTACKSIZE);
+ if (-1 == rc)
+ msyslog(LOG_ERR,
+ "start_blocking_thread: pthread_attr_setstacksize(0x%lx -> 0x%lx) %m",
+ (u_long)stacksize,
+ (u_long)THREAD_MINSTACKSIZE);
+ }
+#else
+ UNUSED_ARG(stacksize);
+#endif
+#if defined(PTHREAD_SCOPE_SYSTEM) && defined(NEED_PTHREAD_SCOPE_SYSTEM)
+ pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
+#endif
+ c->thread_ref = emalloc_zero(sizeof(*c->thread_ref));
+ block_thread_signals(&saved_sig_mask);
+ rc = pthread_create(c->thread_ref, &thr_attr,
+ &blocking_thread, c);
+ saved_errno = errno;
+ pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
+ pthread_attr_destroy(&thr_attr);
+ if (0 != rc) {
+ errno = saved_errno;
+ msyslog(LOG_ERR, "pthread_create() blocking child: %m");
+ exit(1);
+ }
+}
+#endif
+
+
+/*
+ * block_thread_signals()
+ *
+ * Temporarily block signals used by ntpd main thread, so that signal
+ * mask inherited by child threads leaves them blocked. Returns prior
+ * active signal mask via pmask, to be restored by the main thread
+ * after pthread_create().
+ */
+#ifndef SYS_WINNT
+void
+block_thread_signals(
+ sigset_t * pmask
+ )
+{
+ sigset_t block;
+
+ sigemptyset(&block);
+# ifdef HAVE_SIGNALED_IO
+# ifdef SIGIO
+ sigaddset(&block, SIGIO);
+# endif
+# ifdef SIGPOLL
+ sigaddset(&block, SIGPOLL);
+# endif
+# endif /* HAVE_SIGNALED_IO */
+ sigaddset(&block, SIGALRM);
+ sigaddset(&block, MOREDEBUGSIG);
+ sigaddset(&block, LESSDEBUGSIG);
+# ifdef SIGDIE1
+ sigaddset(&block, SIGDIE1);
+# endif
+# ifdef SIGDIE2
+ sigaddset(&block, SIGDIE2);
+# endif
+# ifdef SIGDIE3
+ sigaddset(&block, SIGDIE3);
+# endif
+# ifdef SIGDIE4
+ sigaddset(&block, SIGDIE4);
+# endif
+# ifdef SIGBUS
+ sigaddset(&block, SIGBUS);
+# endif
+ sigemptyset(pmask);
+ pthread_sigmask(SIG_BLOCK, &block, pmask);
+}
+#endif /* !SYS_WINNT */
+
+
+/*
+ * prepare_child_sems()
+ *
+ * create sync events (semaphores)
+ * child_is_blocking initially unset
+ * blocking_req_ready initially unset
+ *
+ * Child waits for blocking_req_ready to be set after
+ * setting child_is_blocking. blocking_req_ready and
+ * blocking_response_ready are auto-reset, so wake one
+ * waiter and become unset (unsignalled) in one operation.
+ */
+static void
+prepare_child_sems(
+ blocking_child *c
+ )
+#ifdef SYS_WINNT
+{
+ if (NULL == c->blocking_req_ready) {
+ /* manual reset using ResetEvent() */
+ /* !!!! c->child_is_blocking = CreateEvent(NULL, TRUE, FALSE, NULL); */
+ /* auto reset - one thread released from wait each set */
+ c->blocking_req_ready = CreateEvent(NULL, FALSE, FALSE, NULL);
+ c->blocking_response_ready = CreateEvent(NULL, FALSE, FALSE, NULL);
+ c->wake_scheduled_sleep = CreateEvent(NULL, FALSE, FALSE, NULL);
+ } else {
+ /* !!!! ResetEvent(c->child_is_blocking); */
+ /* ResetEvent(c->blocking_req_ready); */
+ /* ResetEvent(c->blocking_response_ready); */
+ /* ResetEvent(c->wake_scheduled_sleep); */
+ }
+}
+#else /* pthreads prepare_child_sems() follows */
+{
+ size_t octets;
+
+ if (NULL == c->blocking_req_ready) {
+ octets = sizeof(*c->blocking_req_ready);
+ octets += sizeof(*c->wake_scheduled_sleep);
+ /* !!!! octets += sizeof(*c->child_is_blocking); */
+ c->blocking_req_ready = emalloc_zero(octets);;
+ c->wake_scheduled_sleep = 1 + c->blocking_req_ready;
+ /* !!!! c->child_is_blocking = 1 + c->wake_scheduled_sleep; */
+ } else {
+ sem_destroy(c->blocking_req_ready);
+ sem_destroy(c->wake_scheduled_sleep);
+ /* !!!! sem_destroy(c->child_is_blocking); */
+ }
+ sem_init(c->blocking_req_ready, FALSE, 0);
+ sem_init(c->wake_scheduled_sleep, FALSE, 0);
+ /* !!!! sem_init(c->child_is_blocking, FALSE, 0); */
+}
+#endif
+
+
+static int
+wait_for_sem(
+ sem_ref sem,
+ struct timespec * timeout /* wall-clock */
+ )
+#ifdef SYS_WINNT
+{
+ struct timespec now;
+ struct timespec delta;
+ DWORD msec;
+ DWORD rc;
+
+ if (NULL == timeout) {
+ msec = INFINITE;
+ } else {
+ getclock(TIMEOFDAY, &now);
+ delta = sub_tspec(*timeout, now);
+ if (delta.tv_sec < 0) {
+ msec = 0;
+ } else if ((delta.tv_sec + 1) >= (MAXDWORD / 1000)) {
+ msec = INFINITE;
+ } else {
+ msec = 1000 * (DWORD)delta.tv_sec;
+ msec += delta.tv_nsec / (1000 * 1000);
+ }
+ }
+ rc = WaitForSingleObject(sem, msec);
+ if (WAIT_OBJECT_0 == rc)
+ return 0;
+ if (WAIT_TIMEOUT == rc) {
+ errno = ETIMEDOUT;
+ return -1;
+ }
+ msyslog(LOG_ERR, "WaitForSingleObject unexpected 0x%x", rc);
+ errno = EFAULT;
+ return -1;
+}
+#else /* pthreads wait_for_sem() follows */
+{
+ int rc;
+
+ if (NULL == timeout)
+ rc = sem_wait(sem);
+ else
+ rc = sem_timedwait(sem, timeout);
+
+ return rc;
+}
+#endif
+
+
+/*
+ * blocking_thread - thread functions have WINAPI calling convention
+ */
+#ifdef SYS_WINNT
+u_int
+WINAPI
+#else
+void *
+#endif
+blocking_thread(
+ void * ThreadArg
+ )
+{
+ blocking_child *c;
+
+ c = ThreadArg;
+ exit_worker(blocking_child_common(c));
+
+ /* NOTREACHED */
+ return 0;
+}
+
+
+/*
+ * req_child_exit() runs in the parent.
+ */
+int
+req_child_exit(
+ blocking_child *c
+ )
+{
+ return queue_req_pointer(c, CHILD_EXIT_REQ);
+}
+
+
+/*
+ * cleanup_after_child() runs in parent.
+ */
+static void
+cleanup_after_child(
+ blocking_child * c
+ )
+{
+ u_int idx;
+
+ DEBUG_INSIST(!c->reusable);
+#ifdef SYS_WINNT
+ INSIST(CloseHandle(c->thread_ref));
+#else
+ free(c->thread_ref);
+#endif
+ c->thread_ref = NULL;
+ c->thread_id = 0;
+#ifdef WORK_PIPE
+ DEBUG_INSIST(-1 != c->resp_read_pipe);
+ DEBUG_INSIST(-1 != c->resp_write_pipe);
+ (*addremove_io_fd)(c->resp_read_pipe, c->ispipe, TRUE);
+ close(c->resp_write_pipe);
+ close(c->resp_read_pipe);
+ c->resp_write_pipe = -1;
+ c->resp_read_pipe = -1;
+#else
+ DEBUG_INSIST(NULL != c->blocking_response_ready);
+ (*addremove_io_semaphore)(c->blocking_response_ready, TRUE);
+#endif
+ for (idx = 0; idx < c->workitems_alloc; idx++)
+ c->workitems[idx] = NULL;
+ c->next_workitem = 0;
+ c->next_workeritem = 0;
+ for (idx = 0; idx < c->responses_alloc; idx++)
+ c->responses[idx] = NULL;
+ c->next_response = 0;
+ c->next_workresp = 0;
+ c->reusable = TRUE;
+}
+
+
+#else /* !WORK_THREAD follows */
+char work_thread_nonempty_compilation_unit;
+#endif
diff --git a/contrib/ntp/libntp/ymd2yd.c b/contrib/ntp/libntp/ymd2yd.c
index 796ce40..c6b3a0c 100644
--- a/contrib/ntp/libntp/ymd2yd.c
+++ b/contrib/ntp/libntp/ymd2yd.c
@@ -1,37 +1,26 @@
/*
* ymd2yd - compute the date in the year from y/m/d
+ *
+ * A thin wrapper around a more general calendar function.
*/
-#include "ntp_fp.h"
-#include "ntp_unixtime.h"
+#include <config.h>
#include "ntp_stdlib.h"
-
-/*
- * Tables to compute the day of year from yyyymmdd timecode.
- * Viva la leap.
- */
-static int day1tab[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-static int day2tab[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+#include "ntp_calendar.h"
int
ymd2yd(
int y,
int m,
- int d
- )
+ int d)
{
- int i, *t;
-
- if (m < 1 || m > 12 || d < 1)
- return (-1);
-
- if (((y%4 == 0) && (y%100 != 0)) || (y%400 == 0))
- t = day2tab; /* leap year */
- else
- t = day1tab; /* not a leap year */
- if (d > t[m - 1])
- return (-1);
- for (i = 0; i < m - 1; i++)
- d += t[i];
- return d;
+ /*
+ * convert y/m/d to elapsed calendar units, convert that to
+ * elapsed days since the start of the given year and convert
+ * back to unity-based day in year.
+ *
+ * This does no further error checking, since the underlying
+ * function is assumed to work out how to handle the data.
+ */
+ return ntpcal_edate_to_yeardays(y-1, m-1, d-1) + 1;
}
OpenPOWER on IntegriCloud